Skip to content

Commit

Permalink
Improved stopping/renaming/deleting GIFs/images
Browse files Browse the repository at this point in the history
Support for renaming GIFs has been added, which like normal renaming,
will stop, rename, and resume a GIF in place. This was somewhat tricky
to figure out without the underlying QMovie freezing, but part of the
solution involved added a new signal, `force_pause_signal`, for force-
resuming actively running GIFs without freezing.

Additionally, stopping and resuming stopped GIFs has been improved.
Stopping GIFs now only changes the QMovie's filename without calling
.stop(), as .stop() causes more problems than it fixes. When stopping,
the original filename is saved to `QVideoPlayerLabel.filename` and
reused when pause() is called and it's detected that the QMovie's
filename and the expected filename don't match. The GIF is then
resumed from the progress bar's current value.

Deleting GIFs and images already worked, but this functionality has
been extended to GIFs you're currently watching.

For static images, a setting called `checkRenameMissingImages` has been
added which determines whether or not renaming an image file which no
longer exists will do nothing or will save the cached version to the
desired path.

Also, QVideoPlayerLabel.play() now accepts an `autostart` parameter
for GIFs (currently unused), and docstrings have been added/improved
for rename() and get_renamed_output().
  • Loading branch information
thisismy-github committed May 16, 2022
1 parent 268e98e commit 23acbcf
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 48 deletions.
33 changes: 22 additions & 11 deletions bin/window_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setupUi(self, settingsDialog):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 334, 1731))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 334, 1753))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout_4.setObjectName("verticalLayout_4")
Expand Down Expand Up @@ -131,31 +131,31 @@ def setupUi(self, settingsDialog):
self.checkSaveAsUseMediaFolder = QtWidgets.QCheckBox(self.tabGeneral)
self.checkSaveAsUseMediaFolder.setChecked(True)
self.checkSaveAsUseMediaFolder.setObjectName("checkSaveAsUseMediaFolder")
self.formLayout.setWidget(9, QtWidgets.QFormLayout.SpanningRole, self.checkSaveAsUseMediaFolder)
self.formLayout.setWidget(10, QtWidgets.QFormLayout.SpanningRole, self.checkSaveAsUseMediaFolder)
self.checkStopOnFinish = QtWidgets.QCheckBox(self.tabGeneral)
self.checkStopOnFinish.setObjectName("checkStopOnFinish")
self.formLayout.setWidget(10, QtWidgets.QFormLayout.SpanningRole, self.checkStopOnFinish)
self.formLayout.setWidget(11, QtWidgets.QFormLayout.SpanningRole, self.checkStopOnFinish)
self.checkNavigationWrap = QtWidgets.QCheckBox(self.tabGeneral)
self.checkNavigationWrap.setChecked(True)
self.checkNavigationWrap.setObjectName("checkNavigationWrap")
self.formLayout.setWidget(11, QtWidgets.QFormLayout.SpanningRole, self.checkNavigationWrap)
self.formLayout.setWidget(12, QtWidgets.QFormLayout.SpanningRole, self.checkNavigationWrap)
self.checkNavigationUnpause = QtWidgets.QCheckBox(self.tabGeneral)
self.checkNavigationUnpause.setChecked(True)
self.checkNavigationUnpause.setObjectName("checkNavigationUnpause")
self.formLayout.setWidget(12, QtWidgets.QFormLayout.SpanningRole, self.checkNavigationUnpause)
self.formLayout.setWidget(13, QtWidgets.QFormLayout.SpanningRole, self.checkNavigationUnpause)
self.checkAutoEnableSubtitles = QtWidgets.QCheckBox(self.tabGeneral)
self.checkAutoEnableSubtitles.setChecked(True)
self.checkAutoEnableSubtitles.setObjectName("checkAutoEnableSubtitles")
self.formLayout.setWidget(15, QtWidgets.QFormLayout.SpanningRole, self.checkAutoEnableSubtitles)
self.formLayout.setWidget(16, QtWidgets.QFormLayout.SpanningRole, self.checkAutoEnableSubtitles)
self.checkCycleRememberOriginalPath = QtWidgets.QCheckBox(self.tabGeneral)
self.checkCycleRememberOriginalPath.setChecked(True)
self.checkCycleRememberOriginalPath.setTristate(True)
self.checkCycleRememberOriginalPath.setObjectName("checkCycleRememberOriginalPath")
self.formLayout.setWidget(16, QtWidgets.QFormLayout.SpanningRole, self.checkCycleRememberOriginalPath)
self.formLayout.setWidget(17, QtWidgets.QFormLayout.SpanningRole, self.checkCycleRememberOriginalPath)
self.checkRecycleBin = QtWidgets.QCheckBox(self.tabGeneral)
self.checkRecycleBin.setChecked(True)
self.checkRecycleBin.setObjectName("checkRecycleBin")
self.formLayout.setWidget(17, QtWidgets.QFormLayout.SpanningRole, self.checkRecycleBin)
self.formLayout.setWidget(18, QtWidgets.QFormLayout.SpanningRole, self.checkRecycleBin)
self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.checkMinimizePause = QtWidgets.QCheckBox(self.tabGeneral)
Expand All @@ -165,7 +165,7 @@ def setupUi(self, settingsDialog):
self.checkMinimizeRestore.setEnabled(False)
self.checkMinimizeRestore.setObjectName("checkMinimizeRestore")
self.horizontalLayout_8.addWidget(self.checkMinimizeRestore)
self.formLayout.setLayout(18, QtWidgets.QFormLayout.SpanningRole, self.horizontalLayout_8)
self.formLayout.setLayout(19, QtWidgets.QFormLayout.SpanningRole, self.horizontalLayout_8)
self.label_50 = QtWidgets.QLabel(self.tabGeneral)
self.label_50.setObjectName("label_50")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_50)
Expand All @@ -178,15 +178,19 @@ def setupUi(self, settingsDialog):
self.checkCopyEscapeBackslashes = QtWidgets.QCheckBox(self.tabGeneral)
self.checkCopyEscapeBackslashes.setChecked(True)
self.checkCopyEscapeBackslashes.setObjectName("checkCopyEscapeBackslashes")
self.formLayout.setWidget(13, QtWidgets.QFormLayout.SpanningRole, self.checkCopyEscapeBackslashes)
self.formLayout.setWidget(14, QtWidgets.QFormLayout.SpanningRole, self.checkCopyEscapeBackslashes)
self.checkRememberDropFolder = QtWidgets.QCheckBox(self.tabGeneral)
self.checkRememberDropFolder.setChecked(True)
self.checkRememberDropFolder.setObjectName("checkRememberDropFolder")
self.formLayout.setWidget(14, QtWidgets.QFormLayout.SpanningRole, self.checkRememberDropFolder)
self.formLayout.setWidget(15, QtWidgets.QFormLayout.SpanningRole, self.checkRememberDropFolder)
self.checkFFprobe = QtWidgets.QCheckBox(self.tabGeneral)
self.checkFFprobe.setChecked(True)
self.checkFFprobe.setObjectName("checkFFprobe")
self.formLayout.setWidget(7, QtWidgets.QFormLayout.SpanningRole, self.checkFFprobe)
self.checkRenameMissingImages = QtWidgets.QCheckBox(self.tabGeneral)
self.checkRenameMissingImages.setChecked(True)
self.checkRenameMissingImages.setObjectName("checkRenameMissingImages")
self.formLayout.setWidget(9, QtWidgets.QFormLayout.SpanningRole, self.checkRenameMissingImages)
self.verticalLayout_3.addLayout(self.formLayout)
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setContentsMargins(-1, 5, -1, 5)
Expand Down Expand Up @@ -1415,6 +1419,13 @@ def retranslateUi(self, settingsDialog):
"NOTE: If you experience noticable delays while\n"
"opening media, you can try disabling this setting."))
self.checkFFprobe.setText(_translate("settingsDialog", "Use FFprobe when possible (requires PyPlayer restart)"))
self.checkRenameMissingImages.setToolTip(_translate("settingsDialog", "If checked, renaming an image file that doesn\'t\n"
"exist anymore will save the currently cached\n"
"image as a new file with your desired name.\n"
"\n"
"If not checked, renaming an image file that\n"
"doesn\'t exist anymore will do nothing."))
self.checkRenameMissingImages.setText(_translate("settingsDialog", "Renaming missing image files creates a new one"))
self.groupBox.setTitle(_translate("settingsDialog", "Window behavior"))
self.checkFocusDrop.setToolTip(_translate("settingsDialog", "If checked, dragging-and-dropping media will raise the window\n"
"and give it focus. This brings the window to the foreground and\n"
Expand Down
40 changes: 29 additions & 11 deletions bin/window_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>1731</height>
<height>1753</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -340,7 +340,7 @@ name as the source file, with &quot;_edited&quot; appended to it.</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="checkSaveAsUseMediaFolder">
<property name="toolTip">
<string>If checked, the &quot;Save as...&quot; prompt will default
Expand All @@ -356,7 +356,7 @@ folder from any dialog.</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="checkStopOnFinish">
<property name="toolTip">
<string>If checked, the media player will completely stop
Expand All @@ -375,7 +375,7 @@ going to &quot;File-&gt;Stop Player&quot; in the menubar.</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<item row="12" column="0" colspan="2">
<widget class="QCheckBox" name="checkNavigationWrap">
<property name="toolTip">
<string>If checked, using the arrow keys or J/L to navigate forwards or backwards in a video
Expand All @@ -391,7 +391,7 @@ Example: If you're at the end of a video and press ➞, you'll be placed back at
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<item row="13" column="0" colspan="2">
<widget class="QCheckBox" name="checkNavigationUnpause">
<property name="toolTip">
<string>If checked, navigating with the arrow keys, J/L, scrubbing, etc. after the media
Expand All @@ -405,7 +405,7 @@ has finished will automatically unpause the media and resume playback.</string>
</property>
</widget>
</item>
<item row="15" column="0" colspan="2">
<item row="16" column="0" colspan="2">
<widget class="QCheckBox" name="checkAutoEnableSubtitles">
<property name="toolTip">
<string>If checked, subtitle tracks will be automatically
Expand All @@ -420,7 +420,7 @@ pre-existing tracks and manually-added tracks.</string>
</property>
</widget>
</item>
<item row="16" column="0" colspan="2">
<item row="17" column="0" colspan="2">
<widget class="QCheckBox" name="checkCycleRememberOriginalPath">
<property name="toolTip">
<string>Tristate:
Expand All @@ -446,7 +446,7 @@ next file that will play will still be file #6.</string>
</property>
</widget>
</item>
<item row="17" column="0" colspan="2">
<item row="18" column="0" colspan="2">
<widget class="QCheckBox" name="checkRecycleBin">
<property name="toolTip">
<string>If checked, files marked for deletion are sent to your computer's
Expand All @@ -460,7 +460,7 @@ recycle bin instead of being immediately/permanently deleted.</string>
</property>
</widget>
</item>
<item row="18" column="0" colspan="2">
<item row="19" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="checkMinimizePause">
Expand Down Expand Up @@ -517,7 +517,7 @@ but only if the media had not been paused prior to minimizing.</string>
</item>
</widget>
</item>
<item row="13" column="0" colspan="2">
<item row="14" column="0" colspan="2">
<widget class="QCheckBox" name="checkCopyEscapeBackslashes">
<property name="toolTip">
<string>If checked, copying a media's path to your clipboard
Expand All @@ -535,7 +535,7 @@ systems do not use backslashes in their paths.</string>
</property>
</widget>
</item>
<item row="14" column="0" colspan="2">
<item row="15" column="0" colspan="2">
<widget class="QCheckBox" name="checkRememberDropFolder">
<property name="toolTip">
<string>If checked, dragging and dropping media will remember
Expand Down Expand Up @@ -576,6 +576,24 @@ opening media, you can try disabling this setting.</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="checkRenameMissingImages">
<property name="toolTip">
<string>If checked, renaming an image file that doesn't
exist anymore will save the currently cached
image as a new file with your desired name.

If not checked, renaming an image file that
doesn't exist anymore will do nothing.</string>
</property>
<property name="text">
<string>Renaming missing image files creates a new one</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
Loading

0 comments on commit 23acbcf

Please sign in to comment.