Simply musicmuster:play_next
Split out return_pressed_in_error()
This commit is contained in:
parent
434e45b080
commit
96080cdca0
@ -1123,35 +1123,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
|
||||
# Check for inadvertent press of 'return'
|
||||
if track_sequence.current and self.catch_return_key:
|
||||
# Suppress inadvertent double press
|
||||
if (
|
||||
track_sequence.current
|
||||
and track_sequence.current.start_time
|
||||
and track_sequence.current.start_time
|
||||
+ dt.timedelta(milliseconds=Config.RETURN_KEY_DEBOUNCE_MS)
|
||||
> dt.datetime.now()
|
||||
):
|
||||
return
|
||||
# If return is pressed during first PLAY_NEXT_GUARD_MS then
|
||||
# default to NOT playing the next track, else default to
|
||||
# playing it.
|
||||
default_yes: bool = track_sequence.current.start_time is not None and (
|
||||
(dt.datetime.now() - track_sequence.current.start_time).total_seconds()
|
||||
* 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(
|
||||
"Play next track",
|
||||
msg,
|
||||
default_yes=default_yes,
|
||||
parent=self,
|
||||
):
|
||||
return
|
||||
if self.return_pressed_in_error():
|
||||
return
|
||||
|
||||
# Issue #223 concerns a very short pause (maybe 0.1s) sometimes
|
||||
# when starting to play at track.
|
||||
@ -1386,6 +1359,46 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
session.rollback()
|
||||
session.close()
|
||||
|
||||
def return_pressed_in_error(self) -> bool:
|
||||
"""
|
||||
Check whether Return key has been pressed in error.
|
||||
|
||||
Return True if it has, False if not
|
||||
"""
|
||||
|
||||
if track_sequence.current and self.catch_return_key:
|
||||
# Suppress inadvertent double press
|
||||
if (
|
||||
track_sequence.current
|
||||
and track_sequence.current.start_time
|
||||
and track_sequence.current.start_time
|
||||
+ dt.timedelta(milliseconds=Config.RETURN_KEY_DEBOUNCE_MS)
|
||||
> dt.datetime.now()
|
||||
):
|
||||
return True
|
||||
|
||||
# If return is pressed during first PLAY_NEXT_GUARD_MS then
|
||||
# default to NOT playing the next track, else default to
|
||||
# playing it.
|
||||
default_yes: bool = track_sequence.current.start_time is not None and (
|
||||
(dt.datetime.now() - track_sequence.current.start_time).total_seconds()
|
||||
* 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(
|
||||
"Play next track",
|
||||
msg,
|
||||
default_yes=default_yes,
|
||||
parent=self,
|
||||
):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def resume(self) -> None:
|
||||
"""
|
||||
Resume playing last track. We may be playing the next track
|
||||
|
||||
Loading…
Reference in New Issue
Block a user