mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-09-22 23:08:08 +03:00
Fix theme detection
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
+1
-2
@@ -23,7 +23,6 @@ from PySide6.QtGui import *
|
||||
|
||||
import logging
|
||||
import functools
|
||||
import darkdetect
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -198,7 +197,7 @@ class AppQAction(Mixins.QTranslatable, Mixins.ThemeAware, QAction):
|
||||
# Fall back
|
||||
super().setIcon(icon)
|
||||
else:
|
||||
self.setIconByTheme(darkdetect.theme())
|
||||
self.setIconByTheme(APP().theme())
|
||||
|
||||
def themeChangedCallback(self, theme):
|
||||
self.setIconByTheme(theme)
|
||||
|
||||
@@ -285,13 +285,18 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
return backgroudColor.lightness() < 128
|
||||
|
||||
def isDarkModeEnabled(self):
|
||||
if SystemRuntime.flatpakID():
|
||||
return self.isDarkMode()
|
||||
# if SystemRuntime.flatpakID():
|
||||
# return self.isDarkMode()
|
||||
#
|
||||
# if not SystemRuntime.isAdmin():
|
||||
# return AppSettings.isStateON_('DarkMode')
|
||||
# else:
|
||||
# return self.isDarkMode()
|
||||
|
||||
if not SystemRuntime.isAdmin():
|
||||
return AppSettings.isStateON_('DarkMode')
|
||||
else:
|
||||
return self.isDarkMode()
|
||||
return AppSettings.isStateON_('DarkMode')
|
||||
|
||||
def theme(self):
|
||||
return 'Dark' if self.isDarkMode() else 'Light'
|
||||
|
||||
def switchToDarkMode(self):
|
||||
self.setStyleSheet(qdarkstyle.load_stylesheet_pyside6())
|
||||
@@ -301,7 +306,7 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
def switchToAutoMode(self):
|
||||
self.setStyleSheet('')
|
||||
|
||||
Mixins.ThemeAware.callThemeChangedCallbackUnchecked(darkdetect.theme())
|
||||
Mixins.ThemeAware.callThemeChangedCallbackUnchecked(self.theme())
|
||||
|
||||
@staticmethod
|
||||
@callOnceOnly
|
||||
@@ -416,21 +421,21 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
logger.info(f'isPythonw: {SystemRuntime.isPythonw()}')
|
||||
logger.info(f'system language is {SYSTEM_LANGUAGE}')
|
||||
logger.info(self.customFontLoadMsg)
|
||||
logger.info(f'current theme is {darkdetect.theme()}')
|
||||
logger.info(f'current theme is {self.theme()}')
|
||||
|
||||
if PLATFORM != 'Windows' and not SystemRuntime.isScriptMode():
|
||||
logger.info('theme detect method uses timer implementation')
|
||||
|
||||
@QtCore.Slot()
|
||||
def handleTimeout():
|
||||
currentTheme = darkdetect.theme()
|
||||
currentTheme = self.theme()
|
||||
|
||||
if self.currentTheme != currentTheme:
|
||||
self.currentTheme = currentTheme
|
||||
|
||||
Mixins.ThemeAware.callThemeChangedCallback(currentTheme)
|
||||
|
||||
self.currentTheme = darkdetect.theme()
|
||||
self.currentTheme = self.theme()
|
||||
self.themeDetectTimer = QtCore.QTimer()
|
||||
self.themeDetectTimer.timeout.connect(handleTimeout)
|
||||
self.themeDetectTimer.start(1000)
|
||||
|
||||
@@ -25,7 +25,6 @@ from PySide6.QtWidgets import QSystemTrayIcon
|
||||
|
||||
import logging
|
||||
import platform
|
||||
import darkdetect
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -143,7 +142,7 @@ class SystemTrayIcon(
|
||||
switchMonochrome()
|
||||
|
||||
def setMonochromeIcon(self):
|
||||
self.setMonochromeIconByTheme(darkdetect.theme())
|
||||
self.setMonochromeIconByTheme(APP().theme())
|
||||
|
||||
def setDisconnectedIcon(self):
|
||||
if AppSettings.isStateON_('UseMonochromeTrayIcon'):
|
||||
@@ -154,7 +153,7 @@ class SystemTrayIcon(
|
||||
if (
|
||||
PLATFORM == 'Darwin'
|
||||
or SystemRuntime.isWindows7()
|
||||
or (PLATFORM == 'Windows' and darkdetect.theme() == 'Light')
|
||||
or (PLATFORM == 'Windows' and APP().theme() == 'Light')
|
||||
):
|
||||
# Darker
|
||||
self.setIcon(bootstrapIcon('rocket-takeoff-dark.svg'))
|
||||
@@ -173,7 +172,7 @@ class SystemTrayIcon(
|
||||
if (
|
||||
PLATFORM == 'Darwin'
|
||||
or SystemRuntime.isWindows7()
|
||||
or (PLATFORM == 'Windows' and darkdetect.theme() == 'Light')
|
||||
or (PLATFORM == 'Windows' and APP().theme() == 'Light')
|
||||
):
|
||||
# Darker
|
||||
self.setIcon(bootstrapIcon('rocket-takeoff-connected-dark.svg'))
|
||||
@@ -202,7 +201,7 @@ class SystemTrayIcon(
|
||||
def themeChangedCallback(self, theme):
|
||||
if AppSettings.isStateON_('UseMonochromeTrayIcon'):
|
||||
# 'theme' is not used. Instead, always query current theme
|
||||
self.setMonochromeIconByTheme(darkdetect.theme())
|
||||
self.setMonochromeIconByTheme(APP().theme())
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import shutil
|
||||
import logging
|
||||
import datetime
|
||||
import functools
|
||||
import darkdetect
|
||||
|
||||
__all__ = ['XrayAssetViewerQListWidget']
|
||||
|
||||
@@ -65,7 +64,7 @@ class XrayAssetViewerQListWidget(Mixins.ThemeAware, AppQListWidget):
|
||||
self.setIconSize(QtCore.QSize(64, 64))
|
||||
|
||||
if PLATFORM == 'Linux' and SystemRuntime.ubuntuRelease() == '20.04':
|
||||
self.initialTheme = darkdetect.theme()
|
||||
self.initialTheme = APP().theme()
|
||||
else:
|
||||
self.initialTheme = None
|
||||
|
||||
@@ -148,7 +147,7 @@ class XrayAssetViewerQListWidget(Mixins.ThemeAware, AppQListWidget):
|
||||
# Ubuntu 20.04. Flush by initial theme(Ubuntu 20.04 theme changes bug)
|
||||
self.flushItemByTheme(self.initialTheme)
|
||||
else:
|
||||
self.flushItemByTheme(darkdetect.theme())
|
||||
self.flushItemByTheme(APP().theme())
|
||||
|
||||
def appendNewItem(self, filename: str):
|
||||
def append(_filename):
|
||||
|
||||
Reference in New Issue
Block a user