From 22aaeac561d0e42d3b634c6de84fa0a60533fbbd Mon Sep 17 00:00:00 2001 From: krzywon Date: Wed, 8 Nov 2023 14:01:13 -0500 Subject: [PATCH] Update user and developer documentation to match current features --- src/sas/qtgui/MainWindow/media/preferences_help.rst | 3 +++ .../Utilities/Preferences/DisplayPreferencesWidget.py | 2 ++ src/sas/system/style.py | 10 +++++++++- src/sas/system/themes/__init__.py | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sas/qtgui/MainWindow/media/preferences_help.rst b/src/sas/qtgui/MainWindow/media/preferences_help.rst index 4c9b6f9479..7f09823306 100644 --- a/src/sas/qtgui/MainWindow/media/preferences_help.rst +++ b/src/sas/qtgui/MainWindow/media/preferences_help.rst @@ -45,6 +45,9 @@ use the `Classic` theme as a fall back for any styles not defined in the stylesh is a stylesheet. For more information on writing Qt stylesheets, please see the `Qt style sheet reference `_ *persistent* +**Font Size** Select the font size that will be used throughout the SasView application. Font sizes defined in User themes +will override this setting. + **QT Screen Scale Factor**: A percent scaling factor that is applied all element sizes within the GUI. A restart of SasView is required to take effect. *persistent* diff --git a/src/sas/qtgui/Utilities/Preferences/DisplayPreferencesWidget.py b/src/sas/qtgui/Utilities/Preferences/DisplayPreferencesWidget.py index b7bf1777e0..fc7613b4fb 100644 --- a/src/sas/qtgui/Utilities/Preferences/DisplayPreferencesWidget.py +++ b/src/sas/qtgui/Utilities/Preferences/DisplayPreferencesWidget.py @@ -18,11 +18,13 @@ def __init__(self): 'QT_AUTO_SCREEN_SCALE_FACTOR': "Enable Automatic Scaling"} def _addAllWidgets(self): + self.addHorizontalLine() self.theme = self.addComboBox(title="Theme", params=style.get_theme_names(), default=style.theme) self.theme.currentIndexChanged.connect(self._previewTheme) self.font_size = self.addComboBox(title="Font Size", params=['10.0', '12.0', '14.0'], default=str(style.font_size)) self.font_size.currentIndexChanged.connect(self._previewFont) + self.addHorizontalLine() self.qtScaleFactor = self.addFloatInput( title="QT Screen Scale Factor", default_number=config.QT_SCALE_FACTOR) diff --git a/src/sas/system/style.py b/src/sas/system/style.py index e277c47e6b..05694155d4 100644 --- a/src/sas/system/style.py +++ b/src/sas/system/style.py @@ -9,6 +9,14 @@ class StyleSheet: Class used to manage all available themes. Built-in themes are available in sas.system.themes. User themes should live in ~/.sasview/themes. + + *CSS Order of operations:* + Each operation overrides any previous operation to allow user themes to take precedence over any built-in thematic + elements. + 1. The default font size and fonts are set. + 2. The base style sheet is set -> typically either classic.css for user themes or themes.STYLE_BASE for built-in + 3. Color palettes are applied (Dark or Light), if applicable. + 4. User theme elements are applied. """ def __init__(self): @@ -54,7 +62,7 @@ def get_theme_names(self) -> List[str]: return list(self._available_themes.keys()) def _create_full_theme(self): - """Private method that combines settings so users can separately set fonts and color palettes.""" + """Private method that combines settings to allow fonts and color palettes to be set separately.""" css = load_theme(self.theme) font_str = format_font_size(self.font_size) self._css = f"{font_str}{css}" diff --git a/src/sas/system/themes/__init__.py b/src/sas/system/themes/__init__.py index b6be112b73..02910a0600 100644 --- a/src/sas/system/themes/__init__.py +++ b/src/sas/system/themes/__init__.py @@ -14,6 +14,7 @@ 'Dark': Path(os.path.join(os.path.dirname(__file__), 'dark.css')), 'Classic': Path(os.path.join(os.path.dirname(__file__), 'classic.css')), } +# A list of style sheets that use the base style given in the STYLE_BASE USES_STYLE_BASE = ['Light', 'Dark'] # A template string for setting the font size @@ -63,6 +64,8 @@ def format_font_size(font_size: float) -> str: return FONT.format(font_size) +# STYLE_BASE defines the base sizes and behaviors of all widgets and interactive elements for the Light and Dark themes. +# The styles are here, so they are not considered as a separate style sheet when looking at built-in themes. STYLE_BASE = """ /* QWidget Properties */ QWidget:focus {outline: none;}