From 00c43b6f421d1166f66e1c97750c2dd2e94a8798 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Sat, 16 Mar 2024 13:27:48 -0500 Subject: [PATCH] Fix issues with case sensitivity for qstyles (#1526) --- hydrus/client/gui/ClientGUIStyle.py | 31 ++++++++++++----------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/hydrus/client/gui/ClientGUIStyle.py b/hydrus/client/gui/ClientGUIStyle.py index 00aed16d..509c2072 100644 --- a/hydrus/client/gui/ClientGUIStyle.py +++ b/hydrus/client/gui/ClientGUIStyle.py @@ -66,10 +66,8 @@ def InitialiseDefaults(): global ORIGINAL_STYLE_NAME - global CURRENT_STYLE_NAME - ORIGINAL_STYLE_NAME = QW.QApplication.instance().style().objectName() - CURRENT_STYLE_NAME = ORIGINAL_STYLE_NAME + ORIGINAL_STYLE_NAME = QW.QApplication.instance().style().name() global ORIGINAL_STYLESHEET global CURRENT_STYLESHEET @@ -77,31 +75,28 @@ def InitialiseDefaults(): ORIGINAL_STYLESHEET = QW.QApplication.instance().styleSheet() CURRENT_STYLESHEET = ORIGINAL_STYLESHEET -def SetStyleFromName( name ): +def SetStyleFromName( name: str ): - global CURRENT_STYLE_NAME - - if name == CURRENT_STYLE_NAME: + current_style_name = QW.QApplication.instance().style().name() + + if name.casefold() == current_style_name.casefold(): return - if name in GetAvailableStyles(): + try: - try: + new_style = QW.QApplication.instance().setStyle( name ) + + if new_style is None: - QW.QApplication.instance().setStyle( name ) - - CURRENT_STYLE_NAME = name - - except Exception as e: - - raise HydrusExceptions.DataMissing( 'Style "{}" could not be generated/applied. If this is the default, perhaps a third-party custom style, you may have to restart the client to re-set it. Extra error info: {}'.format( name, e ) ) + raise HydrusExceptions.DataMissing( 'Style "{}" does not exist! If this is the default, perhaps a third-party custom style, you may have to restart the client to re-set it.'.format( name ) ) - else: + except Exception as e: - raise HydrusExceptions.DataMissing( 'Style "{}" does not exist! If this is the default, perhaps a third-party custom style, you may have to restart the client to re-set it.'.format( name ) ) + raise HydrusExceptions.DataMissing( 'Style "{}" could not be generated/applied. If this is the default, perhaps a third-party custom style, you may have to restart the client to re-set it. Extra error info: {}'.format( name, e ) ) + def SetStyleSheet( stylesheet, prepend_hydrus = True ):