v0.72.0: View › Dark Mode (Ctrl+Shift+D)
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||||
|
|
||||||
__version__ = "0.71.0"
|
__version__ = "0.72.0"
|
||||||
|
|||||||
@@ -414,6 +414,11 @@ class MainWindow(QMainWindow):
|
|||||||
self._transport.refresh_theme()
|
self._transport.refresh_theme()
|
||||||
self._version_button.refresh_theme()
|
self._version_button.refresh_theme()
|
||||||
self._sidebar.refresh_style()
|
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):
|
def _mount_view_header(self, _index=None):
|
||||||
view = self._content.currentWidget()
|
view = self._content.currentWidget()
|
||||||
@@ -493,6 +498,15 @@ class MainWindow(QMainWindow):
|
|||||||
view_menu = bar.addMenu("&View")
|
view_menu = bar.addMenu("&View")
|
||||||
self._add_action(view_menu, "Toggle Column Browser", "Ctrl+B",
|
self._add_action(view_menu, "Toggle Column Browser", "Ctrl+B",
|
||||||
self._library_view.toggle_browser)
|
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()
|
view_menu.addSeparator()
|
||||||
self._dj_action = QAction("DJ Mode", self)
|
self._dj_action = QAction("DJ Mode", self)
|
||||||
self._dj_action.setCheckable(True)
|
self._dj_action.setCheckable(True)
|
||||||
|
|||||||
@@ -89,3 +89,17 @@ def test_the_x_shows_while_splitting_and_the_slider_retries(shelf, monkeypatch):
|
|||||||
assert not x.isHidden()
|
assert not x.isHidden()
|
||||||
slider.sliderPressed.emit() # already splitting: no second ask
|
slider.sliderPressed.emit() # already splitting: no second ask
|
||||||
assert asked == ["/x.mp3", "/x.mp3"]
|
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"))
|
||||||
|
|||||||
Reference in New Issue
Block a user