Skip to content

Commit

Permalink
feat: add option to loop through videos in directory
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Dec 24, 2021
1 parent bdeb08a commit cd78f48
Show file tree
Hide file tree
Showing 28 changed files with 85,647 additions and 84,003 deletions.
13 changes: 12 additions & 1 deletion gridplayer/dialogs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from gridplayer import params_env, utils
from gridplayer.dialogs.messagebox import QCustomMessageBox
from gridplayer.dialogs.settings_dialog_ui import Ui_SettingsDialog
from gridplayer.params_static import GridMode, VideoAspect, VideoDriver
from gridplayer.params_static import GridMode, VideoAspect, VideoDriver, VideoRepeat
from gridplayer.settings import Settings
from gridplayer.utils.app_dir import get_app_data_dir
from gridplayer.utils.misc import qt_connect
Expand Down Expand Up @@ -58,6 +58,7 @@ def __init__(self, parent):
"playlist/save_window": self.playlistSaveWindow,
"playlist/seek_synced": self.playlistSeekSync,
"video_defaults/aspect": self.videoAspect,
"video_defaults/repeat": self.repeatMode,
"video_defaults/random_loop": self.videoRandomLoop,
"video_defaults/muted": self.videoMuted,
"video_defaults/paused": self.videoPaused,
Expand Down Expand Up @@ -107,6 +108,7 @@ def ui_fill(self):
self.fill_playerVideoDriver()
self.fill_gridMode()
self.fill_videoAspect()
self.fill_repeatMode()
self.fill_logLevel()
self.fill_logLevelVLC()

Expand Down Expand Up @@ -174,6 +176,15 @@ def fill_videoAspect(self):

_fill_combo_box(self.videoAspect, aspect_ratios)

def fill_repeatMode(self):
repeat_modes = {
VideoRepeat.SINGLE_FILE: "Single File",
VideoRepeat.DIR: "Directory",
VideoRepeat.DIR_SHUFFLE: "Directory (Shuffle)",
}

_fill_combo_box(self.repeatMode, repeat_modes)

