v0.72.1: the visualizer gets its own Preferences page, sized to the style shown
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.72.0"
|
__version__ = "0.72.1"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from PyQt6.QtWidgets import (
|
|||||||
QFormLayout, QFontComboBox, QListWidget, QScrollArea, QSplitter,
|
QFormLayout, QFontComboBox, QListWidget, QScrollArea, QSplitter,
|
||||||
QStackedWidget, QWidget, QDialogButtonBox, QFrame, QToolButton,
|
QStackedWidget, QWidget, QDialogButtonBox, QFrame, QToolButton,
|
||||||
QColorDialog, QMenu, QDoubleSpinBox, QComboBox, QInputDialog,
|
QColorDialog, QMenu, QDoubleSpinBox, QComboBox, QInputDialog,
|
||||||
QMessageBox, QApplication,
|
QMessageBox, QApplication, QSizePolicy,
|
||||||
)
|
)
|
||||||
from PyQt6.QtCore import Qt, QTimer
|
from PyQt6.QtCore import Qt, QTimer
|
||||||
from PyQt6.QtGui import QDoubleValidator, QFont, QColor, QFontInfo
|
from PyQt6.QtGui import QDoubleValidator, QFont, QColor, QFontInfo
|
||||||
@@ -125,8 +125,8 @@ class PreferencesDialog(QDialog):
|
|||||||
for title, groups in (
|
for title, groups in (
|
||||||
("General", general),
|
("General", general),
|
||||||
("Appearance", [self._build_general_group(),
|
("Appearance", [self._build_general_group(),
|
||||||
self._build_visualizer_group(),
|
|
||||||
self._build_colors_group()]),
|
self._build_colors_group()]),
|
||||||
|
("Visualizer", [self._build_visualizer_group()]),
|
||||||
("DJ", [self._build_dj_group()]),
|
("DJ", [self._build_dj_group()]),
|
||||||
("Integrations", [self._build_lastfm_group(),
|
("Integrations", [self._build_lastfm_group(),
|
||||||
self._build_acoustid_group(),
|
self._build_acoustid_group(),
|
||||||
@@ -694,13 +694,14 @@ class PreferencesDialog(QDialog):
|
|||||||
self._viz_pages.addWidget(kaleido)
|
self._viz_pages.addWidget(kaleido)
|
||||||
|
|
||||||
self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(current))
|
self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(current))
|
||||||
|
self._fit_viz_pages()
|
||||||
column.addWidget(self._viz_pages)
|
column.addWidget(self._viz_pages)
|
||||||
|
|
||||||
# For every style: this machine's speakers' latency (config.json).
|
# For every style: this machine's speakers' latency (config.json).
|
||||||
form = QFormLayout()
|
form = QFormLayout()
|
||||||
self._sync_slider = self._sync_delay_slider(form)
|
self._sync_slider = self._sync_delay_slider(form)
|
||||||
column.addLayout(form)
|
column.addLayout(form)
|
||||||
note = QLabel("Double-click the visualizer to see it big.")
|
note = QLabel("Click the visualizer to see it big.")
|
||||||
note.setEnabled(False)
|
note.setEnabled(False)
|
||||||
column.addWidget(note)
|
column.addWidget(note)
|
||||||
return group
|
return group
|
||||||
@@ -947,8 +948,22 @@ class PreferencesDialog(QDialog):
|
|||||||
|
|
||||||
def _on_viz_style(self, key: str):
|
def _on_viz_style(self, key: str):
|
||||||
self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(key))
|
self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(key))
|
||||||
|
self._fit_viz_pages()
|
||||||
self._prefs.set("visualizer_style", key)
|
self._prefs.set("visualizer_style", key)
|
||||||
|
|
||||||
|
def _fit_viz_pages(self):
|
||||||
|
"""A stack is as tall as its tallest page (the laser's), which left
|
||||||
|
the other styles over a block of empty space; only the shown page
|
||||||
|
counts toward its size."""
|
||||||
|
stack = self._viz_pages
|
||||||
|
for i in range(stack.count()):
|
||||||
|
page = stack.widget(i)
|
||||||
|
policy = (QSizePolicy.Policy.Preferred if i == stack.currentIndex()
|
||||||
|
else QSizePolicy.Policy.Ignored)
|
||||||
|
page.setSizePolicy(policy, policy)
|
||||||
|
stack.currentWidget().adjustSize()
|
||||||
|
stack.updateGeometry()
|
||||||
|
|
||||||
def _build_colors_group(self) -> QGroupBox:
|
def _build_colors_group(self) -> QGroupBox:
|
||||||
"""Light and dark each have a tint and a full set of grays; the
|
"""Light and dark each have a tint and a full set of grays; the
|
||||||
Light | Dark switch picks which set the controls show and edit, and
|
Light | Dark switch picks which set the controls show and edit, and
|
||||||
|
|||||||
@@ -103,3 +103,21 @@ def test_view_menu_dark_mode_toggles_and_follows(qapp, tmp_path):
|
|||||||
window._prefs.set("dark_mode", False) # e.g. the toolbar button
|
window._prefs.set("dark_mode", False) # e.g. the toolbar button
|
||||||
assert not action.isChecked()
|
assert not action.isChecked()
|
||||||
theme.apply_theme(qapp, Preferences(tmp_path / "light"))
|
theme.apply_theme(qapp, Preferences(tmp_path / "light"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_visualizer_has_its_own_page_sized_to_the_style_shown(qapp, tmp_path):
|
||||||
|
from lintunes.gui.preferences_dialog import PreferencesDialog
|
||||||
|
from lintunes.preferences import Preferences
|
||||||
|
from tests.test_round40 import _FakeLastFm
|
||||||
|
PreferencesDialog._last_page = 0
|
||||||
|
dialog = PreferencesDialog(Preferences(tmp_path), _FakeLastFm())
|
||||||
|
names = [dialog.pages_list.item(i).text() for i in range(dialog.pages_list.count())]
|
||||||
|
assert names.index("Visualizer") == names.index("Appearance") + 1
|
||||||
|
stack = dialog._viz_pages
|
||||||
|
dialog._viz_radios["laser"].setChecked(True)
|
||||||
|
laser = stack.sizeHint().height()
|
||||||
|
dialog._viz_radios["radial"].setChecked(True)
|
||||||
|
radial = stack.sizeHint().height()
|
||||||
|
assert radial < laser - 100 # no laser-sized gap under radial
|
||||||
|
assert abs(radial - stack.currentWidget().sizeHint().height()) <= 2
|
||||||
|
dialog.deleteLater()
|
||||||
|
|||||||
@@ -239,7 +239,8 @@ class TestPreferencesPages:
|
|||||||
dialog = PreferencesDialog(Preferences(tmp_path), _FakeLastFm())
|
dialog = PreferencesDialog(Preferences(tmp_path), _FakeLastFm())
|
||||||
names = [dialog.pages_list.item(i).text()
|
names = [dialog.pages_list.item(i).text()
|
||||||
for i in range(dialog.pages_list.count())]
|
for i in range(dialog.pages_list.count())]
|
||||||
assert names == ["General", "Appearance", "DJ", "Integrations"] # DJ: Round 94
|
assert names == ["General", "Appearance", "Visualizer", "DJ",
|
||||||
|
"Integrations"] # DJ: Round 94, Visualizer: 102
|
||||||
dialog.pages_list.setCurrentRow(2)
|
dialog.pages_list.setCurrentRow(2)
|
||||||
assert dialog.pages.currentIndex() == 2
|
assert dialog.pages.currentIndex() == 2
|
||||||
PreferencesDialog._last_page = 0
|
PreferencesDialog._last_page = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user