From 29b2f11e7adddd8687badf8aba62176e6d9ee29f Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Tue, 19 May 2020 00:07:14 -0500 Subject: [PATCH] UI: Allow drag & drop reorder of property lists --- UI/properties-view.cpp | 20 ++++++++++++++++++++ UI/properties-view.hpp | 2 ++ 2 files changed, 22 insertions(+) diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index 6115c9297..c86851540 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -594,6 +594,13 @@ void OBSPropertiesView::AddEditableList(obs_property_t *prop, WidgetInfo *info = new WidgetInfo(this, prop, list); + list->setDragDropMode(QAbstractItemView::InternalMove); + connect(list->model(), + SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), + info, + SLOT(EditListReordered(const QModelIndex &, int, int, + const QModelIndex &, int))); + QVBoxLayout *sideLayout = new QVBoxLayout(); NewButton(sideLayout, info, "addIconSmall", &WidgetInfo::EditListAdd); NewButton(sideLayout, info, "removeIconSmall", @@ -1774,6 +1781,19 @@ void WidgetInfo::GroupChanged(const char *setting) : true); } +void WidgetInfo::EditListReordered(const QModelIndex &parent, int start, + int end, const QModelIndex &destination, + int row) +{ + UNUSED_PARAMETER(parent); + UNUSED_PARAMETER(start); + UNUSED_PARAMETER(end); + UNUSED_PARAMETER(destination); + UNUSED_PARAMETER(row); + + EditableListChanged(); +} + void WidgetInfo::EditableListChanged() { const char *setting = obs_property_name(property); diff --git a/UI/properties-view.hpp b/UI/properties-view.hpp index 892c454f0..169c9377e 100644 --- a/UI/properties-view.hpp +++ b/UI/properties-view.hpp @@ -58,6 +58,8 @@ public slots: void EditListEdit(); void EditListUp(); void EditListDown(); + void EditListReordered(const QModelIndex &parent, int start, int end, + const QModelIndex &destination, int row); }; /* ------------------------------------------------------------------------- */