Theme: Tuned finish

Signed-off-by: LorenEteval <loren.eteval@proton.me>
This commit is contained in:
LorenEteval
2026-06-21 15:56:17 +08:00
committed by Loren Eteval
parent ec9e2a0e20
commit 97699f47db
4 changed files with 28 additions and 71 deletions
+8 -5
View File
@@ -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;
}}
+3 -56
View File
@@ -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):
+15 -8
View File
@@ -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,
+2 -2
View File
@@ -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()