From b8f0c62149cc1575cc3f7dd576b88a88ad0b59dc Mon Sep 17 00:00:00 2001 From: Mateus Meyer Jiacomelli Date: Tue, 7 Feb 2023 15:28:56 +0000 Subject: [PATCH] Fixing orphan code [skip ci] --- openlp/core/app.py | 13 ++++++------- openlp/core/common/enum.py | 10 ---------- openlp/core/ui/advancedtab.py | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/openlp/core/app.py b/openlp/core/app.py index ed0327e22..4b313781f 100644 --- a/openlp/core/app.py +++ b/openlp/core/app.py @@ -396,10 +396,6 @@ def backup_if_version_changed(settings): return True -def get_hidpi_mode(args, settings): - return settings.value('advanced/hidpi mode') - - def apply_dpi_adjustments_stage_qt(hidpi_mode, qt_args): if hidpi_mode == HiDPIMode.Windows_Unaware: os.environ['QT_SCALE_FACTOR'] = '1' @@ -484,6 +480,7 @@ def main(): QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) init_webview_custom_schemes() application = QtWidgets.QApplication(qt_args) + application.setApplicationName('OpenLP') application.setOrganizationDomain('openlp.org') application.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) application.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings, True) @@ -497,7 +494,7 @@ def main(): font.setPointSizeF(font.pointSizeF() * application.devicePixelRatio()) application.setFont(font) if args.portable: - QtWidgets.QApplication.setApplicationName('OpenLPPortable') + application.setApplicationName('OpenLPPortable') Settings.setDefaultFormat(Settings.IniFormat) # Get location OpenLPPortable.ini if args.portablepath: @@ -510,6 +507,7 @@ def main(): portable_path = resolve(portable_path) data_path = portable_path / 'Data' set_up_logging(portable_path / 'Other') + set_up_web_engine_cache(portable_path / 'Other' / 'web_cache') log.info('Running portable') portable_settings_path = data_path / 'OpenLP.ini' # Make this our settings file @@ -523,8 +521,9 @@ def main(): portable_settings.setValue('advanced/is portable', True) portable_settings.sync() else: - QtWidgets.QApplication.setApplicationName('OpenLP') + application.setApplicationName('OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) + set_up_web_engine_cache(AppLocation.get_directory(AppLocation.CacheDir) / 'web_cache') # Set the libvlc environment variable if we're frozen if getattr(sys, 'frozen', False): # Path to libvlc and the plugins @@ -544,7 +543,7 @@ def main(): Registry.create() settings = Settings() # Doing HiDPI adjustments that need to be done before QCoreApplication instantiation. - hidpi_mode = get_hidpi_mode(args, settings) + hidpi_mode = settings.value('advanced/hidpi mode') apply_dpi_adjustments_stage_qt(hidpi_mode, qt_args) # Instantiating QCoreApplication application = QtWidgets.QApplication(qt_args) diff --git a/openlp/core/common/enum.py b/openlp/core/common/enum.py index e8eeef3af..0e5092cff 100644 --- a/openlp/core/common/enum.py +++ b/openlp/core/common/enum.py @@ -164,13 +164,3 @@ class HiDPIMode(IntEnum): Legacy = 1, # (Windows only) Make the OpenLP run unaware of any screen scaling. Windows_Unaware = 2 - - @staticmethod - def parse(value): - value = value.lower() if isinstance(value, str) else value - if value in [0, '0', 'default']: - return HiDPIMode.Default - elif value in [1, '1', 'legacy']: - return HiDPIMode.Legacy - elif value in [2, '2', 'windows_unaware']: - return HiDPIMode.Windows_Unaware diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index bc0f4dacb..61cff515b 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -317,7 +317,7 @@ class AdvancedTab(SettingsTab): :param checked: The state of the check box (boolean). """ - if (self.isVisible()): + if self.isVisible(): QtWidgets.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP '