Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2249: Create a global stylesheet and allow user-built themes #2258

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
592b597
Create a global style sheet attached to MainWindow that is housed in …
krzywon Oct 24, 2022
56a129c
Remove inline styles from the about box
krzywon Oct 25, 2022
592f8c1
Remove inline styles from the acknowledgements window
krzywon Oct 25, 2022
be7d3a3
Remove inline styles from the data explorer widget
krzywon Oct 25, 2022
9abf246
Remove inline styles from the welcome panel
krzywon Oct 25, 2022
876488f
Overwrite style sheet on save instead of appending
krzywon Oct 25, 2022
7b04a81
Add headers to differentiate different styles
krzywon Oct 25, 2022
05d1aa9
Replace inline styles in data operations panel with dynamic styles
krzywon Oct 25, 2022
6cd5cbb
Move inline styles from generic scattering calculator to the style sheet
krzywon Oct 25, 2022
9b52fc9
Set global font family and style class for special characters
krzywon Oct 25, 2022
d479fa7
Create GuiUtils widget property updater and apply urgent property to …
krzywon Oct 25, 2022
f4f4232
Apply GuiUtils property updater to data operations panel
krzywon Oct 25, 2022
6d2dbad
Respond to review concerns
krzywon Oct 25, 2022
c7e8435
Use guiutils property updater for GSC and resolution calculator
krzywon Oct 25, 2022
060e6e0
Commit sasview.css changes for previous commit and roll-back style.py…
krzywon Oct 25, 2022
00f97d1
Remove unneeded style polish and updates in add multiply editor window
krzywon Oct 25, 2022
55372da
Add italics option to style sheet and apply to grid panel while gener…
krzywon Oct 25, 2022
e267beb
Move default styles into python to eliminate file not found errors
krzywon Oct 25, 2022
349c2ad
Merge main into 2249-use-generic-stylesheet and resolve conflicts
krzywon Feb 7, 2023
5f99581
Merge main into 2249-use-generic-stylesheet and resolve conflicts
krzywon Sep 16, 2023
213e4b3
Create helper methods and default style sheet in configuration system
krzywon Sep 16, 2023
954b05a
Rename STYLE_SHEET to THEME and change value
krzywon Sep 16, 2023
0b212c8
Remove unneeded value from themes and update style manager to match t…
krzywon Sep 16, 2023
03cd392
Replace theme updator with property
krzywon Sep 16, 2023
e53bfd5
Update main window styles
krzywon Sep 16, 2023
fa014d9
Add theme combobox to display preferences
krzywon Sep 16, 2023
869d9aa
Fix pathing issue when loading files
krzywon Sep 16, 2023
558fc0f
Tweak default styles and remove html-specific styles
krzywon Sep 16, 2023
8a24207
Update generic scattering calculator to to use common styles
krzywon Sep 17, 2023
8346368
Update resolution calculator to to use common styles
krzywon Sep 17, 2023
9800ca0
Update preferences panel to use style sheets
krzywon Sep 17, 2023
b8af23c
Update model editor to use style sheets
krzywon Sep 17, 2023
e41b652
Update invariant perspective to use style sheets
krzywon Sep 17, 2023
444017e
Update corfunc perspective to use style sheets
krzywon Sep 17, 2023
110d632
Update fitting widget to use style sheets
krzywon Sep 17, 2023
585622d
Update remaining fitting pieces to use style sheets
krzywon Sep 17, 2023
5cabf67
Add start of dark theme
krzywon Sep 17, 2023
c8d22b5
Add start of large font theme
krzywon Sep 17, 2023
9bedc88
Tweaks to dark font theme
krzywon Sep 17, 2023
0ed78c3
Merge branch 'main' into 2249-use-generic-stylesheet
lucas-wilkins Sep 17, 2023
03f857f
Fix issue where config file was secondary to config defaults
krzywon Sep 18, 2023
d8701f4
Remove reject from fitting options and return instead
krzywon Sep 18, 2023
10bc32b
Set proper default value for style preference
krzywon Sep 18, 2023
f160d91
Disable alternate themes to be finalized later
krzywon Sep 18, 2023
3f81896
Include css files in the build spec
krzywon Sep 18, 2023
0fae36e
Merge main into 2249-use-generic-stylesheet and resolve merge conflicts
krzywon Sep 21, 2023
1d0e075
Dark theme improved a bit
lucas-wilkins Sep 22, 2023
483057a
Rename default to classic
krzywon Oct 30, 2023
0649dbe
Include classic theme as an option
krzywon Oct 30, 2023
e0ad232
Update default theme to be more modern looking
krzywon Oct 30, 2023
9439855
Add QTabWidget styles in default theme
krzywon Oct 30, 2023
37abdbe
Tweaks to default theme
krzywon Oct 30, 2023
97ec077
Tweak menu items in default theme
krzywon Oct 30, 2023
ceea678
Replace dark theme using default theme as a basis
krzywon Oct 30, 2023
450e37f
Replace large font theme using default theme as a basis
krzywon Oct 30, 2023
85cd609
Remove alternating colors from model list view
krzywon Oct 30, 2023
2a8fe18
Pass parent to tool panels to ensure theme is applied to them
krzywon Oct 30, 2023
f4e9146
Apply style sheet to orientation viewer and what's new box
krzywon Oct 30, 2023
001d220
Ensure user themes use the classic theme as a basis.
krzywon Oct 30, 2023
1f96f97
Auto apply theme when selected
krzywon Oct 30, 2023
47c62f6
Ensure user themes are in dictionary when switching themes
krzywon Oct 30, 2023
3d8bf0b
Documentation
krzywon Oct 30, 2023
f364613
Merge main into 2249-use-generic-stylesheet and resolve conflicts in …
krzywon Oct 30, 2023
d7a5d39
Update themes for new "Send To" perspective button type
krzywon Oct 30, 2023
de6442b
Pass parent to FileConverter to ensure styles are applied
krzywon Oct 31, 2023
0c5166b
Dark theme clean up for checkboxes and minimize blue color
krzywon Nov 3, 2023
b7575d4
Tweaks to the default and large font themes
krzywon Nov 3, 2023
96639f0
Allow user to set font size and theme independently
krzywon Nov 6, 2023
48260c4
Updates to QTreeView taken out of the fitting widget
krzywon Nov 8, 2023
efc3945
Clean up tree view and checked heck box look
krzywon Nov 8, 2023
86b7685
Separate out common theme elements from light and dark only leaving c…
krzywon Nov 8, 2023
22aaeac
Update user and developer documentation to match current features
krzywon Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sas/qtgui/MainWindow/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys

