Skip to content

Commit

Permalink
Update user and developer documentation to match current features
Browse files Browse the repository at this point in the history
  • Loading branch information
krzywon committed Nov 8, 2023
1 parent 86b7685 commit 22aaeac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/sas/qtgui/MainWindow/media/preferences_help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://doc.qt.io/qt-6/stylesheet-reference.html>`_ *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*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion src/sas/system/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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}"
Expand Down
3 changes: 3 additions & 0 deletions src/sas/system/themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;}
Expand Down

0 comments on commit 22aaeac

Please sign in to comment.