diff --git a/lintunes/__init__.py b/lintunes/__init__.py index 60e5cb7..e43a5f7 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.72.0" +__version__ = "0.72.1" diff --git a/lintunes/gui/preferences_dialog.py b/lintunes/gui/preferences_dialog.py index a1e0511..d7ab031 100644 --- a/lintunes/gui/preferences_dialog.py +++ b/lintunes/gui/preferences_dialog.py @@ -7,7 +7,7 @@ from PyQt6.QtWidgets import ( QFormLayout, QFontComboBox, QListWidget, QScrollArea, QSplitter, QStackedWidget, QWidget, QDialogButtonBox, QFrame, QToolButton, QColorDialog, QMenu, QDoubleSpinBox, QComboBox, QInputDialog, - QMessageBox, QApplication, + QMessageBox, QApplication, QSizePolicy, ) from PyQt6.QtCore import Qt, QTimer from PyQt6.QtGui import QDoubleValidator, QFont, QColor, QFontInfo @@ -125,8 +125,8 @@ class PreferencesDialog(QDialog): for title, groups in ( ("General", general), ("Appearance", [self._build_general_group(), - self._build_visualizer_group(), self._build_colors_group()]), + ("Visualizer", [self._build_visualizer_group()]), ("DJ", [self._build_dj_group()]), ("Integrations", [self._build_lastfm_group(), self._build_acoustid_group(), @@ -694,13 +694,14 @@ class PreferencesDialog(QDialog): self._viz_pages.addWidget(kaleido) self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(current)) + self._fit_viz_pages() column.addWidget(self._viz_pages) # For every style: this machine's speakers' latency (config.json). form = QFormLayout() self._sync_slider = self._sync_delay_slider(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) column.addWidget(note) return group @@ -947,8 +948,22 @@ class PreferencesDialog(QDialog): def _on_viz_style(self, key: str): self._viz_pages.setCurrentIndex(list(_VISUALIZER_STYLES).index(key)) + self._fit_viz_pages() 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: """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 diff --git a/tests/test_round102.py b/tests/test_round102.py index a09a92f..098e7e5 100644 --- a/tests/test_round102.py +++ b/tests/test_round102.py @@ -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 assert not action.isChecked() 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() diff --git a/tests/test_round70.py b/tests/test_round70.py index 5530d5a..f84d3ba 100644 --- a/tests/test_round70.py +++ b/tests/test_round70.py @@ -239,7 +239,8 @@ class TestPreferencesPages: dialog = PreferencesDialog(Preferences(tmp_path), _FakeLastFm()) names = [dialog.pages_list.item(i).text() 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) assert dialog.pages.currentIndex() == 2 PreferencesDialog._last_page = 0