From 95857b4443d09156db5ac8c7a84a7f0f6bc41364 Mon Sep 17 00:00:00 2001 From: Palana Date: Sat, 27 Jun 2015 04:06:34 +0200 Subject: [PATCH] UI: Enable drag&drop reordering for scenes The empty implementation for the QDataStream operators is necessary to fix a Qt assertion: "QVariant::save: unable to save type 'std::vector >' (type id: 1036)." It doesn't seem like a full implementation of the stream operators would be useful since the signal registration is very specific to the interaction between the scenes and sources list, i.e. in case the scenes list ever accepts scenes from sources (not 'obs_source's) other than itself (non InternalMove drag&drop?) it would have to register those scenes with the libobs core which should trigger the normal signal registration --- obs/forms/OBSBasic.ui | 12 ++++++++++++ obs/qt-wrappers.cpp | 12 ++++++++++++ obs/qt-wrappers.hpp | 7 +++++++ obs/window-basic-main.cpp | 3 +++ 4 files changed, 34 insertions(+) diff --git a/obs/forms/OBSBasic.ui b/obs/forms/OBSBasic.ui index 459ad5694..42fd544ab 100644 --- a/obs/forms/OBSBasic.ui +++ b/obs/forms/OBSBasic.ui @@ -473,6 +473,18 @@ QFrame::Plain + + true + + + true + + + QAbstractItemView::InternalMove + + + Qt::IgnoreAction + diff --git a/obs/qt-wrappers.cpp b/obs/qt-wrappers.cpp index 1643c26c4..66ad29235 100644 --- a/obs/qt-wrappers.cpp +++ b/obs/qt-wrappers.cpp @@ -79,6 +79,18 @@ uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods) return obsModifiers; } +QDataStream &operator<<(QDataStream &out, + const std::vector> &) +{ + return out; +} + +QDataStream &operator>>(QDataStream &in, + std::vector> &) +{ + return in; +} + QDataStream &operator<<(QDataStream &out, const OBSScene &scene) { return out << QString(obs_source_get_name(obs_scene_get_source(scene))); diff --git a/obs/qt-wrappers.hpp b/obs/qt-wrappers.hpp index e661cd03e..925ab696e 100644 --- a/obs/qt-wrappers.hpp +++ b/obs/qt-wrappers.hpp @@ -20,6 +20,9 @@ #include #include +#include +#include + #define QT_UTF8(str) QString::fromUtf8(str) #define QT_TO_UTF8(str) str.toUtf8().constData() @@ -33,6 +36,10 @@ void QTToGSWindow(WId windowId, gs_window &gswindow); uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods); +QDataStream &operator<<(QDataStream &out, + const std::vector> &signal_vec); +QDataStream &operator>>(QDataStream &in, + std::vector> &signal_vec); QDataStream &operator<<(QDataStream &out, const OBSScene &scene); QDataStream &operator>>(QDataStream &in, OBSScene &scene); QDataStream &operator<<(QDataStream &out, const OBSSceneItem &si); diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 6528eff4a..261ef71b0 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -133,6 +133,9 @@ OBSBasic::OBSBasic(QWidget *parent) qRegisterMetaType ("OBSSource"); qRegisterMetaType("obs_hotkey_id"); + qRegisterMetaTypeStreamOperators< + std::vector>>( + "std::vector>"); qRegisterMetaTypeStreamOperators("OBSScene"); qRegisterMetaTypeStreamOperators("OBSSceneItem");