mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
UI: Make scene items serializable via QDataStream
This minimal implementation should be enough to drag&drop scenes between UI elements in the same process in the future
This commit is contained in:
parent
363b887cad
commit
b543ea6231
@ -95,3 +95,29 @@ QDataStream &operator>>(QDataStream &in, OBSScene &scene)
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const OBSSceneItem &si)
|
||||
{
|
||||
obs_scene_t *scene = obs_sceneitem_get_scene(si);
|
||||
obs_source_t *source = obs_sceneitem_get_source(si);
|
||||
return out << QString(obs_source_get_name(obs_scene_get_source(scene)))
|
||||
<< QString(obs_source_get_name(source));
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, OBSSceneItem &si)
|
||||
{
|
||||
QString sceneName;
|
||||
QString sourceName;
|
||||
|
||||
in >> sceneName >> sourceName;
|
||||
|
||||
obs_source_t *sceneSource =
|
||||
obs_get_source_by_name(QT_TO_UTF8(sceneName));
|
||||
|
||||
obs_scene_t *scene = obs_scene_from_source(sceneSource);
|
||||
si = obs_scene_find_source(scene, QT_TO_UTF8(sourceName));
|
||||
|
||||
obs_source_release(sceneSource);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -35,3 +35,5 @@ uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods);
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const OBSScene &scene);
|
||||
QDataStream &operator>>(QDataStream &in, OBSScene &scene);
|
||||
QDataStream &operator<<(QDataStream &out, const OBSSceneItem &si);
|
||||
QDataStream &operator>>(QDataStream &in, OBSSceneItem &si);
|
||||
|
@ -134,6 +134,7 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
qRegisterMetaType<obs_hotkey_id>("obs_hotkey_id");
|
||||
|
||||
qRegisterMetaTypeStreamOperators<OBSScene>("OBSScene");
|
||||
qRegisterMetaTypeStreamOperators<OBSSceneItem>("OBSSceneItem");
|
||||
|
||||
ui->scenes->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
ui->sources->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
|
Loading…
Reference in New Issue
Block a user