Skip to content

Commit

Permalink
feat: add option to disable overlay timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Dec 24, 2021
1 parent cd78f48 commit 4d0782a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions gridplayer/dialogs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, parent):
"video_defaults/random_loop": self.videoRandomLoop,
"video_defaults/muted": self.videoMuted,
"video_defaults/paused": self.videoPaused,
"misc/overlay_hide": self.timeoutOverlayFlag,
"misc/overlay_timeout": self.timeoutOverlay,
"misc/mouse_hide": self.timeoutMouseHideFlag,
"misc/mouse_hide_timeout": self.timeoutMouseHide,
Expand Down Expand Up @@ -115,6 +116,7 @@ def ui_fill(self):
def ui_customize_dynamic(self):
self.driver_selected(self.playerVideoDriver.currentIndex())
self.timeoutMouseHide.setEnabled(self.timeoutMouseHideFlag.isChecked())
self.timeoutOverlay.setEnabled(self.timeoutOverlayFlag.isChecked())

self.playerVideoDriverPlayers.setRange(1, MAX_VLC_PROCESSES)
self.timeoutOverlay.setRange(1, 60)
Expand All @@ -127,6 +129,7 @@ def ui_connect(self):
qt_connect(
(self.playerVideoDriver.currentIndexChanged, self.driver_selected),
(self.timeoutMouseHideFlag.stateChanged, self.timeoutMouseHide.setEnabled),
(self.timeoutOverlayFlag.stateChanged, self.timeoutOverlay.setEnabled),
(self.logFileOpen.clicked, self.open_logfile),
)

Expand Down
8 changes: 7 additions & 1 deletion gridplayer/dialogs/settings_dialog_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Ui_SettingsDialog(object):
def setupUi(self, SettingsDialog):
SettingsDialog.setObjectName("SettingsDialog")
SettingsDialog.resize(440, 505)
SettingsDialog.resize(442, 541)
self.lay_main = QtWidgets.QVBoxLayout(SettingsDialog)
self.lay_main.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
self.lay_main.setObjectName("lay_main")
Expand Down Expand Up @@ -172,6 +172,9 @@ def setupUi(self, SettingsDialog):
self.section_timeouts.setFont(font)
self.section_timeouts.setObjectName("section_timeouts")
self.lay_section_timeouts.addWidget(self.section_timeouts)
self.timeoutOverlayFlag = QtWidgets.QCheckBox(SettingsDialog)
self.timeoutOverlayFlag.setObjectName("timeoutOverlayFlag")
self.lay_section_timeouts.addWidget(self.timeoutOverlayFlag)
self.lay_timeoutOverlay = QtWidgets.QHBoxLayout()
self.lay_timeoutOverlay.setObjectName("lay_timeoutOverlay")
self.timeoutOverlay = QtWidgets.QSpinBox(SettingsDialog)
Expand Down Expand Up @@ -317,6 +320,9 @@ def retranslateUi(self, SettingsDialog):
_translate("SettingsDialog", "Videos per process")
)
self.section_timeouts.setText(_translate("SettingsDialog", "Timeouts"))
self.timeoutOverlayFlag.setText(
_translate("SettingsDialog", "Hide overlay after timeout")
)
self.timeoutOverlayLabel.setText(
_translate("SettingsDialog", "Video overlay timeout (sec)")
)
Expand Down
1 change: 1 addition & 0 deletions gridplayer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"video_defaults/random_loop": False,
"video_defaults/muted": True,
"video_defaults/paused": False,
"misc/overlay_hide": True,
"misc/overlay_timeout": 1,
"misc/mouse_hide": True,
"misc/mouse_hide_timeout": 3,
Expand Down
15 changes: 11 additions & 4 deletions gridplayer/widgets/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def mouseReleaseEvent(self, event) -> None:
def hideEvent(self, event):
self.hide_overlay()

def showEvent(self, event):
if self.is_video_initialized and not Settings().get("misc/overlay_hide"):
self.show_overlay()

def is_under_cursor(self):
return self.rect().contains(self.mapFromGlobal(QCursor.pos()))

Expand Down Expand Up @@ -255,13 +259,15 @@ def loop_end(self):

def show_overlay(self):
self.overlay.show()
self.overlay_hide_timer.start(1000 * Settings().get("misc/overlay_timeout"))
if Settings().get("misc/overlay_hide"):
self.overlay_hide_timer.start(1000 * Settings().get("misc/overlay_timeout"))

def hide_overlay(self):
if not Settings().get("misc/overlay_hide"):
return

if self.is_active:
self.overlay_hide_timer.start(
1000 * Settings().get("misc/overlay_timeout"),
)
self.overlay_hide_timer.start(1000 * Settings().get("misc/overlay_timeout"))
return

self.overlay.hide()
Expand Down Expand Up @@ -329,6 +335,7 @@ def load_video_finish(self): # noqa: WPS213
self.set_pause(self.video_params.is_paused)

self.status_label.hide()
self.show_overlay()

def set_aspect(self, aspect):
self.video_params.aspect_mode = aspect
Expand Down
11 changes: 9 additions & 2 deletions resources/ui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>505</height>
<width>442</width>
<height>541</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -326,6 +326,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="timeoutOverlayFlag">
<property name="text">
<string>Hide overlay after timeout</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="lay_timeoutOverlay" stretch="0,1">
<item>
Expand Down

0 comments on commit 4d0782a

Please sign in to comment.