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

Add qss theme from qtum core #106

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion electrum/gui/kivy/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class ElectrumWindow(App):

electrum_config = ObjectProperty(None)
language = StringProperty('en')

# properties might be updated by the network
num_blocks = NumericProperty(0)
num_nodes = NumericProperty(0)
Expand Down
19 changes: 2 additions & 17 deletions electrum/gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import threading
from typing import Optional, TYPE_CHECKING

from .theme_helper import set_qtum_theme_if_needed

try:
import PyQt5
Expand Down Expand Up @@ -128,25 +129,9 @@ def __init__(self, config: 'SimpleConfig', daemon: 'Daemon', plugins: 'Plugins')
self.build_tray_menu()
self.tray.show()
self.app.new_window_signal.connect(self.start_new_window)
self.set_dark_theme_if_needed()
set_qtum_theme_if_needed(self.config)
run_hook('init_qt', self)

def set_dark_theme_if_needed(self):
use_dark_theme = self.config.get('qt_gui_color_theme', 'default') == 'dark'
if use_dark_theme:
try:
import qdarkstyle
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
except BaseException as e:
use_dark_theme = False
self.logger.warning(f'Error setting dark theme: {repr(e)}')
# Apply any necessary stylesheet patches
patch_qt_stylesheet(use_dark_theme=use_dark_theme)
# Even if we ourselves don't set the dark theme,
# the OS/window manager/etc might set *a dark theme*.
# Hence, try to choose colors accordingly:
ColorScheme.update_from_widget(QWidget(), force_dark=use_dark_theme)

def build_tray_menu(self):
# Avoid immediate GC of old menu when window closed via its action
if self.tray.contextMenu() is None:
Expand Down
1 change: 0 additions & 1 deletion electrum/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ def new_wallet(self):

def init_menubar(self):
menubar = QMenuBar()

file_menu = menubar.addMenu(_("&File"))
self.recently_visited_menu = file_menu.addMenu(_("&Recently open"))
file_menu.addAction(_("&Open"), self.open_wallet).setShortcut(QKeySequence.Open)
Expand Down
9 changes: 6 additions & 3 deletions electrum/gui/qt/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from electrum.i18n import languages
from electrum import qrscanner

from .theme_helper import set_qtum_theme_if_needed
if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig
from .main_window import ElectrumWindow
Expand All @@ -55,7 +55,6 @@ def __init__(self, parent: 'ElectrumWindow', config: 'SimpleConfig'):
self.need_restart = False
self.fx = self.window.fx
self.wallet = self.window.wallet

vbox = QVBoxLayout()
tabs = QTabWidget()
gui_widgets = []
Expand Down Expand Up @@ -284,12 +283,16 @@ def on_unit(x, nz):
colortheme_combo = QComboBox()
colortheme_combo.addItem(_('Light'), 'default')
colortheme_combo.addItem(_('Dark'), 'dark')
colortheme_combo.addItem(_('Qtum Light'), 'qtum_light')
colortheme_combo.addItem(_('Qtum Dark Blue'), 'qtum_almost_dark')
colortheme_combo.addItem(_('Qtum Dark'), 'qtum_dark')

index = colortheme_combo.findData(self.config.get('qt_gui_color_theme', 'default'))
colortheme_combo.setCurrentIndex(index)
colortheme_label = QLabel(_('Color theme') + ':')
def on_colortheme(x):
self.config.set_key('qt_gui_color_theme', colortheme_combo.itemData(x), True)
self.need_restart = True
set_qtum_theme_if_needed(self.config)
colortheme_combo.currentIndexChanged.connect(on_colortheme)
gui_widgets.append((colortheme_label, colortheme_combo))

Expand Down
Loading