from sas import config
from sas.system import env, version
from sas.system import env, version, style

from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QMdiArea
Expand Down Expand Up @@ -98,7 +98,7 @@ def run_sasview():
splash.show()
app.setAttribute(Qt.AA_EnableHighDpiScaling)
# Main application style.
#app.setStyle('Fusion')
app.setStyleSheet(style.style_sheet())

# fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
if 'twisted.internet.reactor' in sys.modules:
Expand Down
2 changes: 1 addition & 1 deletion src/sas/system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .env import env
from .config.config import config

__all__ = ["web", "legal", "env", "config"]
__all__ = ["web", "legal", "env", "config", "style"]
6 changes: 6 additions & 0 deletions src/sas/system/sasview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* {font-size: 10pt;}

QLineEdit {background-color: white; color: black;}
QLineEdit:focus {background-color: #98dbcc; color: #333333}

.warning {background-color: red;}
73 changes: 73 additions & 0 deletions src/sas/system/style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
import pkg_resources
import sys

from sas.system import user

DEFAULT_STYLE_SHEET_NAME = 'sasview.css'
krzywon marked this conversation as resolved.
Show resolved Hide resolved


class StyleSheet:
"""
The directory where the per-user style sheet is stored.
krzywon marked this conversation as resolved.
Show resolved Hide resolved

Returns ~/.sasview/sasview.css, creating it if it does not already exist.
"""
def __init__(self):
self.style_sheet = None
self._find_style_sheet()
self.save()
krzywon marked this conversation as resolved.
Show resolved Hide resolved
krzywon marked this conversation as resolved.
Show resolved Hide resolved

def style_sheet_filename(self):
krzywon marked this conversation as resolved.
Show resolved Hide resolved
"""Filename for saving config items"""
user_dir = user.get_user_dir()
self.style_sheet = os.path.join(user_dir, DEFAULT_STYLE_SHEET_NAME)

def save(self):
self._find_style_sheet()
sheet = self()
self.style_sheet_filename()
with open(self.style_sheet, 'a') as file:
file.write(sheet)

def _find_style_sheet(self, filename=DEFAULT_STYLE_SHEET_NAME):
krzywon marked this conversation as resolved.
Show resolved Hide resolved
'''
The style sheet is in:
User directory ~/.sasview/
Debug .
Packaging: sas/sasview/
Packaging / production does not work well with absolute paths
thus the multiple paths below
'''
self.style_sheet_filename()
places_to_look_for_conf_file = [
krzywon marked this conversation as resolved.
Show resolved Hide resolved
self.style_sheet,
os.path.join(os.path.abspath(os.path.dirname(__file__)), filename),
filename,
os.path.join("sas", "system", filename),
os.path.join(os.getcwd(), "sas", "system", filename),
os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), filename) #For OSX app
]

# To avoid the exception in OSx
# NotImplementedError: resource_filename() only supported for .egg, not .zip
try:
places_to_look_for_conf_file.append(
pkg_resources.resource_filename(__name__, filename))
except NotImplementedError:
pass

for filepath in places_to_look_for_conf_file:
if os.path.exists(filepath):
self.style_sheet = filepath
return
print(f"'{filename}' not found.", file=sys.stderr)
self.style_sheet = None

def __call__(self, *args, **kwargs):
krzywon marked this conversation as resolved.
Show resolved Hide resolved
with open(self.style_sheet) as f:
style = f.read()
return style


style_sheet = StyleSheet()