Add more protection against hitting return twice
This commit is contained in:
parent
f825304de4
commit
a7932adfe4
@ -78,6 +78,7 @@ class Config(object):
|
|||||||
OBS_HOST = "localhost"
|
OBS_HOST = "localhost"
|
||||||
OBS_PASSWORD = "auster"
|
OBS_PASSWORD = "auster"
|
||||||
OBS_PORT = 4455
|
OBS_PORT = 4455
|
||||||
|
PLAY_NEXT_GUARD_MS = 10000
|
||||||
PLAY_SETTLE = 500000
|
PLAY_SETTLE = 500000
|
||||||
REPLACE_FILES_DEFAULT_SOURCE = "/home/kae/music/Singles/tmp"
|
REPLACE_FILES_DEFAULT_SOURCE = "/home/kae/music/Singles/tmp"
|
||||||
RETURN_KEY_DEBOUNCE_MS = 500
|
RETURN_KEY_DEBOUNCE_MS = 500
|
||||||
|
|||||||
@ -1164,10 +1164,21 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
> dt.datetime.now()
|
> dt.datetime.now()
|
||||||
):
|
):
|
||||||
return
|
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.now.start_time is not None
|
||||||
|
and (
|
||||||
|
(dt.datetime.now() - track_sequence.now.start_time).total_seconds()
|
||||||
|
* 1000
|
||||||
|
> Config.PLAY_NEXT_GUARD_MS
|
||||||
|
)
|
||||||
|
)
|
||||||
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?",
|
||||||
default_yes=True,
|
default_yes=default_yes,
|
||||||
parent=self,
|
parent=self,
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
@ -1311,7 +1322,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
if os.path.exists(rf.obsolete_path):
|
if os.path.exists(rf.obsolete_path):
|
||||||
os.unlink(rf.obsolete_path)
|
os.unlink(rf.obsolete_path)
|
||||||
else:
|
else:
|
||||||
log.error(f"replace_files: could not unlink {rf.obsolete_path=}")
|
log.error(
|
||||||
|
f"replace_files: could not unlink {rf.obsolete_path=}"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
if rf.track_path:
|
if rf.track_path:
|
||||||
if os.path.exists(rf.track_path):
|
if os.path.exists(rf.track_path):
|
||||||
@ -1340,12 +1353,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
else:
|
else:
|
||||||
# We're importing a new track
|
# We're importing a new track
|
||||||
do_import = self.ok_to_import(
|
do_import = self.ok_to_import(
|
||||||
session,
|
session, os.path.basename(rf.new_file_path), rf.tags
|
||||||
os.path.basename(rf.new_file_path),
|
|
||||||
rf.tags
|
|
||||||
)
|
)
|
||||||
if do_import:
|
if do_import:
|
||||||
rf.audio_metadata = helpers.get_audio_metadata(rf.new_file_path)
|
rf.audio_metadata = helpers.get_audio_metadata(
|
||||||
|
rf.new_file_path
|
||||||
|
)
|
||||||
import_files.append(rf)
|
import_files.append(rf)
|
||||||
|
|
||||||
# self.import_filenames(dlg.replacement_files)
|
# self.import_filenames(dlg.replacement_files)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user