Skip to content

Commit

Permalink
fix: hide bulk commands if no video can execute them
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Jun 22, 2022
1 parent 56f7465 commit 3ea89b5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
28 changes: 28 additions & 0 deletions gridplayer/player/managers/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,165 +311,193 @@
"key": "Space",
"icon": "play",
"func": "all_play_pause",
"show_if": "is_any_videos_initialized",
},
"Play Previous File [ALL]": {
"title": translate("Actions", "Play Previous File"),
"key": Qt.SHIFT + Qt.Key_PageUp,
"icon": "previous-video-file",
"func": ("all", "previous_video"),
"show_if": "is_any_videos_local_file",
},
"Play Next File [ALL]": {
"title": translate("Actions", "Play Next File"),
"key": Qt.SHIFT + Qt.Key_PageDown,
"icon": "next-video-file",
"func": ("all", "next_video"),
"show_if": "is_any_videos_local_file",
},
"Timecode [ALL]": {
"title": translate("Actions", "Timecode"),
"key": "Shift+T",
"icon": "seek-sync-time",
"func": "all_seek_timecode",
"show_if": "is_any_videos_seekable",
},
"Random [ALL]": {
"title": translate("Actions", "Random"),
"key": "Shift+R",
"icon": "loop-random",
"func": ("all", "seek_random"),
"show_if": "is_any_videos_seekable",
},
"Next frame [ALL]": {
"title": translate("Actions", "Next frame"),
"key": "Shift+S",
"icon": "next-frame",
"func": ("all", "next_frame"),
"show_if": "is_any_videos_seekable",
},
"Previous frame [ALL]": {
"title": translate("Actions", "Previous frame"),
"key": "Shift+D",
"icon": "previous-frame",
"func": ("all", "previous_frame"),
"show_if": "is_any_videos_seekable",
},
"+1% [ALL]": {
"title": "+1%",
"key": "Shift+Right",
"icon": "seek-plus-1",
"func": ("all", "seek_shift_percent", 1),
"show_if": "is_any_videos_seekable",
},
"+5% [ALL]": {
"title": "+5%",
"key": "Shift+]",
"icon": "seek-plus-5",
"func": ("all", "seek_shift_percent", 5),
"show_if": "is_any_videos_seekable",
},
"+10% [ALL]": {
"title": "+10%",
"key": "Shift+'",
"icon": "seek-plus-10",
"func": ("all", "seek_shift_percent", 10),
"show_if": "is_any_videos_seekable",
},
"-1% [ALL]": {
"title": "-1%",
"key": "Shift+Left",
"icon": "seek-minus-1",
"func": ("all", "seek_shift_percent", -1),
"show_if": "is_any_videos_seekable",
},
"-5% [ALL]": {
"title": "-5%",
"key": "Shift+[",
"icon": "seek-minus-5",
"func": ("all", "seek_shift_percent", -5),
"show_if": "is_any_videos_seekable",
},
"-10% [ALL]": {
"title": "-10%",
"key": "Shift+;",
"icon": "seek-minus-10",
"func": ("all", "seek_shift_percent", -10),
"show_if": "is_any_videos_seekable",
},
"+5s [ALL]": {
"title": translate("Actions", "+5s"),
"key": "Ctrl+Shift+Right",
"icon": "seek-plus-1",
"func": ("all", "seek_shift_ms", 5000),
"show_if": "is_any_videos_seekable",
},
"+15s [ALL]": {
"title": translate("Actions", "+15s"),
"key": "Ctrl+Shift+]",
"icon": "seek-plus-5",
"func": ("all", "seek_shift_ms", 15000),
"show_if": "is_any_videos_seekable",
},
"+30s [ALL]": {
"title": translate("Actions", "+30s"),
"key": "Ctrl+Shift+'",
"icon": "seek-plus-10",
"func": ("all", "seek_shift_ms", 30000),
"show_if": "is_any_videos_seekable",
},
"-5s [ALL]": {
"title": translate("Actions", "-5s"),
"key": "Ctrl+Shift+Left",
"icon": "seek-minus-1",
"func": ("all", "seek_shift_ms", -5000),
"show_if": "is_any_videos_seekable",
},
"-15s [ALL]": {
"title": translate("Actions", "-15s"),
"key": "Ctrl+Shift+[",
"icon": "seek-minus-5",
"func": ("all", "seek_shift_ms", -15000),
"show_if": "is_any_videos_seekable",
},
"-30s [ALL]": {
"title": translate("Actions", "-30s"),
"key": "Ctrl+Shift+;",
"icon": "seek-minus-10",
"func": ("all", "seek_shift_ms", -30000),
"show_if": "is_any_videos_seekable",
},
"Faster [ALL]": {
"title": translate("Actions", "Faster"),
"key": "Shift+C",
"icon": "speed-faster",
"func": ("all", "rate_increase"),
"show_if": "is_any_videos_seekable",
},
"Slower [ALL]": {
"title": translate("Actions", "Slower"),
"key": "Shift+X",
"icon": "speed-slower",
"func": ("all", "rate_decrease"),
"show_if": "is_any_videos_seekable",
},
"Normal [ALL]": {
"title": translate("Actions", "Normal"),
"key": "Shift+Z",
"icon": "speed-reset",
"func": ("all", "rate_reset"),
"show_if": "is_any_videos_seekable",
},
"Zoom In [ALL]": {
"title": translate("Actions", "Zoom In"),
"key": "Shift++",
"icon": "zoom-in",
"func": ("all", "scale_increase"),
"show_if": "is_any_videos_initialized",
},
"Zoom Out [ALL]": {
"title": translate("Actions", "Zoom Out"),
"key": "Shift+-",
"icon": "zoom-out",
"func": ("all", "scale_decrease"),
"show_if": "is_any_videos_initialized",
},
"Zoom Reset [ALL]": {
"title": translate("Actions", "Zoom Reset"),
"key": "Shift+*",
"icon": "zoom-reset",
"func": ("all", "scale_reset"),
"show_if": "is_any_videos_initialized",
},
"Aspect Fit [ALL]": {
"title": translate("Actions", "Aspect Fit"),
"icon": "aspect-fit",
"func": ("all", "set_aspect", VideoAspect.FIT),
"show_if": "is_any_videos_initialized",
},
"Aspect Stretch [ALL]": {
"title": translate("Actions", "Aspect Stretch"),
"icon": "aspect-stretch",
"func": ("all", "set_aspect", VideoAspect.STRETCH),
"show_if": "is_any_videos_initialized",
},
"Aspect None [ALL]": {
"title": translate("Actions", "Aspect None"),
"icon": "aspect-none",
"func": ("all", "set_aspect", VideoAspect.NONE),
"show_if": "is_any_videos_initialized",
},
"Reload [ALL]": {
"title": translate("Actions", "Reload"),
Expand Down
4 changes: 2 additions & 2 deletions gridplayer/player/managers/active_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def is_active_seekable(self):
if not self.is_active_initialized():
return False

return not self._ctx.active_block.video_driver.is_live
return not self._ctx.active_block.is_live

def is_active_live(self):
if not self.is_active_initialized():
return False

return self._ctx.active_block.video_driver.is_live
return self._ctx.active_block.is_live

def is_active_local_file(self):
if not self.is_active_initialized():
Expand Down
16 changes: 16 additions & 0 deletions gridplayer/player/managers/video_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def index(self, block):
def unpaused(self):
return [v for v in self._blocks if not v.video_params.is_paused]

@property
def initialized(self):
return [v for v in self._blocks if v.is_video_initialized]

@property
def videos(self) -> List[Video]:
return [v.video_params for v in self._blocks]
Expand Down Expand Up @@ -106,6 +110,9 @@ def commands(self):
"all_play_pause": self.cmd_all_play_pause,
"all_seek_timecode": self.cmd_seek_timecode,
"is_videos": lambda: bool(self._ctx.video_blocks),
"is_any_videos_initialized": self.is_any_videos_initialized,
"is_any_videos_seekable": self.is_any_videos_seekable,
"is_any_videos_local_file": self.is_any_videos_local_file,
"is_seek_sync_mode_set_to": self.is_seek_sync_mode_set_to,
"set_seek_sync_mode": self.set_seek_sync_mode,
"reload_all": self.reload_videos,
Expand Down Expand Up @@ -146,6 +153,15 @@ def is_seek_sync_mode_set_to(self, mode):
def set_seek_sync_mode(self, mode):
self._ctx.seek_sync_mode = mode

def is_any_videos_initialized(self):
return bool(self._ctx.video_blocks.initialized)

def is_any_videos_seekable(self):
return any(not vb.is_live for vb in self._ctx.video_blocks.initialized)

def is_any_videos_local_file(self):
return any(vb.is_local_file for vb in self._ctx.video_blocks.initialized)

def pause_all(self):
self.set_pause.emit(True)

Expand Down
2 changes: 1 addition & 1 deletion gridplayer/widgets/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def is_video_initialized(self):

@property
def is_local_file(self):
return not isinstance(self.video_params.uri, VideoURL)
return isinstance(self.video_params.uri, Path)

@property
def title(self):
Expand Down

0 comments on commit 3ea89b5

Please sign in to comment.