From 2c379c4229b3b0f73936304e6cae580182714433 Mon Sep 17 00:00:00 2001 From: trav Date: Mon, 19 Oct 2026 23:07:20 -0700 Subject: [PATCH] =?UTF-8?q?v0.72.0:=20View=20=E2=80=BA=20Dark=20Mode=20(Ct?= =?UTF-8?q?rl+Shift+D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lintunes/__init__.py | 2 +- lintunes/gui/main_window.py | 14 ++++++++++++++ tests/test_round102.py | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lintunes/__init__.py b/lintunes/__init__.py index d84e277..60e5cb7 100644 --- a/lintunes/__init__.py +++ b/lintunes/__init__.py @@ -1,3 +1,3 @@ """LinTunes — iTunes-style music library manager and player for Linux.""" -__version__ = "0.71.0" +__version__ = "0.72.0" diff --git a/lintunes/gui/main_window.py b/lintunes/gui/main_window.py index e73b223..cb7a5ee 100644 --- a/lintunes/gui/main_window.py +++ b/lintunes/gui/main_window.py @@ -414,6 +414,11 @@ class MainWindow(QMainWindow): self._transport.refresh_theme() self._version_button.refresh_theme() self._sidebar.refresh_style() + dark = getattr(self, "_dark_action", None) + if dark is not None and dark.isChecked() != (theme.mode(self._prefs) == "dark"): + dark.blockSignals(True) + dark.setChecked(theme.mode(self._prefs) == "dark") + dark.blockSignals(False) def _mount_view_header(self, _index=None): view = self._content.currentWidget() @@ -493,6 +498,15 @@ class MainWindow(QMainWindow): view_menu = bar.addMenu("&View") self._add_action(view_menu, "Toggle Column Browser", "Ctrl+B", self._library_view.toggle_browser) + # No platform convention for this; Ctrl+Shift+D leaves plain Ctrl+D + # (bookmark/duplicate/delete elsewhere) free, and is easy to hit. + self._dark_action = QAction("Dark Mode", self) + self._dark_action.setCheckable(True) + self._dark_action.setShortcut(QKeySequence("Ctrl+Shift+D")) + self._dark_action.setChecked(theme.mode(self._prefs) == "dark") + self._dark_action.toggled.connect( + lambda on: self._prefs.set("dark_mode", on)) + view_menu.addAction(self._dark_action) view_menu.addSeparator() self._dj_action = QAction("DJ Mode", self) self._dj_action.setCheckable(True) diff --git a/tests/test_round102.py b/tests/test_round102.py index 1553e63..a09a92f 100644 --- a/tests/test_round102.py +++ b/tests/test_round102.py @@ -89,3 +89,17 @@ def test_the_x_shows_while_splitting_and_the_slider_retries(shelf, monkeypatch): assert not x.isHidden() slider.sliderPressed.emit() # already splitting: no second ask assert asked == ["/x.mp3", "/x.mp3"] + + +def test_view_menu_dark_mode_toggles_and_follows(qapp, tmp_path): + from tests.test_round69 import _window + from lintunes import theme + from lintunes.preferences import Preferences + window = _window(qapp, tmp_path) + action = window._dark_action + assert action.shortcut().toString() == "Ctrl+Shift+D" + action.trigger() + assert window._prefs.get("dark_mode") is True + window._prefs.set("dark_mode", False) # e.g. the toolbar button + assert not action.isChecked() + theme.apply_theme(qapp, Preferences(tmp_path / "light"))