Use dialog box to check for unintended play next track

This commit is contained in:
Keith Edmunds 2024-03-25 17:48:56 +00:00
parent 38bb5dc7cd
commit 851e52c3e1
3 changed files with 17 additions and 44 deletions

View File

@ -238,13 +238,13 @@ class Window(QMainWindow, Ui_MainWindow):
else:
self.carts_init()
self.disable_selection_timing = False
self.enable_play_next_controls()
self.clock_counter = 0
self.timer10.start(10)
self.timer500.start(500)
self.timer1000.start(1000)
self.signals = MusicMusterSignals()
self.connect_signals_slots()
self.catch_return_key = False
self.load_last_playlists()
def about(self) -> None:
@ -517,7 +517,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.actionDownload_CSV_of_played_tracks.triggered.connect(
self.download_played_tracks
)
self.actionEnable_controls.triggered.connect(self.enable_play_next_controls)
self.actionExport_playlist.triggered.connect(self.export_playlist_tab)
self.actionFade.triggered.connect(self.fade)
self.actionImport.triggered.connect(self.import_track)
@ -652,14 +651,6 @@ class Window(QMainWindow, Ui_MainWindow):
else:
log.error("Failed to retrieve playlist")
def disable_play_next_controls(self) -> None:
"""
Disable "play next" keyboard controls
"""
self.actionPlay_next.setEnabled(False)
self.show_status_message("Play controls: Disabled", 0)
def download_played_tracks(self) -> None:
"""Download a CSV of played tracks"""
@ -705,14 +696,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.action_Clear_selection.setEnabled(enabled)
def enable_play_next_controls(self) -> None:
"""
Enable "play next" keyboard controls
"""
self.actionPlay_next.setEnabled(True)
self.show_status_message("Play controls: Enabled", 0)
def export_playlist_tab(self) -> None:
"""Export the current playlist to an m3u file"""
@ -1106,6 +1089,16 @@ class Window(QMainWindow, Ui_MainWindow):
- Update headers
"""
# Check for inadvertent press of 'return'
if self.catch_return_key:
if not helpers.ask_yes_no(
"Track playing",
"Really play next track now?",
default_yes=True,
parent=self,
):
return
log.info(f"play_next({position=})")
# If there is no next track set, return.
@ -1148,7 +1141,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.playing = True
# Disable play next controls
self.disable_play_next_controls()
self.catch_return_key = True
# Notify model
self.active_proxy_model().current_track_started()
@ -1170,22 +1163,6 @@ class Window(QMainWindow, Ui_MainWindow):
break
sleep(0.1)
# Try making playing the last thing we do here to see whether
# the occasional short pause at the start of the track can be
# eliminated.
# # Notify model
# self.active_proxy_model().current_track_started()
# # Note that track is now playing
# self.playing = True
# # Disable play next controls
# self.disable_play_next_controls()
# # Update headers
# self.update_headers()
def preview(self) -> None:
"""
Preview selected or next track. We use a different mechanism to
@ -1291,7 +1268,7 @@ class Window(QMainWindow, Ui_MainWindow):
# Disable play controls so that 'return' in search box doesn't
# play next track
self.disable_play_next_controls()
self.catch_return_key = True
self.txtSearch.setHidden(False)
self.txtSearch.setFocus()
# Select any text that may already be there
@ -1498,7 +1475,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.update_headers()
# Enable controls
self.enable_play_next_controls()
self.catch_return_key = False
def tab_change(self):
"""Called when active tab changed"""
@ -1578,7 +1555,7 @@ class Window(QMainWindow, Ui_MainWindow):
css_silence = f"background: {Config.COLOUR_ENDING_TIMER}"
if self.frame_silent.styleSheet() != css_silence:
self.frame_silent.setStyleSheet(css_silence)
self.enable_play_next_controls()
self.catch_return_key = False
# Set warning colour on time to silence box when fade starts
elif time_to_fade <= 500:
css_fade = f"background: {Config.COLOUR_WARNING_TIMER}"
@ -1590,7 +1567,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.frame_fade.setStyleSheet(
f"background: {Config.COLOUR_WARNING_TIMER}"
)
self.enable_play_next_controls()
self.catch_return_key = False
else:
self.frame_silent.setStyleSheet("")
self.frame_fade.setStyleSheet("")

View File

@ -775,8 +775,6 @@ padding-left: 8px;</string>
<addaction name="actionSetNext"/>
<addaction name="action_Clear_selection"/>
<addaction name="separator"/>
<addaction name="actionEnable_controls"/>
<addaction name="separator"/>
<addaction name="actionMark_for_moving"/>
<addaction name="actionPaste"/>
</widget>

View File

@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'app/ui/main_window.ui'
#
# Created by: PyQt6 UI code generator 6.6.0
# Created by: PyQt6 UI code generator 6.6.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
@ -487,8 +487,6 @@ class Ui_MainWindow(object):
self.menuPlaylist.addAction(self.actionSetNext)
self.menuPlaylist.addAction(self.action_Clear_selection)
self.menuPlaylist.addSeparator()
self.menuPlaylist.addAction(self.actionEnable_controls)
self.menuPlaylist.addSeparator()
self.menuPlaylist.addAction(self.actionMark_for_moving)
self.menuPlaylist.addAction(self.actionPaste)
self.menuSearc_h.addAction(self.actionSearch)