From 80687df82e508dbc14bf0b1a36e525cea7dd9870 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 28 Apr 2024 13:15:15 +0100 Subject: [PATCH] Don't react to second of two quick 'return' key presses Fixes #228 --- app/config.py | 5 ++++- app/musicmuster.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/config.py b/app/config.py index 55c16ca..2b6f74c 100644 --- a/app/config.py +++ b/app/config.py @@ -77,9 +77,9 @@ class Config(object): OBS_PASSWORD = "auster" OBS_PORT = 4455 PLAY_SETTLE = 500000 + RETURN_KEY_DEBOUNCE_MS = 500 ROOT = os.environ.get("ROOT") or "/home/kae/music" ROWS_FROM_ZERO = True - IMPORT_DESTINATION = os.path.join(ROOT, "Singles") SCROLL_TOP_MARGIN = 3 START_GAP_WARNING_THRESHOLD = 300 TEXT_NO_TRACK_NO_NOTE = "[Section header]" @@ -90,3 +90,6 @@ class Config(object): WARNING_MS_BEFORE_FADE = 5500 WARNING_MS_BEFORE_SILENCE = 5500 WEB_ZOOM_FACTOR = 1.2 + + # These rely on earlier definitions + IMPORT_DESTINATION = os.path.join(ROOT, "Singles") diff --git a/app/musicmuster.py b/app/musicmuster.py index 86320a5..0c838e4 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -214,8 +214,7 @@ class Window(QMainWindow, Ui_MainWindow): try: mixer.init() except Exception: - helpers.show_warning(self, "Fatal error", - "Cannot initialise sound device") + helpers.show_warning(self, "Fatal error", "Cannot initialise sound device") sys.exit(1) self.widgetFadeVolume.hideAxis("bottom") @@ -654,7 +653,6 @@ class Window(QMainWindow, Ui_MainWindow): else: log.error("Failed to retrieve playlist") - def download_played_tracks(self) -> None: """Download a CSV of played tracks""" @@ -1098,6 +1096,13 @@ class Window(QMainWindow, Ui_MainWindow): # Check for inadvertent press of 'return' 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( "Track playing", "Really play next track now?",