mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-15 07:44:10 +00:00
libobs,UI: Issue appropriate signals on group / ungroup
Due to the way the frontend works, the logic for inserting the row for the group in the UI was dropped since the new item_add message will insert one automatically since it forces a refresh of the scene items. The reliance on that implicit row insertion when grouping items is a bit of a code smell, although the alternative would be to add logic to disable handling the signal for that instant, which is probably a worse choice.
This commit is contained in:
parent
f482111791
commit
961b75b58c
|
@ -967,28 +967,17 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
|||
for (obs_sceneitem_t *item : item_order)
|
||||
obs_sceneitem_select(item, false);
|
||||
|
||||
int newIdx = indices[0].row();
|
||||
|
||||
beginInsertRows(QModelIndex(), newIdx, newIdx);
|
||||
items.insert(newIdx, item);
|
||||
endInsertRows();
|
||||
|
||||
for (int i = 0; i < indices.size(); i++) {
|
||||
int fromIdx = indices[i].row() + 1;
|
||||
int toIdx = newIdx + i + 1;
|
||||
if (fromIdx != toIdx) {
|
||||
beginMoveRows(QModelIndex(), fromIdx, fromIdx,
|
||||
QModelIndex(), toIdx);
|
||||
MoveItem(items, fromIdx, toIdx);
|
||||
endMoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
hasGroups = true;
|
||||
st->UpdateWidgets(true);
|
||||
|
||||
obs_sceneitem_select(item, true);
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* obs_scene_insert_group triggers a full refresh of scene items via */
|
||||
/* the item_add signal. No need to insert a row, just edit the one */
|
||||
/* that's created automatically. */
|
||||
|
||||
int newIdx = indices[0].row();
|
||||
QMetaObject::invokeMethod(st, "NewGroupEdit", Qt::QueuedConnection,
|
||||
Q_ARG(int, newIdx));
|
||||
}
|
||||
|
|
|
@ -3332,6 +3332,15 @@ obs_sceneitem_t *obs_scene_insert_group(obs_scene_t *scene, const char *name,
|
|||
full_unlock(sub_scene);
|
||||
full_unlock(scene);
|
||||
|
||||
struct calldata params;
|
||||
uint8_t stack[128];
|
||||
|
||||
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
||||
calldata_set_ptr(¶ms, "scene", scene);
|
||||
calldata_set_ptr(¶ms, "item", item);
|
||||
signal_handler_signal(scene->source->context.signals, "item_add",
|
||||
¶ms);
|
||||
|
||||
/* ------------------------- */
|
||||
|
||||
return item;
|
||||
|
@ -3397,6 +3406,8 @@ void obs_sceneitem_group_ungroup(obs_sceneitem_t *item)
|
|||
obs_sceneitem_t *first;
|
||||
obs_sceneitem_t *last;
|
||||
|
||||
signal_item_remove(item);
|
||||
|
||||
full_lock(scene);
|
||||
|
||||
/* ------------------------- */
|
||||
|
|
Loading…
Reference in a new issue