From 87d2d7adae683cd762f7bf306fd6144f774928b7 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 6 Jul 2024 14:26:29 +0100 Subject: [PATCH] Add issue 223 debugging and quicklog function --- app/musicmuster.py | 58 ++++++++++++++++++++++++++++++++++----------- app/trackmanager.py | 3 +++ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/app/musicmuster.py b/app/musicmuster.py index d0f7c7c..4b9a5ae 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -23,7 +23,9 @@ from PyQt6.QtCore import ( from PyQt6.QtGui import ( QCloseEvent, QColor, + QKeySequence, QPalette, + QShortcut, ) from PyQt6.QtWidgets import ( QApplication, @@ -297,6 +299,10 @@ class Window(QMainWindow, Ui_MainWindow): self.catch_return_key = False self.load_last_playlists() + # Set up shortcut key for instant logging from keyboard + self.action_quicklog = QShortcut(QKeySequence("Ctrl+L"), self) + self.action_quicklog.activated.connect(self.quicklog) + def about(self) -> None: """Get git tag and database name""" @@ -1052,6 +1058,7 @@ class Window(QMainWindow, Ui_MainWindow): Actions required: - If there is no next track set, return. + - Check for inadvertent press of return - If there's currently a track playing, fade it. - Move next track to current track. - Clear next track @@ -1064,6 +1071,13 @@ class Window(QMainWindow, Ui_MainWindow): - Update headers """ + log.debug(f"issue223: play_next({position=})") + + # If there is no next track set, return. + if track_sequence.next is None: + log.error("musicmuster.play_next(): no next track selected") + return + # Check for inadvertent press of 'return' if track_sequence.current and self.catch_return_key: # Suppress inadvertent double press @@ -1083,21 +1097,18 @@ class Window(QMainWindow, Ui_MainWindow): * 1000 > Config.PLAY_NEXT_GUARD_MS ) + if default_yes: + msg = "Hit return to play next track now" + else: + msg = "Press tab to select Yes and hit return to play next track" if not helpers.ask_yes_no( - "Track playing", - "Really play next track now?", + "Play next track", + msg, default_yes=default_yes, parent=self, ): return - log.debug(f"play_next({position=})") - - # If there is no next track set, return. - if track_sequence.next is None: - log.error("musicmuster.play_next(): no next track selected") - return - # Issue #223 concerns a very short pause (maybe 0.1s) sometimes # when starting to play at track. @@ -1105,7 +1116,7 @@ class Window(QMainWindow, Ui_MainWindow): # seconds of playback. Re-enable in update_clocks. self.timer10.stop() - log.debug("10ms timer disabled") + log.debug("issue223: play_next: 10ms timer disabled") # If there's currently a track playing, fade it. if track_sequence.current: @@ -1121,32 +1132,35 @@ class Window(QMainWindow, Ui_MainWindow): # Restore volume if -3dB active if self.btnDrop3db.isChecked(): - log.debug("Reset -3db button") + log.debug("issue223: play_next: Reset -3db button") self.btnDrop3db.setChecked(False) # Play (new) current track track_sequence.current.play(position) # Update clocks now, don't wait for next tick + log.debug("issue223: play_next: update_clocks()") self.update_clocks() # Show closing volume graph if track_sequence.current.fade_graph: + log.error("issue223: play_next: set up fade_graph") track_sequence.current.fade_graph.GraphWidget = self.widgetFadeVolume track_sequence.current.fade_graph.clear() track_sequence.current.fade_graph.plot() else: - log.error("No fade_graph") + log.error("issue223: play_next: No fade_graph") # Disable play next controls self.catch_return_key = True self.show_status_message("Play controls: Disabled", 0) # Notify model + log.debug("issue223: play_next: notify model") self.active_proxy_model().current_track_started() # Update headers - log.debug("update headers") + log.debug("issue223: play_next: update headers") self.update_headers() with db.Session() as session: last_played = Playdates.last_played_tracks(session) @@ -1227,6 +1241,22 @@ class Window(QMainWindow, Ui_MainWindow): self.preview_manager.restart() + def quicklog(self) -> None: + """ + Create log entry + """ + + log.debug("quicklog") + + # Get log text + dlg: QInputDialog = QInputDialog(self) + dlg.setInputMode(QInputDialog.InputMode.TextInput) + dlg.setLabelText("Log text:") + dlg.resize(500, 100) + ok = dlg.exec() + if ok: + log.debug("quicklog: " + dlg.textValue()) + def rename_playlist(self) -> None: """ Rename current playlist @@ -1625,7 +1655,7 @@ class Window(QMainWindow, Ui_MainWindow): and not self.timer10.isActive() ): self.timer10.start(10) - log.debug("10ms timer enabled") + log.debug("issue223: update_clocks: 10ms timer enabled") # Elapsed time self.label_elapsed_timer.setText( diff --git a/app/trackmanager.py b/app/trackmanager.py index 9577589..cbf7cc9 100644 --- a/app/trackmanager.py +++ b/app/trackmanager.py @@ -119,10 +119,12 @@ class _FadeCurve: if self.region is None: # Create the region now that we're into fade + log.debug("issue223: _FadeCurve: create region") self.region = pg.LinearRegionItem([0, 0], bounds=[0, len(self.graph_array)]) self.GraphWidget.addItem(self.region) # Update region position + log.debug("issue223: _FadeCurve: update region") self.region.setRegion([0, ms_of_graph * self.ms_to_array_factor]) @@ -499,6 +501,7 @@ class _TrackManager: def play(self, position: Optional[float] = None) -> None: """Play track""" + log.debug(f"issue223: _TrackManager: play {self.track_id=}") now = dt.datetime.now() self.start_time = now