-
Notifications
You must be signed in to change notification settings - Fork 3.3k
qt: use system theme as default theme and add 'System' theme option #9684
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1328,6 +1328,17 @@ def font_height(widget: QWidget = None) -> int: | |||||||||||||||||||||||
return QFontMetrics(widget.font()).height() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def is_system_dark_mode() -> bool: | ||||||||||||||||||||||||
"""Returns True if the system theme is in dark mode, False otherwise.""" | ||||||||||||||||||||||||
Comment on lines
+1331
to
+1332
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the motivation for this PR? Is it that when running on a dark system, you want an option to run electrum with the system qt theming but with electrum/electrum/gui/qt/__init__.py Lines 195 to 198 in 1559129
electrum/electrum/gui/qt/util.py Lines 1144 to 1150 in 1559129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The motivation for this PR is that its annoying having to set the theme manually in every application instead of just switching the system theme and have all applications follow it, especially when switching often due to lighting conditions. So this seemed like a small useful change to allow electrum automatically switch between the Oh yeah i didn't see |
||||||||||||||||||||||||
qapp: Optional[QApplication] = QApplication.instance() | ||||||||||||||||||||||||
if not qapp: | ||||||||||||||||||||||||
return False | ||||||||||||||||||||||||
palette: QPalette = qapp.palette() | ||||||||||||||||||||||||
window_color: QColor = palette.color(QPalette.ColorRole.Window) | ||||||||||||||||||||||||
text_color: QColor = palette.color(QPalette.ColorRole.WindowText) | ||||||||||||||||||||||||
return text_color.lightness() > window_color.lightness() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def webopen(url: str): | ||||||||||||||||||||||||
if sys.platform == 'linux' and os.environ.get('APPIMAGE'): | ||||||||||||||||||||||||
# When on Linux webbrowser.open can fail in AppImage because it can't find the correct libdbus. | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running on a system that has a dark theme, what exactly happens when the user sets GUI_QT_COLOR_THEME to "light"? Presumably the user would then expect Electrum to run in a light theme - but that's not what happens, is it? I suppose it is only a few colours here-and-there that gets changed.
What I am getting at is that the cornerstone of the "dark" theme is the qdarkstyle package, and the "system" ("default") theme is just whatever qt does by default. -- and on top of all that we have some hardcoded colors that depend on
GUI_QT_COLOR_THEME
(seeutil.ColorScheme
)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user sets
GUI_QT_COLOR_THEME
to light and has its system theme in dark mode electrum will start in the regular light theme (becauseuse_dark_theme
ifFalse
) respecting the configuration (nothing changes to master), at least on my machine (wayland, kde), is this behaviour different on other plattforms?The only place i see that is dependent on the value of
GUI_QT_COLOR_THEME
isreload_app_stylesheet()
:The only thing that changes in this pr is that
use_dark_theme
gets an additional condition, ifGUI_QT_COLOR_THEME
is set to default ('System' setting in GUI) and if the system theme is dark (determined byis_system_dark_mode()
) then also use the dark mode, else just go the same path as if the configuration isLight
.I see that ColorScheme is also dependent on the system theme (background color) but the behavior stays the same here as if
Light
is selected on master.