From f580de0bc761415a07f0e613b8d53020447dc01d Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Fri, 21 Aug 2020 03:39:42 -0500 Subject: [PATCH] UI: Fix multiview update regression Fixes bug where multiview won't update when reordering scenes with drag and drop. Was originally fixed with #2114, but bcddf4d caused a regression where it didn't work anymore. --- UI/scene-tree.cpp | 8 +++++++- UI/scene-tree.hpp | 3 +++ UI/window-basic-main.cpp | 16 +++------------- UI/window-basic-main.hpp | 3 +-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/UI/scene-tree.cpp b/UI/scene-tree.cpp index 801e83cfa..86fedaf39 100644 --- a/UI/scene-tree.cpp +++ b/UI/scene-tree.cpp @@ -106,7 +106,11 @@ void SceneTree::startDrag(Qt::DropActions supportedActions) void SceneTree::dropEvent(QDropEvent *event) { QListWidget::dropEvent(event); - if (event->source() == this && gridMode) { + + if (event->source() != this) + return; + + if (gridMode) { int scrollWid = verticalScrollBar()->sizeHint().width(); int h = visualItemRect(item(count() - 1)).bottom(); @@ -131,6 +135,8 @@ void SceneTree::dropEvent(QDropEvent *event) setCurrentItem(item); resize(size()); } + + emit scenesReordered(); } void SceneTree::dragMoveEvent(QDragMoveEvent *event) diff --git a/UI/scene-tree.hpp b/UI/scene-tree.hpp index 4b04dda54..99090ebc7 100644 --- a/UI/scene-tree.hpp +++ b/UI/scene-tree.hpp @@ -34,4 +34,7 @@ protected: virtual void dragMoveEvent(QDragMoveEvent *event) override; virtual void rowsInserted(const QModelIndex &parent, int start, int end) override; + +signals: + void scenesReordered(); }; diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index c03930860..b9fa4c52e 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -408,11 +408,8 @@ OBSBasic::OBSBasic(QWidget *parent) connect(ui->enablePreviewButton, SIGNAL(clicked()), this, SLOT(TogglePreview())); - connect(ui->scenes->model(), - SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), - this, - SLOT(ScenesReordered(const QModelIndex &, int, int, - const QModelIndex &, int))); + connect(ui->scenes, SIGNAL(scenesReordered()), this, + SLOT(ScenesReordered())); } static void SaveAudioDevice(const char *name, int channel, obs_data_t *parent, @@ -8232,15 +8229,8 @@ void OBSBasic::CheckDiskSpaceRemaining() } } -void OBSBasic::ScenesReordered(const QModelIndex &parent, int start, int end, - const QModelIndex &destination, int row) +void OBSBasic::ScenesReordered() { - UNUSED_PARAMETER(parent); - UNUSED_PARAMETER(start); - UNUSED_PARAMETER(end); - UNUSED_PARAMETER(destination); - UNUSED_PARAMETER(row); - OBSProjector::UpdateMultiviewProjectors(); } diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index e6d4db6d1..e8682b451 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -662,8 +662,7 @@ private slots: void CheckDiskSpaceRemaining(); void OpenSavedProjector(SavedProjectorInfo *info); - void ScenesReordered(const QModelIndex &parent, int start, int end, - const QModelIndex &destination, int row); + void ScenesReordered(); void ResetStatsHotkey();