Don't react to second of two quick 'return' key presses

Fixes #228
This commit is contained in:
Keith Edmunds 2024-04-28 13:15:15 +01:00
parent 09dcba90a9
commit 80687df82e
2 changed files with 12 additions and 4 deletions

View File

@ -77,9 +77,9 @@ class Config(object):
OBS_PASSWORD = "auster" OBS_PASSWORD = "auster"
OBS_PORT = 4455 OBS_PORT = 4455
PLAY_SETTLE = 500000 PLAY_SETTLE = 500000
RETURN_KEY_DEBOUNCE_MS = 500
ROOT = os.environ.get("ROOT") or "/home/kae/music" ROOT = os.environ.get("ROOT") or "/home/kae/music"
ROWS_FROM_ZERO = True ROWS_FROM_ZERO = True
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
SCROLL_TOP_MARGIN = 3 SCROLL_TOP_MARGIN = 3
START_GAP_WARNING_THRESHOLD = 300 START_GAP_WARNING_THRESHOLD = 300
TEXT_NO_TRACK_NO_NOTE = "[Section header]" TEXT_NO_TRACK_NO_NOTE = "[Section header]"
@ -90,3 +90,6 @@ class Config(object):
WARNING_MS_BEFORE_FADE = 5500 WARNING_MS_BEFORE_FADE = 5500
WARNING_MS_BEFORE_SILENCE = 5500 WARNING_MS_BEFORE_SILENCE = 5500
WEB_ZOOM_FACTOR = 1.2 WEB_ZOOM_FACTOR = 1.2
# These rely on earlier definitions
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")

View File

@ -214,8 +214,7 @@ class Window(QMainWindow, Ui_MainWindow):
try: try:
mixer.init() mixer.init()
except Exception: except Exception:
helpers.show_warning(self, "Fatal error", helpers.show_warning(self, "Fatal error", "Cannot initialise sound device")
"Cannot initialise sound device")
sys.exit(1) sys.exit(1)
self.widgetFadeVolume.hideAxis("bottom") self.widgetFadeVolume.hideAxis("bottom")
@ -654,7 +653,6 @@ class Window(QMainWindow, Ui_MainWindow):
else: else:
log.error("Failed to retrieve playlist") log.error("Failed to retrieve playlist")
def download_played_tracks(self) -> None: def download_played_tracks(self) -> None:
"""Download a CSV of played tracks""" """Download a CSV of played tracks"""
@ -1098,6 +1096,13 @@ class Window(QMainWindow, Ui_MainWindow):
# Check for inadvertent press of 'return' # Check for inadvertent press of 'return'
if self.catch_return_key: if self.catch_return_key:
# Suppress inadvertent double press
if (
track_sequence.now.start_time and track_sequence.now.start_time
+ dt.timedelta(milliseconds=Config.RETURN_KEY_DEBOUNCE_MS)
> dt.datetime.now()
):
return
if not helpers.ask_yes_no( if not helpers.ask_yes_no(
"Track playing", "Track playing",
"Really play next track now?", "Really play next track now?",