Fix issues with case sensitivity for qstyles (#1526)

This commit is contained in:
Paul Friederichsen 2024-03-16 13:27:48 -05:00 committed by GitHub
parent 7bc49e94ba
commit 00c43b6f42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 18 deletions

View File

@ -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 ):