* Added reset to zero button to time input in preferences; minor cleanup.
authorUrban Wallasch <urban.wallasch@freenet.de>
Fri, 21 May 2021 19:15:18 +0000 (21:15 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Fri, 21 May 2021 19:15:18 +0000 (21:15 +0200)
ffpreview.py

index fbe172726c05fee8acb27af2b96214581c3efd77..c69d0b5b07feb1f1a452220da87d46b157458a2c 100755 (executable)
@@ -910,7 +910,7 @@ class cfgDialog(QDialog):
             elif o[1] == 'check':
                 self.cfg[o[0]] = w.isChecked()
             elif o[1] == 'time':
-                t = w.time()
+                t = w.children()[1].time()
                 self.cfg[o[0]] = t.hour()*3600 + t.minute()*60 + t.second() + t.msec()/1000
             elif o[1] == 'mcombo':
                 self.cfg[o[0]] = w.currentText()
@@ -941,6 +941,20 @@ class cfgDialog(QDialog):
         widget.setLayout(layout)
         return widget
 
+    def _time_edit(self, h=0, m=0, s=0, ms=0):
+        widget = QWidget()
+        edit = QTimeEdit(QTime(h, m, s, ms))
+        edit.timeChanged.connect(self.changed)
+        edit.setDisplayFormat('hh:mm:ss.zzz')
+        zero = QPushButton('→ 00:00')
+        zero.clicked.connect(lambda: edit.setTime(QTime(0, 0, 0, 0)))
+        layout = QHBoxLayout()
+        layout.addWidget(edit, 10)
+        layout.addWidget(zero, 1)
+        layout.setContentsMargins(0, 0, 0, 0)
+        widget.setLayout(layout)
+        return widget
+
     def refresh(self):
         self.cfg = ffConfig.get()
         self.refresh_view()
@@ -990,10 +1004,8 @@ class cfgDialog(QDialog):
                 s = s % 3600
                 m = s / 60
                 s = s % 60
-                w = QTimeEdit(QTime(h, m, s, ms))
-                w.setDisplayFormat('hh:mm:ss.zzz')
+                w = self._time_edit(h, m, s, ms)
                 w.setToolTip(o[2])
-                w.timeChanged.connect(self.changed)
             elif o[1] == 'mcombo':
                 w = QComboBox()
                 w.addItems(['iframe', 'scene', 'skip', 'time', 'customvf'])
@@ -1158,8 +1170,6 @@ class sMainWindow(QMainWindow):
     def config_dlg(self):
         if self.view_locked:
             return
-        gr = cfg['grid_rows']
-        gc = cfg['grid_columns']
         dlg = cfgDialog(self)
         res = dlg.exec_()
         if res == QDialog.Accepted: