From 15f1ed5c9692d3e833f1c0e8bf9bf1ec3f7d7558 Mon Sep 17 00:00:00 2001 From: trav Date: Fri, 6 Nov 2026 02:55:16 -0800 Subject: [PATCH] v0.90.1: the visualizer's sync delay is a box with 1 ms arrows instead of a slider --- lintunes/__init__.py | 2 +- lintunes/gui/preferences_dialog.py | 33 ++++++++++++++++-------------- tests/test_round125.py | 20 ++++++++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 tests/test_round125.py diff --git a/lintunes/__init__.py b/lintunes/__init__.py index 38526d9..635bf57 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.90.0" +__version__ = "0.90.1" diff --git a/lintunes/gui/preferences_dialog.py b/lintunes/gui/preferences_dialog.py index b80522f..c06a49b 100644 --- a/lintunes/gui/preferences_dialog.py +++ b/lintunes/gui/preferences_dialog.py @@ -1081,37 +1081,40 @@ class PreferencesDialog(QDialog): form.addRow("Frequency range:", row) return slider - def _sync_delay_slider(self, form, style: str) -> QSlider: + def _sync_delay_slider(self, form, style: str) -> "QSpinBox": """This style's sync delay — this machine's speakers' latency plus - the style's own lag, so one per style, in config.json.""" + the style's own lag, so one per style, in config.json. A box with + 1 ms arrows (Round 125): a slider was too fidgety to set it by.""" + from PyQt6.QtWidgets import QSpinBox lo, hi = visualizer_styles.SYNC_DELAY_LIMITS - slider = _viz_slider_widget() - slider.setRange(lo, hi) - slider.setSingleStep(5) - slider.setPageStep(25) - slider.setToolTip( + box = QSpinBox() + box.setRange(lo, hi) + box.setSingleStep(1) + box.setSuffix(" ms") + box.setKeyboardTracking(False) # typing saves on Enter/leaving + box.setToolTip( "If the visualizer runs ahead of what you hear — Bluetooth " "headphones especially — hold it back this much. Below zero it " "reacts sooner, by up to as much audio as the player has decoded " "ahead (usually a few tens of ms). Set per computer and per " "style, since each style lags in its own way.") - slider.setValue(visualizer_styles.sync_delay_ms(load_config(), style)) - text = QLabel(_sync_text(slider.value())) - text.setMinimumWidth(max(_VALUE_WIDTH, text.fontMetrics().horizontalAdvance( - _sync_text(visualizer_styles.SYNC_DELAY_LIMITS[0])) + 4)) + box.setValue(visualizer_styles.sync_delay_ms(load_config(), style)) + text = QLabel(_sync_text(box.value())) + text.setEnabled(False) def changed(value): text.setText(_sync_text(value)) self._sync_save_timer.start() - slider.valueChanged.connect(changed) - self._sync_sliders[style] = slider + box.valueChanged.connect(changed) + self._sync_sliders[style] = box row = QHBoxLayout() - row.addWidget(slider, stretch=1) + row.addWidget(box) row.addSpacing(8) row.addWidget(text) + row.addStretch(1) form.addRow("Sync delay:", row) - return slider + return box def _save_sync_delay(self): config = load_config() diff --git a/tests/test_round125.py b/tests/test_round125.py new file mode 100644 index 0000000..2e4b461 --- /dev/null +++ b/tests/test_round125.py @@ -0,0 +1,20 @@ +"""Round 125: the visualizer's sync delay is a box with 1 ms arrows, not a +slider (too fidgety to set to the millisecond).""" +from PyQt6.QtWidgets import QSpinBox + +from lintunes.gui import visualizer_styles as vs +from lintunes.preferences import Preferences +from test_round108 import _dialog + + +def test_every_styles_sync_delay_is_a_1_ms_spin_box(qapp, tmp_path, monkeypatch): + monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "cfg")) + dialog = _dialog(Preferences(tmp_path)) + assert set(dialog._sync_sliders) == set(vs.STYLES) + for box in dialog._sync_sliders.values(): + assert isinstance(box, QSpinBox) + assert box.singleStep() == 1 + assert (box.minimum(), box.maximum()) == vs.SYNC_DELAY_LIMITS + before = box.value() + box.stepBy(1) + assert box.value() == before + 1