From 97699f47dbfc9e93cef1c9bd48cbc9b8608a4561 Mon Sep 17 00:00:00 2001 From: LorenEteval Date: Mon, 15 Jun 2026 18:15:57 +0800 Subject: [PATCH] Theme: Tuned finish Signed-off-by: LorenEteval --- Furious/Qt/AppStyleSheet.py | 13 ++++--- Furious/Qt/QtWidgets.py | 59 ++------------------------------ Furious/Widget/Application.py | 23 ++++++++----- Furious/Widget/GuiTUNSettings.py | 4 +-- 4 files changed, 28 insertions(+), 71 deletions(-) diff --git a/Furious/Qt/AppStyleSheet.py b/Furious/Qt/AppStyleSheet.py index 1064d85..c4e1708 100644 --- a/Furious/Qt/AppStyleSheet.py +++ b/Furious/Qt/AppStyleSheet.py @@ -23,6 +23,7 @@ __all__ = ['AppStyleSheet'] class AppStyleSheet: Light = 'Light' Dark = 'Dark' + FontPointSize = 10 Palettes = { Light: { @@ -134,7 +135,8 @@ class AppStyleSheet: }} QMenuBar::item {{ - padding: 6px 10px; + min-height: 24px; + padding: 9px 14px; border-radius: 4px; background: transparent; }} @@ -146,7 +148,7 @@ class AppStyleSheet: }} QMenu {{ - padding: 6px; + padding: 8px; border: 1px solid {palette['border']}; border-radius: 6px; background-color: {palette['panel']}; @@ -154,13 +156,14 @@ class AppStyleSheet: QMenu::separator {{ height: 1px; - margin: 5px 8px; + margin: 6px 8px; background-color: {palette['border']}; }} QMenu::item {{ - min-width: 120px; - padding: 6px 24px 6px 12px; + min-width: 132px; + min-height: 18px; + padding: 9px 28px 9px 14px; border-radius: 4px; background-color: transparent; }} diff --git a/Furious/Qt/QtWidgets.py b/Furious/Qt/QtWidgets.py index f952c97..789f3d0 100644 --- a/Furious/Qt/QtWidgets.py +++ b/Furious/Qt/QtWidgets.py @@ -19,6 +19,7 @@ from __future__ import annotations from Furious.Frozenlib import * from Furious.Library import * +from Furious.Qt.AppStyleSheet import * from Furious.Qt.DynamicTheme import * from Furious.Qt.DynamicTranslate import gettext as _ from Furious.Qt.QtGui import * @@ -370,7 +371,7 @@ class AppQMainWindow( pass -class AppQMenu(Mixins.QTranslatable, Mixins.ConnectionAware, QMenu): +class AppQMenu(Mixins.QTranslatable, QMenu): def __init__(self, *actions, **kwargs): super().__init__(**kwargs) @@ -390,68 +391,14 @@ class AppQMenu(Mixins.QTranslatable, Mixins.ConnectionAware, QMenu): # Do nothing pass - self.setStyleSheet(self.getStyleSheet(AppHue.currentColor())) - - @staticmethod - def getStyleSheet(color): - return ( - f'QMenu {{' - f' padding: 6px;' - f'}}' - f'' - f'QMenu::item {{' - f' padding: 6px 12px;' - # f' background-color: solid;' - f'}}' - # f'' - # f'QMenu::item:selected {{' - # f' background-color: {color};' - # f'}}' - ) - def retranslate(self): self.setTitle(_(self.title())) - def disconnectedCallback(self): - # self.setStyleSheet(self.getStyleSheet(AppHue.disconnectedColor())) - pass - - def connectedCallback(self): - # self.setStyleSheet(self.getStyleSheet(AppHue.connectedColor())) - - pass - - -class AppQMenuBar(Mixins.ConnectionAware, QMenuBar): +class AppQMenuBar(QMenuBar): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.setSelectionColor(AppHue.currentColor()) - - @staticmethod - def getStyleSheet(color): - return ( - f'QMenuBar::item:selected {{' - f' background: {color};' - f'}}' - f'' - f'QMenuBar::item:hover {{' - f' background: {color};' - f'}}' - ) - - def setSelectionColor(self, color): - # self.setStyleSheet(self.getStyleSheet(color)) - - pass - - def disconnectedCallback(self): - self.setSelectionColor(AppHue.disconnectedColor()) - - def connectedCallback(self): - self.setSelectionColor(AppHue.connectedColor()) - class AppQMessageBox(Mixins.QTranslatable, Mixins.ConnectionAware, QMessageBox): def __init__(self, *args, **kwargs): diff --git a/Furious/Widget/Application.py b/Furious/Widget/Application.py index 6404778..0e0ebdf 100644 --- a/Furious/Widget/Application.py +++ b/Furious/Widget/Application.py @@ -255,6 +255,12 @@ class Application(ApplicationFactory, SingletonApplication): # Delayed self.customFontLoadMsg = f'custom font {fontName} load failed' + def configureApplicationFont(self): + font = self.font() + font.setPointSize(AppStyleSheet.FontPointSize) + + self.setFont(font) + @staticmethod def addEnviron(): # Xray environment variables @@ -284,14 +290,16 @@ class Application(ApplicationFactory, SingletonApplication): return backgroudColor.lightness() < 128 - def systemTheme(self): + def systemTheme(self) -> str: try: theme = darkdetect.theme() - except Exception: - theme = None - if theme in [AppStyleSheet.Dark, AppStyleSheet.Light]: - return theme + if theme in [AppStyleSheet.Dark, AppStyleSheet.Light]: + return theme + except Exception: + # Any non-exit exceptions + + logger.error('darkdetect.theme() is not implemented on this platform') return AppStyleSheet.Dark if self.isDarkMode() else AppStyleSheet.Light @@ -414,6 +422,7 @@ class Application(ApplicationFactory, SingletonApplication): self.addEnviron() self.addStorage() self.addCustomFont() + # self.configureApplicationFont() self.configureLogging() logger.info(f'application version: {APPLICATION_VERSION}') @@ -482,9 +491,7 @@ class Application(ApplicationFactory, SingletonApplication): ) self.themeDetector = ApplicationThemeDetector() - self.themeDetector.themeChanged.connect( - self.handleSystemThemeChanged - ) + self.themeDetector.themeChanged.connect(self.handleSystemThemeChanged) self.themeListenerThread = threading.Thread( target=listener, diff --git a/Furious/Widget/GuiTUNSettings.py b/Furious/Widget/GuiTUNSettings.py index 6004439..a2146e7 100644 --- a/Furious/Widget/GuiTUNSettings.py +++ b/Furious/Widget/GuiTUNSettings.py @@ -233,9 +233,9 @@ class GuiTUNSettings(GuiEditorWidgetQDialog): self.setTabText(_('Customize TUN Settings')) if PLATFORM == 'Darwin' or PLATFORM == 'Linux': - self.setFixedSize(int(550 * GOLDEN_RATIO), int(550)) + self.setFixedSize(int(690 * GOLDEN_RATIO), int(690)) else: - self.setFixedSize(int(480 * GOLDEN_RATIO), int(480)) + self.setFixedSize(int(620 * GOLDEN_RATIO), int(620)) # Shallow copy config = Storage.UserTUNSettings()