Add issue 223 debugging and quicklog function

This commit is contained in:
Keith Edmunds 2024-07-06 14:26:29 +01:00
parent dc3b46d2d6
commit 87d2d7adae
2 changed files with 47 additions and 14 deletions

View File

@ -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(

View File

@ -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