diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 8f183030a..af9f36958 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -10,7 +10,6 @@ import aqt from anki.lang import _ from aqt import AnkiQt from aqt.qt import * -from aqt.theme import theme_manager from aqt.utils import TR, askUser, openHelp, showInfo, showWarning, tr @@ -250,11 +249,7 @@ Not currently enabled; click the sync button in the main window to enable.""" self.form.pasteInvert.setChecked(self.prof.get("pasteInvert", False)) self.form.showPlayButtons.setChecked(self.prof.get("showPlayButtons", True)) self.form.nightMode.setChecked(self.mw.pm.night_mode()) - if theme_manager.macos_dark_mode(): - self.form.nightMode.setChecked(True) - self.form.nightMode.setText(tr(TR.PREFERENCES_DARK_MODE_ACTIVE)) - else: - self.form.nightMode.setChecked(self.mw.pm.night_mode()) + self.form.nightMode.setChecked(self.mw.pm.night_mode()) self.form.interrupt_audio.setChecked(self.mw.pm.interrupt_audio()) def updateOptions(self): @@ -268,17 +263,9 @@ Not currently enabled; click the sync button in the main window to enable.""" restart_required = True self.prof["showPlayButtons"] = self.form.showPlayButtons.isChecked() - if theme_manager.macos_dark_mode(): - if not self.form.nightMode.isChecked(): - # user is trying to turn it off, but it's forced - showInfo( - tr(TR.PREFERENCES_DARK_MODE_DISABLE), textFormat="rich", - ) - openHelp("profileprefs") - else: - if self.mw.pm.night_mode() != self.form.nightMode.isChecked(): - self.mw.pm.set_night_mode(not self.mw.pm.night_mode()) - restart_required = True + if self.mw.pm.night_mode() != self.form.nightMode.isChecked(): + self.mw.pm.set_night_mode(not self.mw.pm.night_mode()) + restart_required = True self.mw.pm.set_interrupt_audio(self.form.interrupt_audio.isChecked()) diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index ccef2f1b5..5ca697625 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -496,6 +496,9 @@ create table if not exists profiles def set_night_mode(self, on: bool) -> None: self.meta["night_mode"] = on + def dark_mode_widgets(self) -> bool: + return self.meta.get("dark_mode_widgets", False) + # Profile-specific ###################################################################### diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index b77e248c6..19a2db660 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -3,13 +3,12 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import platform -import sys -from typing import Dict, Optional +from typing import Dict from anki.utils import isMac from aqt import QApplication, gui_hooks, isWin from aqt.colors import colors -from aqt.qt import QColor, QIcon, QPalette, QPixmap, QStyleFactory, Qt, qtminor +from aqt.qt import QColor, QIcon, QPalette, QPixmap, QStyleFactory, Qt class ThemeManager: @@ -17,25 +16,18 @@ class ThemeManager: _icon_cache_light: Dict[str, QIcon] = {} _icon_cache_dark: Dict[str, QIcon] = {} _icon_size = 128 - _macos_dark_mode_cached: Optional[bool] = None def macos_dark_mode(self) -> bool: - if not getattr(sys, "frozen", False): - return False + "True if the user has night mode on, and has forced native widgets." if not isMac: return False - if qtminor < 13: - return False - if self._macos_dark_mode_cached is None: - import darkdetect # pylint: disable=import-error - # cache the value, as the interface gets messed up - # if the value changes after starting Anki - self._macos_dark_mode_cached = darkdetect.isDark() is True - return self._macos_dark_mode_cached + from aqt import mw + + return self._night_mode_preference and mw.pm.dark_mode_widgets() def get_night_mode(self) -> bool: - return self.macos_dark_mode() or self._night_mode_preference + return self._night_mode_preference def set_night_mode(self, val: bool) -> None: self._night_mode_preference = val diff --git a/qt/setup.py b/qt/setup.py index 98d207714..456c9dcb1 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -30,7 +30,6 @@ install_requires = [ "pyqt5>=5.9", 'psutil; sys.platform == "win32"', 'pywin32; sys.platform == "win32"', - 'darkdetect; sys.platform == "darwin"', ]