2020 format = '%(asctime)s %(levelname)s:%(message)s' ,
2121 handlers = [logging .StreamHandler ()]
2222)
23+ from PyQt6 import uic
24+ from PyQt6 .QtWidgets import QDialog
25+ from PyQt6 .QtCore import QSettings
26+
27+ class ConfigDialog (QDialog ):
28+ def __init__ (self , parent = None , current_jump_before = 5000 ):
29+ super ().__init__ (parent )
30+ # uic.loadUi("ui/configdialog.ui", self)
31+ uic .loadUi (os .path .join (os .path .dirname (__file__ ), "ui/configdialog.ui" ), self )
32+
33+ self .jumpBeforeSpinBox .setValue (current_jump_before )
34+ self .okButton .clicked .connect (self .accept )
35+ self .cancelButton .clicked .connect (self .reject )
36+
37+ def get_jump_before (self ):
38+ return self .jumpBeforeSpinBox .value ()
2339
2440class DatasetViewer (QMainWindow ):
2541 def __init__ (self ):
@@ -43,6 +59,7 @@ def __init__(self):
4359 self .available_labels = []
4460 self .current_video_info = None
4561 self ._updating_selection = False
62+ self .jump_before_ms = 5000
4663
4764 self .player = QMediaPlayer (self )
4865 self .audio_output = QAudioOutput (self )
@@ -71,6 +88,10 @@ def __init__(self):
7188 self .forwardFrameButton .clicked .connect (lambda : self .step_frame (1 ))
7289 self .addAnnotationButton .clicked .connect (self .add_annotation_at_current_time )
7390 self .removeAnnotationButton .clicked .connect (self .remove_selected_annotation )
91+ self .actionOpen_Settings .triggered .connect (self .show_config_dialog )
92+
93+
94+ self .load_settings ()
7495
7596
7697
@@ -169,7 +190,7 @@ def select_annotation(self, item):
169190 else :
170191 self .metadataTextEdit .setText ("" )
171192
172- jump_to = max (0 , ann ["position" ] - 5000 ) # 5000 ms = 5 seconds
193+ jump_to = max (0 , ann ["position" ] - self . jump_before_ms ) # 5000 ms = 5 seconds
173194 self .player .setPosition (jump_to )
174195 self .player .play ()
175196 self .playButton .setText ("Pause" )
@@ -395,3 +416,19 @@ def set_annotation_time_to_video(self):
395416
396417 logging .info (f"Annotation updated and resorted to { current_time } ms (index { new_index } )" )
397418
419+ def show_config_dialog (self ):
420+ dialog = ConfigDialog (self , self .jump_before_ms )
421+ if dialog .exec ():
422+ self .jump_before_ms = dialog .get_jump_before ()
423+ self .save_settings () # Persist!
424+
425+
426+ def save_settings (self ):
427+ settings = QSettings ("OSLActionSpotting" , "DatasetAnnotationTool" )
428+ settings .setValue ("jump_before_ms" , self .jump_before_ms )
429+
430+
431+ def load_settings (self ):
432+ settings = QSettings ("OSLActionSpotting" , "DatasetAnnotationTool" )
433+ # get returns QVariant; int(None) raises TypeError, so handle missing gracefully
434+ self .jump_before_ms = settings .value ("jump_before_ms" , 5000 )
0 commit comments