Skip to content
Closed
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 @@ -19,6 +19,7 @@
class DragNDropManager(ManagerBase):
playlist_dropped = pyqtSignal(Path)
videos_dropped = pyqtSignal(list)
close_this = pyqtSignal(str)

videos_swapped = pyqtSignal()

Expand Down Expand Up @@ -185,6 +186,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 @@ -285,7 +292,7 @@ def _make_qdrag(self, block):
drag.setMimeData(mime_data)
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 @@ -294,4 +301,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_swapped", "active_block.update_active_under_mouse"),
("videos_dropped", "video_blocks.add_videos"),
Expand Down