def fill_gridMode(self):
grid_modes = {
GridMode.AUTO_ROWS: "Rows First",
Expand Down
98 changes: 66 additions & 32 deletions gridplayer/dialogs/settings_dialog_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,67 @@
class Ui_SettingsDialog(object):
def setupUi(self, SettingsDialog):
SettingsDialog.setObjectName("SettingsDialog")
SettingsDialog.resize(440, 481)
SettingsDialog.resize(440, 505)
self.lay_main = QtWidgets.QVBoxLayout(SettingsDialog)
self.lay_main.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
self.lay_main.setObjectName("lay_main")
self.lay_body = QtWidgets.QHBoxLayout()
self.lay_body.setObjectName("lay_body")
self.lay_left_column = QtWidgets.QVBoxLayout()
self.lay_left_column.setObjectName("lay_left_column")
self.lay_section_player = QtWidgets.QVBoxLayout()
self.lay_section_player.setObjectName("lay_section_player")
self.section_player = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_player.setFont(font)
self.section_player.setObjectName("section_player")
self.lay_left_column.addWidget(self.section_player)
self.lay_section_player.addWidget(self.section_player)
self.playerPauseBackgroundVideos = QtWidgets.QCheckBox(SettingsDialog)
self.playerPauseBackgroundVideos.setObjectName("playerPauseBackgroundVideos")
self.lay_left_column.addWidget(self.playerPauseBackgroundVideos)
self.lay_section_player.addWidget(self.playerPauseBackgroundVideos)
self.playerPauseWhenMinimized = QtWidgets.QCheckBox(SettingsDialog)
self.playerPauseWhenMinimized.setObjectName("playerPauseWhenMinimized")
self.lay_left_column.addWidget(self.playerPauseWhenMinimized)
self.lay_section_player.addWidget(self.playerPauseWhenMinimized)
self.playerInhibitScreensaver = QtWidgets.QCheckBox(SettingsDialog)
self.playerInhibitScreensaver.setObjectName("playerInhibitScreensaver")
self.lay_left_column.addWidget(self.playerInhibitScreensaver)
self.lay_section_player.addWidget(self.playerInhibitScreensaver)
self.playerOneInstance = QtWidgets.QCheckBox(SettingsDialog)
self.playerOneInstance.setObjectName("playerOneInstance")
self.lay_left_column.addWidget(self.playerOneInstance)
self.lay_section_player.addWidget(self.playerOneInstance)
self.lay_left_column.addLayout(self.lay_section_player)
self.lay_section_playlist = QtWidgets.QVBoxLayout()
self.lay_section_playlist.setObjectName("lay_section_playlist")
self.section_playlist = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_playlist.setFont(font)
self.section_playlist.setObjectName("section_playlist")
self.lay_left_column.addWidget(self.section_playlist)
self.lay_section_playlist.addWidget(self.section_playlist)
self.playlistSaveWindow = QtWidgets.QCheckBox(SettingsDialog)
self.playlistSaveWindow.setObjectName("playlistSaveWindow")
self.lay_left_column.addWidget(self.playlistSaveWindow)
self.lay_section_playlist.addWidget(self.playlistSaveWindow)
self.playlistSavePosition = QtWidgets.QCheckBox(SettingsDialog)
self.playlistSavePosition.setObjectName("playlistSavePosition")
self.lay_left_column.addWidget(self.playlistSavePosition)
self.lay_section_playlist.addWidget(self.playlistSavePosition)
self.playlistSaveState = QtWidgets.QCheckBox(SettingsDialog)
self.playlistSaveState.setObjectName("playlistSaveState")
self.lay_left_column.addWidget(self.playlistSaveState)
self.lay_section_playlist.addWidget(self.playlistSaveState)
self.playlistSeekSync = QtWidgets.QCheckBox(SettingsDialog)
self.playlistSeekSync.setObjectName("playlistSeekSync")
self.lay_left_column.addWidget(self.playlistSeekSync)
self.lay_section_playlist.addWidget(self.playlistSeekSync)
self.lay_left_column.addLayout(self.lay_section_playlist)
self.lay_section_grid = QtWidgets.QVBoxLayout()
self.lay_section_grid.setObjectName("lay_section_grid")
self.section_grid = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_grid.setFont(font)
self.section_grid.setObjectName("section_grid")
self.lay_left_column.addWidget(self.section_grid)
self.lay_section_grid.addWidget(self.section_grid)
self.lay_gridMode = QtWidgets.QHBoxLayout()
self.lay_gridMode.setObjectName("lay_gridMode")
self.gridModeLabel = QtWidgets.QLabel(SettingsDialog)
Expand All @@ -69,7 +77,7 @@ def setupUi(self, SettingsDialog):
40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
)
self.lay_gridMode.addItem(spacerItem)
self.lay_left_column.addLayout(self.lay_gridMode)
self.lay_section_grid.addLayout(self.lay_gridMode)
self.lay_gridSize = QtWidgets.QHBoxLayout()
self.lay_gridSize.setObjectName("lay_gridSize")
self.gridSize = QtWidgets.QSpinBox(SettingsDialog)
Expand All @@ -78,18 +86,20 @@ def setupUi(self, SettingsDialog):
self.gridSizeLabel = QtWidgets.QLabel(SettingsDialog)
self.gridSizeLabel.setObjectName("gridSizeLabel")
self.lay_gridSize.addWidget(self.gridSizeLabel)
self.lay_gridSize.setStretch(1, 1)
self.lay_left_column.addLayout(self.lay_gridSize)
self.lay_section_grid.addLayout(self.lay_gridSize)
self.gridFit = QtWidgets.QCheckBox(SettingsDialog)
self.gridFit.setObjectName("gridFit")
self.lay_left_column.addWidget(self.gridFit)
self.lay_section_grid.addWidget(self.gridFit)
self.lay_left_column.addLayout(self.lay_section_grid)
self.lay_section_video_defaults = QtWidgets.QVBoxLayout()
self.lay_section_video_defaults.setObjectName("lay_section_video_defaults")
self.section_video_defaults = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_video_defaults.setFont(font)
self.section_video_defaults.setObjectName("section_video_defaults")
self.lay_left_column.addWidget(self.section_video_defaults)
self.lay_section_video_defaults.addWidget(self.section_video_defaults)
self.lay_aspect = QtWidgets.QHBoxLayout()
self.lay_aspect.setObjectName("lay_aspect")
self.videoAspectLabel = QtWidgets.QLabel(SettingsDialog)
Expand All @@ -102,20 +112,34 @@ def setupUi(self, SettingsDialog):
40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
)
self.lay_aspect.addItem(spacerItem1)
self.lay_left_column.addLayout(self.lay_aspect)
self.lay_section_video_defaults.addLayout(self.lay_aspect)
self.lay_repeat = QtWidgets.QHBoxLayout()
self.lay_repeat.setObjectName("lay_repeat")
self.repeatModeLabel = QtWidgets.QLabel(SettingsDialog)
self.repeatModeLabel.setObjectName("repeatModeLabel")
self.lay_repeat.addWidget(self.repeatModeLabel)
self.repeatMode = QtWidgets.QComboBox(SettingsDialog)
self.repeatMode.setObjectName("repeatMode")
self.lay_repeat.addWidget(self.repeatMode)
spacerItem2 = QtWidgets.QSpacerItem(
40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
)
self.lay_repeat.addItem(spacerItem2)
self.lay_section_video_defaults.addLayout(self.lay_repeat)
self.videoRandomLoop = QtWidgets.QCheckBox(SettingsDialog)
self.videoRandomLoop.setObjectName("videoRandomLoop")
self.lay_left_column.addWidget(self.videoRandomLoop)
self.lay_section_video_defaults.addWidget(self.videoRandomLoop)
self.videoPaused = QtWidgets.QCheckBox(SettingsDialog)
self.videoPaused.setObjectName("videoPaused")
self.lay_left_column.addWidget(self.videoPaused)
self.lay_section_video_defaults.addWidget(self.videoPaused)
self.videoMuted = QtWidgets.QCheckBox(SettingsDialog)
self.videoMuted.setObjectName("videoMuted")
self.lay_left_column.addWidget(self.videoMuted)
spacerItem2 = QtWidgets.QSpacerItem(
self.lay_section_video_defaults.addWidget(self.videoMuted)
self.lay_left_column.addLayout(self.lay_section_video_defaults)
spacerItem3 = QtWidgets.QSpacerItem(
0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding
)
self.lay_left_column.addItem(spacerItem2)
self.lay_left_column.addItem(spacerItem3)
self.lay_body.addLayout(self.lay_left_column)
self.lay_right_column = QtWidgets.QVBoxLayout()
self.lay_right_column.setObjectName("lay_right_column")
Expand All @@ -139,13 +163,15 @@ def setupUi(self, SettingsDialog):
self.lay_playerVideoDriverPlayers.setStretch(0, 1)
self.lay_playerVideoDriverBox.addLayout(self.lay_playerVideoDriverPlayers)
self.lay_right_column.addWidget(self.playerVideoDriverBox)
self.lay_section_timeouts = QtWidgets.QVBoxLayout()
self.lay_section_timeouts.setObjectName("lay_section_timeouts")
self.section_timeouts = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_timeouts.setFont(font)
self.section_timeouts.setObjectName("section_timeouts")
self.lay_right_column.addWidget(self.section_timeouts)
self.lay_section_timeouts.addWidget(self.section_timeouts)
self.lay_timeoutOverlay = QtWidgets.QHBoxLayout()
self.lay_timeoutOverlay.setObjectName("lay_timeoutOverlay")
self.timeoutOverlay = QtWidgets.QSpinBox(SettingsDialog)
Expand All @@ -155,10 +181,10 @@ def setupUi(self, SettingsDialog):
self.timeoutOverlayLabel.setObjectName("timeoutOverlayLabel")
self.lay_timeoutOverlay.addWidget(self.timeoutOverlayLabel)
self.lay_timeoutOverlay.setStretch(1, 1)
self.lay_right_column.addLayout(self.lay_timeoutOverlay)
self.lay_section_timeouts.addLayout(self.lay_timeoutOverlay)
self.timeoutMouseHideFlag = QtWidgets.QCheckBox(SettingsDialog)
self.timeoutMouseHideFlag.setObjectName("timeoutMouseHideFlag")
self.lay_right_column.addWidget(self.timeoutMouseHideFlag)
self.lay_section_timeouts.addWidget(self.timeoutMouseHideFlag)
self.lay_timeoutMouseHide = QtWidgets.QHBoxLayout()
self.lay_timeoutMouseHide.setObjectName("lay_timeoutMouseHide")
self.timeoutMouseHide = QtWidgets.QSpinBox(SettingsDialog)
Expand All @@ -168,14 +194,17 @@ def setupUi(self, SettingsDialog):
self.timeoutMouseHideLabel.setObjectName("timeoutMouseHideLabel")
self.lay_timeoutMouseHide.addWidget(self.timeoutMouseHideLabel)
self.lay_timeoutMouseHide.setStretch(1, 1)
self.lay_right_column.addLayout(self.lay_timeoutMouseHide)
self.lay_section_timeouts.addLayout(self.lay_timeoutMouseHide)
self.lay_right_column.addLayout(self.lay_section_timeouts)
self.lay_section_logging = QtWidgets.QVBoxLayout()
self.lay_section_logging.setObjectName("lay_section_logging")
self.section_logging = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.section_logging.setFont(font)
self.section_logging.setObjectName("section_logging")
self.lay_right_column.addWidget(self.section_logging)
self.lay_section_logging.addWidget(self.section_logging)
self.lay_logLevel = QtWidgets.QHBoxLayout()
self.lay_logLevel.setObjectName("lay_logLevel")
self.logLevelLabel = QtWidgets.QLabel(SettingsDialog)
Expand All @@ -184,7 +213,7 @@ def setupUi(self, SettingsDialog):
self.logLevel = QtWidgets.QComboBox(SettingsDialog)
self.logLevel.setObjectName("logLevel")
self.lay_logLevel.addWidget(self.logLevel)
self.lay_right_column.addLayout(self.lay_logLevel)
self.lay_section_logging.addLayout(self.lay_logLevel)
self.lay_logLevelVLC = QtWidgets.QHBoxLayout()
self.lay_logLevelVLC.setObjectName("lay_logLevelVLC")
self.logLevelVLCLabel = QtWidgets.QLabel(SettingsDialog)
Expand All @@ -193,7 +222,8 @@ def setupUi(self, SettingsDialog):
self.logLevelVLC = QtWidgets.QComboBox(SettingsDialog)
self.logLevelVLC.setObjectName("logLevelVLC")
self.lay_logLevelVLC.addWidget(self.logLevelVLC)
self.lay_right_column.addLayout(self.lay_logLevelVLC)
self.lay_section_logging.addLayout(self.lay_logLevelVLC)
self.lay_right_column.addLayout(self.lay_section_logging)
self.section_misc = QtWidgets.QLabel(SettingsDialog)
font = QtGui.QFont()
font.setBold(True)
Expand All @@ -204,10 +234,13 @@ def setupUi(self, SettingsDialog):
self.miscOpaqueHWOverlay = QtWidgets.QCheckBox(SettingsDialog)
self.miscOpaqueHWOverlay.setObjectName("miscOpaqueHWOverlay")
self.lay_right_column.addWidget(self.miscOpaqueHWOverlay)
spacerItem3 = QtWidgets.QSpacerItem(
self.lay_section_misc = QtWidgets.QVBoxLayout()
self.lay_section_misc.setObjectName("lay_section_misc")
self.lay_right_column.addLayout(self.lay_section_misc)
spacerItem4 = QtWidgets.QSpacerItem(
0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding
)
self.lay_right_column.addItem(spacerItem3)
self.lay_right_column.addItem(spacerItem4)
self.lay_body.addLayout(self.lay_right_column)
self.lay_body.setStretch(0, 1)
self.lay_main.addLayout(self.lay_body)
Expand Down Expand Up @@ -271,6 +304,7 @@ def retranslateUi(self, SettingsDialog):
_translate("SettingsDialog", "Default Video Parameters")
)
self.videoAspectLabel.setText(_translate("SettingsDialog", "Aspect mode"))
self.repeatModeLabel.setText(_translate("SettingsDialog", "Repeat mode"))
self.videoRandomLoop.setText(
_translate("SettingsDialog", "Start at random position")
)
Expand Down
6 changes: 6 additions & 0 deletions gridplayer/params_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class VideoAspect(AutoName):
NONE = auto()


class VideoRepeat(AutoName):
SINGLE_FILE = auto()
DIR = auto()
DIR_SHUFFLE = auto()


class VideoDriver(AutoName):
VLC_SW = auto()
VLC_HW = auto()
Expand Down
38 changes: 36 additions & 2 deletions gridplayer/player/managers/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtWidgets import QAction

from gridplayer.params_static import GridMode, VideoAspect
from gridplayer.params_static import GridMode, VideoAspect, VideoRepeat
from gridplayer.player.managers.base import ManagerBase

COMMANDS = MappingProxyType(
Expand Down Expand Up @@ -127,6 +127,16 @@
"icon": "play-all",
"func": "play_pause_all",
},
"Play Previous File": {
"key": Qt.Key_PageUp,
"icon": "previous-video-file",
"func": ("active", "previous_video"),
},
"Play Next File": {
"key": Qt.Key_PageDown,
"icon": "next-video-file",
"func": ("active", "next_video"),
},
"Random Loop": {
"key": "Ctrl+R",
"icon": "loop-random",
Expand All @@ -148,6 +158,29 @@
"icon": "loop-reset",
"func": ("active", "reset_loop"),
},
"Repeat Single File": {
"icon": "loop-single",
"func": ("active", "set_repeat_mode", VideoRepeat.SINGLE_FILE),
"check": (
"is_active_param_set_to",
"repeat_mode",
VideoRepeat.SINGLE_FILE,
),
},
"Repeat Directory": {
"icon": "loop-dir",
"func": ("active", "set_repeat_mode", VideoRepeat.DIR),
"check": ("is_active_param_set_to", "repeat_mode", VideoRepeat.DIR),
},
"Repeat Directory (Shuffle)": {
"icon": "loop-dir-shuffle",
"func": ("active", "set_repeat_mode", VideoRepeat.DIR_SHUFFLE),
"check": (
"is_active_param_set_to",
"repeat_mode",
VideoRepeat.DIR_SHUFFLE,
),
},
"Random": {
"key": "R",
"icon": "loop-random",
Expand Down Expand Up @@ -275,7 +308,8 @@ def _make_actions(self):
def _make_action(self, cmd, cmd_name):
action = QAction(cmd_name, self.parent())

action.setShortcut(QKeySequence(cmd["key"]))
if cmd.get("key"):
action.setShortcut(QKeySequence(cmd["key"]))

action.triggered.connect(self._ctx.commands.resolve(cmd["func"]))

Expand Down
3 changes: 3 additions & 0 deletions gridplayer/player/managers/active_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def cmd_active(self, command, *args):
if self._ctx.active_block is None:
return

if not self._ctx.active_block.is_video_initialized:
return

getattr(self._ctx.active_block, command)(*args)

def is_active_param_set_to(self, param_name, param_value):
Expand Down
8 changes: 8 additions & 0 deletions gridplayer/player/managers/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
{
"video_active": [
"Play / Pause",
"---",
"Play Previous File",
"Play Next File",
"---",
("Step", "Next frame", "Previous frame"),
(
"Loop",
Expand All @@ -37,6 +41,10 @@
"Set Loop Start",
"Set Loop End",
"Loop Reset",
"---",
"Repeat Single File",
"Repeat Directory",
"Repeat Directory (Shuffle)",
),
("Speed", "Faster", "Slower", "Normal"),
("Zoom", "Zoom In", "Zoom Out", "Zoom Reset"),
Expand Down
Loading

0 comments on commit cd78f48

Please sign in to comment.