* Pressing ESC in full-screen view does not quit, just restores window.
authorUrban Wallasch <urban.wallasch@freenet.de>
Fri, 14 May 2021 22:29:53 +0000 (00:29 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Fri, 14 May 2021 22:29:53 +0000 (00:29 +0200)
* Made 'Load Thumbnails' the default button in thumbnail manager dialog.
* Avoid division by zero exception for zero duration files.
* Improved dark theme style example.

ffpreview.conf.sample
ffpreview.py

index bf8bc5b519c129c7de41dc76286d3e57bfb28491..bec1457e5a1ef8386524d8364b4330fb4ff4a876 100644 (file)
@@ -14,12 +14,13 @@ grid=5x5
 
 # Application and selected thumbnail style in CSS syntax.
 # Examples:
-# default theme
-#  appstyle=
-#  selstyle=background-color: lightblue;
-# dark theme
-#  appstyle=background-color: #181818; color: #a0a0a0;
-#  selstyle=background-color: #b0b0b0; color: #202020;
+# Standard theme example:
+#   appstyle=
+#   selstyle=background-color: lightblue;
+# Dark theme example:
+#   appstyle= * {background-color: #181818; color: #b0b0b0;}
+#     :selected {background-color: #4a90d9; color: #f4f8fd;}
+#   selstyle= background-color: #4a90d9; color: #f4f8fd;
 appstyle=
 selstyle=background-color: lightblue;
 
index 6ff4726c8221617d17fbc1a343c8187c635f0cde..c748c2f555174e7837af1bf740cecf80e51f5a5e 100755 (executable)
@@ -554,6 +554,14 @@ class sMainWindow(QMainWindow):
             for w in self.statdsp:
                 w.hide()
 
+    def esc_action(self):
+        if self.windowState() & Qt.WindowFullScreen:
+            self.showNormal()
+            for w in self.statdsp:
+                w.show()
+        else:
+            die(0)
+
     def init_window(self, title):
         self.setWindowTitle(title)
         self.broken_img = sQPixmap(imgdata=_broken_img_png)
@@ -594,7 +602,7 @@ class sMainWindow(QMainWindow):
         self.main_layout.addLayout(self.statbar)
         self.setCentralWidget(self.main_frame)
 
-        QShortcut('Esc', self).activated.connect(lambda: die(0))
+        QShortcut('Esc', self).activated.connect(self.esc_action)
         QShortcut('Ctrl+Q', self).activated.connect(lambda: die(0))
         QShortcut('Ctrl+W', self).activated.connect(lambda: die(0))
         QShortcut('Ctrl+F', self).activated.connect(self.toggle_fullscreen)
@@ -714,7 +722,7 @@ class sMainWindow(QMainWindow):
 
         def load_thumbs(item):
             if item.vfile:
-                eprint(0, "open ", item.vfile)
+                eprint(1, "open ", item.vfile)
                 dlg.close()
                 self.load_view(item.vfile)
 
@@ -738,9 +746,9 @@ class sMainWindow(QMainWindow):
         refresh_button.clicked.connect(lambda: refresh_list(list_widget, outdir))
         load_button = QPushButton("Load Thumbnails")
         load_button.clicked.connect(lambda: load_thumbs_btn(list_widget))
+        load_button.setDefault(True)
         close_button = QPushButton("Close")
         close_button.clicked.connect(dlg.close)
-        close_button.setDefault(True)
         btn_layout.addWidget(load_button)
         btn_layout.addWidget(refresh_button)
         btn_layout.addWidget(remove_button)
@@ -848,7 +856,8 @@ def make_thumbs(vidfile, thinfo, thdir, ilabel=None, pbar=None):
                     thinfo['th'].append([ cnt, pictemplate % cnt, t ])
                     if ilabel and pbar:
                         ilabel.setText('%s / %d s' % (t.split('.')[0], thinfo['duration']))
-                        pbar.setValue(float(t) * 100 / thinfo['duration'])
+                        if thinfo['duration']:
+                            pbar.setValue(float(t) * 100 / thinfo['duration'])
                         QApplication.processEvents()
                     else:
                         print('\r%s / %d s ' % (t.split('.')[0], thinfo['duration']), end='', file=sys.stderr)