Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always four videos, drag over replaces video below #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions gridplayer/player/managers/drag_n_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
class DragNDropManager(ManagerBase):
playlist_dropped = pyqtSignal(Path)
videos_dropped = pyqtSignal(list)
close_this = pyqtSignal(str)

videos_swapped = pyqtSignal()

Expand Down Expand Up @@ -84,6 +85,12 @@ def _drop_files(self, event, drop_files):
videos = filter_video_uris(drop_files)
self.videos_dropped.emit(videos)

if len(self._ctx.video_blocks) >= 4:
if (self._ctx.active_block):
self._swap_videos(self._ctx.active_block, self._ctx.video_blocks[-1], False)
self._ctx.active_block.close(True)
self.videos_swapped.emit()

event.acceptProposedAction()

return True
Expand Down Expand Up @@ -141,7 +148,7 @@ def _get_drag_video(self):

return drag

def _swap_videos(self, src, dst):
def _swap_videos(self, src, dst, emit=True):
self._log.debug(f"Swapping {src.id} with {dst.id}")

if src == dst:
Expand All @@ -150,4 +157,5 @@ def _swap_videos(self, src, dst):

self._ctx.video_blocks.swap(dst, src)

self.videos_swapped.emit()
if emit:
self.videos_swapped.emit()
4 changes: 2 additions & 2 deletions gridplayer/player/managers/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def visible_count(self):
@property
def grid_dimensions(self):
if self.visible_count <= 1:
return GridDimensions(1, 1)
return GridDimensions(2, 2)

if self._grid_size == 0:
grid_size = math.ceil(math.sqrt(self.visible_count))
Expand All @@ -111,7 +111,7 @@ def grid_dimensions(self):
else:
cols, rows = grid_size, grid_slices

return GridDimensions(cols, rows)
return GridDimensions(2, 2)

@contextlib.contextmanager
def slow_ui_operation(self):
Expand Down
1 change: 1 addition & 0 deletions gridplayer/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, **kwargs):
("video_blocks.video_count_changed", "update_active_under_mouse")
],
"drag_n_drop": [
("close_this", "video_blocks.close_single"),
("videos_swapped", "grid.reload_video_grid"),
("videos_dropped", "video_blocks.add_videos"),
("videos_dropped", "window_state.activate_window"),
Expand Down