From 8298450814f2b90522c6af93a2cc2554f064e773 Mon Sep 17 00:00:00 2001 From: trav Date: Sat, 17 Oct 2026 02:19:02 -0700 Subject: [PATCH] v0.63.1: nothing starts the main player in DJ mode; sync always clickable Return or a double-click on a song started the regular player behind the decks, with its controls greyed out and no way to stop it. DJ mode now suspends the player. Sync to other track was only re-enabled when its own deck changed, so loading the other deck afterwards left it grey; it's now enabled whenever its deck has a song and explains what it can't do. --- CLAUDE.md | 6 ++++- lintunes/__init__.py | 2 +- lintunes/gui/dj_shelf.py | 25 +++++++++++++------ lintunes/gui/main_window.py | 4 ++-- lintunes/player.py | 18 +++++++++++++- tests/test_round93.py | 48 +++++++++++++++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 12 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 58ed34f..0b7ab8e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -353,7 +353,11 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal record darkens and gets the deck's rim; replacing a deck that's playing above 50 % gain asks first), and a song that ends just stops — no queue, so the main transport, seek bar, space and arrows are greyed/ignored, and - the main player pauses when DJ mode opens. Deck A is blue and Deck B + the main player is **suspended** while DJ mode is open + (`Player.set_suspended`: paused, and nothing — double-click, Return, a + media key — can start it; it played behind the decks, unstoppable, in + v0.63.0). "Sync to other track" is enabled whenever its own deck has a + song; what it can't do yet it says in the status bar. Deck A is blue and Deck B orange, every control included; loaded songs get a DECK A/B tag in every track list (`track_table.deck_tag`). **Its own engine**, because Qt's player can't change tempo without pitch or play backwards: `dj/loader.py` diff --git a/lintunes/__init__.py b/lintunes/__init__.py index 12df565..ce75f2a 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.63.0" +__version__ = "0.63.1" diff --git a/lintunes/gui/dj_shelf.py b/lintunes/gui/dj_shelf.py index 32f8679..595d048 100644 --- a/lintunes/gui/dj_shelf.py +++ b/lintunes/gui/dj_shelf.py @@ -513,8 +513,10 @@ class DjShelf(QWidget): slider.setToolTip(f"Deck {v.name} speed (double-click: back to 0)") slider.valueChanged.connect(lambda value, v=v: self._on_speed(v, value)) slider.mouseDoubleClickEvent = lambda e, s=slider: s.setValue(0) - label = QLabel("0.0%") - label.setStyleSheet(f"color: {v.color.name()};") + label = QLabel("+0.0%") + label.setStyleSheet(f"color: {v.color.name()}; font-size: 11px;") + label.setAlignment(Qt.AlignmentFlag.AlignCenter) + label.setMinimumWidth(60) for w in (top, bottom): w.setStyleSheet(f"color: {DIM}; font-size: 10px;") for w in (top, slider, bottom, label): @@ -522,7 +524,7 @@ class DjShelf(QWidget): col.setStretch(1, 1) holder = QWidget() holder.setLayout(col) - holder.setFixedWidth(58) + holder.setFixedWidth(64) self.speed[v.name] = slider self.speed_label[v.name] = label self._compact_hidden.append(holder) @@ -555,6 +557,7 @@ class DjShelf(QWidget): sync.clicked.connect(lambda _=False, v=v: self.sync(v)) for w in (play, sync): w.setStyleSheet(_deck_button_qss(v.name)) + w.setFocusPolicy(Qt.FocusPolicy.NoFocus) # Space/Return mean nothing here buttons.addWidget(play) buttons.addWidget(sync, stretch=1) self.play_buttons[v.name] = play @@ -616,6 +619,7 @@ class DjShelf(QWidget): line.addLayout(nums) pitch = QCheckBox("Keep pitch") pitch.setChecked(True) + pitch.setFocusPolicy(Qt.FocusPolicy.NoFocus) pitch.setStyleSheet(_deck_button_qss(v.name)) pitch.setToolTip("On: a faster song stays in its key. Off: pitch " "follows speed, like a turntable") @@ -857,11 +861,16 @@ class DjShelf(QWidget): def sync(self, view: DeckView): """Tempo to the other deck's; while both play, the beats too.""" other = self.other(view) - if view.deck.source is None or other.deck.source is None: - self.message.emit("Sync needs a song on both decks.") + if view.deck.source is None: + return + if other.deck.source is None: + self.message.emit(f"Load a song on Deck {other.name} to sync to it." + if other.track is None else + f"Deck {other.name} is still loading.") return if not view.bpm or not other.bpm: - self.message.emit("Sync needs both songs' tempo, and one has no beat to find.") + missing = view if not view.bpm else other + self.message.emit(f"Can't sync: no beat was found in “{missing.track.name}”.") return target = other.bpm * other.deck.speed view.deck.speed = analysis.sync_ratio(view.bpm, target) @@ -928,7 +937,9 @@ class DjShelf(QWidget): self.play_buttons[view.name].setIcon(QIcon(_play_icon(deck.playing))) loaded = deck.source is not None self.play_buttons[view.name].setEnabled(loaded) - self.sync_buttons[view.name].setEnabled(loaded and self.other(view).deck.source is not None) + # Always clickable once this deck has a song: whatever sync can't do + # yet (an empty other deck, a tempo still being worked out) it says. + self.sync_buttons[view.name].setEnabled(loaded) self._refresh_note(view) def _tick(self): diff --git a/lintunes/gui/main_window.py b/lintunes/gui/main_window.py index cbe16ea..21a69e9 100644 --- a/lintunes/gui/main_window.py +++ b/lintunes/gui/main_window.py @@ -2315,8 +2315,7 @@ class MainWindow(QMainWindow): from lintunes.gui import track_table if on: shelf = self._ensure_dj() - if self.player.is_playing(): - self.player.pause() + self.player.set_suspended(True) # pauses it, and keeps it so target = self._dj_target_height() self._transport.set_dj_mode(True, self._dj_titles()) track_table.deck_tag = self._deck_tag @@ -2397,6 +2396,7 @@ class MainWindow(QMainWindow): return # reopened mid-close self._dj.stop() self._dj.hide() + self.player.set_suspended(False) self._transport.set_dj_mode(False) def _on_dj_resize(self, dy: int): diff --git a/lintunes/player.py b/lintunes/player.py index a36bb17..efa8bac 100644 --- a/lintunes/player.py +++ b/lintunes/player.py @@ -586,7 +586,19 @@ class Player(QObject): # ---- queue ---- + # DJ mode (Round 93) has its own decks; while it's open nothing may + # start this player — a double-click, Return or a media key would play + # behind the decks with the main transport greyed out, unstoppable. + suspended = False + + def set_suspended(self, on: bool): + self.suspended = bool(on) + if on: + self.pause() + def play_queue(self, track_ids: list[int], start_index: int): + if self.suspended: + return self._queue = list(track_ids) self._index = start_index self._reshuffle() @@ -801,6 +813,8 @@ class Player(QObject): # ---- transport ---- def toggle_play(self): + if self.suspended and not self.is_playing(): + return log_control("player", "toggle_play", f"playing={self.is_playing()} pos={self.position_ms()}ms " f"track={self._current_track.name if self._current_track else None!r}") @@ -833,12 +847,14 @@ class Player(QObject): self.track_changed.emit(None) def next(self): + if self.suspended: + return # When paused/stopped, skipping only cues the new track; audio # starts only if we were already playing. self._advance(autoplay=self.is_playing()) def previous(self): - if not self._queue: + if not self._queue or self.suspended: return prev_index = self._step_index(-1) if self.position_ms() > RESTART_THRESHOLD_MS or prev_index is None: diff --git a/tests/test_round93.py b/tests/test_round93.py index 7d911ef..2488b73 100644 --- a/tests/test_round93.py +++ b/tests/test_round93.py @@ -295,3 +295,51 @@ def test_dj_mode_greys_the_transport_and_ignores_space(qapp, tmp_path, monkeypat assert track_table.deck_tag is None finally: window.close() + + +# ---- Round 93 fixes: nothing starts the main player; sync always clickable ---- + +def test_a_suspended_player_cannot_be_started(qapp, tmp_path): + from tests.test_round29 import _FakeSink, _local_track, _player + tracks = [_local_track(tmp_path, i) for i in range(1, 4)] + player = _player(qapp, tracks) + sink = _FakeSink() + player.set_sink(sink) + player.set_suspended(True) + player.play_queue([1, 2, 3], 0) + player.toggle_play() + player.next() + assert player.current_track is None and not sink.loads + player.set_suspended(False) + player.play_queue([1, 2, 3], 0) + assert player.current_track.track_id == 1 + + +def test_return_on_a_song_does_nothing_in_dj_mode(qapp, tmp_path, monkeypatch): + from lintunes.gui.main_window import MainWindow + from lintunes.library_manager import LibraryManager + from lintunes.models.library import Library + from lintunes.preferences import Preferences + monkeypatch.setattr("lintunes.gui.main_window.load_config", lambda: {}) + monkeypatch.setattr("lintunes.gui.main_window.save_config", lambda c: None) + window = MainWindow(LibraryManager(Library(), tmp_path), Preferences(tmp_path)) + try: + window.set_dj_mode(True) + assert window.player.suspended + window.set_dj_mode(False) + window._dj_anim.stop() + window._dj_closed() + assert not window.player.suspended + finally: + window.close() + + +def test_sync_is_clickable_with_one_deck_and_says_why(shelf): + a, _ = shelf.views + _loaded(shelf, a, shelf.tracks[0], _clicks(124, 0.1, 5), 124.0, 0.1) + assert shelf.sync_buttons["A"].isEnabled() + said = [] + shelf.message.connect(said.append) + shelf.sync(a) + assert said and "Deck B" in said[0] + assert a.deck.speed == 1.0