Propagate preview window selection to sources list

master
Palana 2014-10-13 22:14:06 +02:00
parent 3dc1b7f3d5
commit cf3ca1d5fc
2 changed files with 61 additions and 0 deletions

View File

@ -709,6 +709,10 @@ void OBSBasic::AddScene(OBSSource source)
OBSBasic::SceneItemAdded, this); OBSBasic::SceneItemAdded, this);
signal_handler_connect(handler, "item_remove", signal_handler_connect(handler, "item_remove",
OBSBasic::SceneItemRemoved, this); OBSBasic::SceneItemRemoved, this);
signal_handler_connect(handler, "item_select",
OBSBasic::SceneItemSelected, this);
signal_handler_connect(handler, "item_deselect",
OBSBasic::SceneItemDeselected, this);
signal_handler_connect(handler, "item_move_up", signal_handler_connect(handler, "item_move_up",
OBSBasic::SceneItemMoveUp, this); OBSBasic::SceneItemMoveUp, this);
signal_handler_connect(handler, "item_move_down", signal_handler_connect(handler, "item_move_down",
@ -815,6 +819,36 @@ void OBSBasic::RenameSources(QString newName, QString prevName)
} }
} }
void OBSBasic::SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select)
{
if (scene != GetCurrentScene())
return;
for (int i = 0; i < ui->sources->count(); i++) {
QListWidgetItem *witem = ui->sources->item(i);
QVariant data = witem->data(Qt::UserRole);
if (!data.canConvert<OBSSceneItem>())
continue;
if (item != data.value<OBSSceneItem>())
continue;
if (select && witem->isSelected())
break;
if (!select && !witem->isSelected())
break;
QItemSelectionModel::SelectionFlags model = select ?
QItemSelectionModel::Select :
QItemSelectionModel::Deselect;
model |= QItemSelectionModel::Current;
ui->sources->setCurrentItem(witem, model);
break;
}
}
void OBSBasic::MoveSceneItem(OBSSceneItem item, obs_order_movement movement) void OBSBasic::MoveSceneItem(OBSSceneItem item, obs_order_movement movement)
{ {
OBSScene scene = obs_sceneitem_get_scene(item); OBSScene scene = obs_sceneitem_get_scene(item);
@ -1057,6 +1091,30 @@ void OBSBasic::SceneItemRemoved(void *data, calldata_t *params)
Q_ARG(OBSSceneItem, OBSSceneItem(item))); Q_ARG(OBSSceneItem, OBSSceneItem(item)));
} }
void OBSBasic::SceneItemSelected(void *data, calldata_t *params)
{
OBSBasic *window = static_cast<OBSBasic*>(data);
obs_scene_t *scene = (obs_scene_t*)calldata_ptr(params, "scene");
obs_sceneitem_t *item = (obs_sceneitem_t*)calldata_ptr(params, "item");
QMetaObject::invokeMethod(window, "SelectSceneItem",
Q_ARG(OBSScene, scene), Q_ARG(OBSSceneItem, item),
Q_ARG(bool, true));
}
void OBSBasic::SceneItemDeselected(void *data, calldata_t *params)
{
OBSBasic *window = static_cast<OBSBasic*>(data);
obs_scene_t *scene = (obs_scene_t*)calldata_ptr(params, "scene");
obs_sceneitem_t *item = (obs_sceneitem_t*)calldata_ptr(params, "item");
QMetaObject::invokeMethod(window, "SelectSceneItem",
Q_ARG(OBSScene, scene), Q_ARG(OBSSceneItem, item),
Q_ARG(bool, false));
}
void OBSBasic::SourceAdded(void *data, calldata_t *params) void OBSBasic::SourceAdded(void *data, calldata_t *params)
{ {
OBSBasic *window = static_cast<OBSBasic*>(data); OBSBasic *window = static_cast<OBSBasic*>(data);

View File

@ -161,6 +161,7 @@ private slots:
void UpdateSceneSelection(OBSSource source); void UpdateSceneSelection(OBSSource source);
void RenameSources(QString newName, QString prevName); void RenameSources(QString newName, QString prevName);
void SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select);
void MoveSceneItem(OBSSceneItem item, obs_order_movement movement); void MoveSceneItem(OBSSceneItem item, obs_order_movement movement);
void ActivateAudioSource(OBSSource source); void ActivateAudioSource(OBSSource source);
@ -173,6 +174,8 @@ private:
/* OBS Callbacks */ /* OBS Callbacks */
static void SceneItemAdded(void *data, calldata_t *params); static void SceneItemAdded(void *data, calldata_t *params);
static void SceneItemRemoved(void *data, calldata_t *params); static void SceneItemRemoved(void *data, calldata_t *params);
static void SceneItemSelected(void *data, calldata_t *params);
static void SceneItemDeselected(void *data, calldata_t *params);
static void SourceAdded(void *data, calldata_t *params); static void SourceAdded(void *data, calldata_t *params);
static void SourceRemoved(void *data, calldata_t *params); static void SourceRemoved(void *data, calldata_t *params);
static void SourceActivated(void *data, calldata_t *params); static void SourceActivated(void *data, calldata_t *params);