New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -25,15 +25,14 @@
|
|||
|
||||
static inline OBSScene GetCurrentScene()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
return main->GetCurrentScene();
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
|
||||
: tree (tree_),
|
||||
sceneitem (sceneitem_)
|
||||
: tree(tree_), sceneitem(sceneitem_)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setMouseTracking(true);
|
||||
|
|
@ -98,14 +97,12 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
|
|||
|
||||
/* --------------------------------------------------------- */
|
||||
|
||||
auto setItemVisible = [this] (bool checked)
|
||||
{
|
||||
auto setItemVisible = [this](bool checked) {
|
||||
SignalBlocker sourcesSignalBlocker(this);
|
||||
obs_sceneitem_set_visible(sceneitem, checked);
|
||||
};
|
||||
|
||||
auto setItemLocked = [this] (bool checked)
|
||||
{
|
||||
auto setItemLocked = [this](bool checked) {
|
||||
SignalBlocker sourcesSignalBlocker(this);
|
||||
obs_sceneitem_set_locked(sceneitem, checked);
|
||||
};
|
||||
|
|
@ -130,6 +127,7 @@ void SourceTreeItem::DisconnectSignals()
|
|||
itemRemoveSignal.Disconnect();
|
||||
deselectSignal.Disconnect();
|
||||
visibleSignal.Disconnect();
|
||||
lockedSignal.Disconnect();
|
||||
renameSignal.Disconnect();
|
||||
removeSignal.Disconnect();
|
||||
}
|
||||
|
|
@ -149,47 +147,58 @@ void SourceTreeItem::ReconnectSignals()
|
|||
|
||||
/* --------------------------------------------------------- */
|
||||
|
||||
auto removeItem = [] (void *data, calldata_t *cd)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto removeItem = [](void *data, calldata_t *cd) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
obs_sceneitem_t *curItem =
|
||||
(obs_sceneitem_t*)calldata_ptr(cd, "item");
|
||||
(obs_sceneitem_t *)calldata_ptr(cd, "item");
|
||||
|
||||
if (curItem == this_->sceneitem) {
|
||||
QMetaObject::invokeMethod(this_->tree,
|
||||
"Remove",
|
||||
Q_ARG(OBSSceneItem, curItem));
|
||||
QMetaObject::invokeMethod(this_->tree, "Remove",
|
||||
Q_ARG(OBSSceneItem, curItem));
|
||||
curItem = nullptr;
|
||||
}
|
||||
if (!curItem)
|
||||
QMetaObject::invokeMethod(this_, "Clear");
|
||||
};
|
||||
|
||||
auto itemVisible = [] (void *data, calldata_t *cd)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto itemVisible = [](void *data, calldata_t *cd) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
obs_sceneitem_t *curItem =
|
||||
(obs_sceneitem_t*)calldata_ptr(cd, "item");
|
||||
(obs_sceneitem_t *)calldata_ptr(cd, "item");
|
||||
bool visible = calldata_bool(cd, "visible");
|
||||
|
||||
if (curItem == this_->sceneitem)
|
||||
QMetaObject::invokeMethod(this_, "VisibilityChanged",
|
||||
Q_ARG(bool, visible));
|
||||
Q_ARG(bool, visible));
|
||||
};
|
||||
|
||||
auto itemDeselect = [] (void *data, calldata_t *cd)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto itemLocked = [](void *data, calldata_t *cd) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
obs_sceneitem_t *curItem =
|
||||
(obs_sceneitem_t*)calldata_ptr(cd, "item");
|
||||
(obs_sceneitem_t *)calldata_ptr(cd, "item");
|
||||
bool locked = calldata_bool(cd, "locked");
|
||||
|
||||
if (curItem == this_->sceneitem)
|
||||
QMetaObject::invokeMethod(this_, "LockedChanged",
|
||||
Q_ARG(bool, locked));
|
||||
};
|
||||
|
||||
auto itemDeselect = [](void *data, calldata_t *cd) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
obs_sceneitem_t *curItem =
|
||||
(obs_sceneitem_t *)calldata_ptr(cd, "item");
|
||||
|
||||
if (curItem == this_->sceneitem)
|
||||
QMetaObject::invokeMethod(this_, "Deselect");
|
||||
};
|
||||
|
||||
auto reorderGroup = [] (void *data, calldata_t*)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto reorderGroup = [](void *data, calldata_t *) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
QMetaObject::invokeMethod(this_->tree, "ReorderItems");
|
||||
};
|
||||
|
||||
|
|
@ -200,33 +209,34 @@ void SourceTreeItem::ReconnectSignals()
|
|||
sceneRemoveSignal.Connect(signal, "remove", removeItem, this);
|
||||
itemRemoveSignal.Connect(signal, "item_remove", removeItem, this);
|
||||
visibleSignal.Connect(signal, "item_visible", itemVisible, this);
|
||||
lockedSignal.Connect(signal, "item_locked", itemLocked, this);
|
||||
|
||||
if (obs_sceneitem_is_group(sceneitem)) {
|
||||
obs_source_t *source = obs_sceneitem_get_source(sceneitem);
|
||||
signal = obs_source_get_signal_handler(source);
|
||||
|
||||
groupReorderSignal.Connect(signal, "reorder", reorderGroup,
|
||||
this);
|
||||
this);
|
||||
}
|
||||
|
||||
if (scene != GetCurrentScene())
|
||||
deselectSignal.Connect(signal, "item_deselect", itemDeselect,
|
||||
this);
|
||||
this);
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
|
||||
auto renamed = [] (void *data, calldata_t *cd)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto renamed = [](void *data, calldata_t *cd) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
const char *name = calldata_string(cd, "new_name");
|
||||
|
||||
QMetaObject::invokeMethod(this_, "Renamed",
|
||||
Q_ARG(QString, QT_UTF8(name)));
|
||||
Q_ARG(QString, QT_UTF8(name)));
|
||||
};
|
||||
|
||||
auto removeSource = [] (void *data, calldata_t *)
|
||||
{
|
||||
SourceTreeItem *this_ = reinterpret_cast<SourceTreeItem*>(data);
|
||||
auto removeSource = [](void *data, calldata_t *) {
|
||||
SourceTreeItem *this_ =
|
||||
reinterpret_cast<SourceTreeItem *>(data);
|
||||
this_->DisconnectSignals();
|
||||
this_->sceneitem = nullptr;
|
||||
};
|
||||
|
|
@ -246,13 +256,34 @@ void SourceTreeItem::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
} else {
|
||||
obs_source_t *source = obs_sceneitem_get_source(sceneitem);
|
||||
OBSBasic *main =
|
||||
reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
if (source) {
|
||||
main->CreatePropertiesWindow(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SourceTreeItem::enterEvent(QEvent *event)
|
||||
{
|
||||
QWidget::enterEvent(event);
|
||||
|
||||
OBSBasicPreview *preview = OBSBasicPreview::Get();
|
||||
|
||||
std::lock_guard<std::mutex> lock(preview->selectMutex);
|
||||
preview->hoveredPreviewItems.clear();
|
||||
preview->hoveredPreviewItems.push_back(sceneitem);
|
||||
}
|
||||
|
||||
void SourceTreeItem::leaveEvent(QEvent *event)
|
||||
{
|
||||
QWidget::leaveEvent(event);
|
||||
|
||||
OBSBasicPreview *preview = OBSBasicPreview::Get();
|
||||
|
||||
std::lock_guard<std::mutex> lock(preview->selectMutex);
|
||||
preview->hoveredPreviewItems.clear();
|
||||
}
|
||||
|
||||
bool SourceTreeItem::IsEditing()
|
||||
{
|
||||
return editor != nullptr;
|
||||
|
|
@ -275,7 +306,7 @@ void SourceTreeItem::ExitEditMode(bool save)
|
|||
if (!editor)
|
||||
return;
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
std::string newName = QT_TO_UTF8(editor->text());
|
||||
|
|
@ -294,9 +325,8 @@ void SourceTreeItem::ExitEditMode(bool save)
|
|||
return;
|
||||
|
||||
if (newName.empty()) {
|
||||
OBSMessageBox::information(main,
|
||||
QTStr("NoNameEntered.Title"),
|
||||
QTStr("NoNameEntered.Text"));
|
||||
OBSMessageBox::information(main, QTStr("NoNameEntered.Title"),
|
||||
QTStr("NoNameEntered.Text"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -310,15 +340,13 @@ void SourceTreeItem::ExitEditMode(bool save)
|
|||
/* ----------------------------------------- */
|
||||
/* check for existing source */
|
||||
|
||||
obs_source_t *existingSource =
|
||||
obs_get_source_by_name(newName.c_str());
|
||||
obs_source_t *existingSource = obs_get_source_by_name(newName.c_str());
|
||||
obs_source_release(existingSource);
|
||||
bool exists = !!existingSource;
|
||||
|
||||
if (exists) {
|
||||
OBSMessageBox::information(main,
|
||||
QTStr("NameExists.Title"),
|
||||
QTStr("NameExists.Text"));
|
||||
OBSMessageBox::information(main, QTStr("NameExists.Title"),
|
||||
QTStr("NameExists.Text"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -335,28 +363,16 @@ bool SourceTreeItem::eventFilter(QObject *object, QEvent *event)
|
|||
if (editor != object)
|
||||
return false;
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
||||
switch (keyEvent->key()) {
|
||||
case Qt::Key_Escape:
|
||||
QMetaObject::invokeMethod(this, "ExitEditMode",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, false));
|
||||
return true;
|
||||
case Qt::Key_Tab:
|
||||
case Qt::Key_Backtab:
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
QMetaObject::invokeMethod(this, "ExitEditMode",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, true));
|
||||
return true;
|
||||
}
|
||||
} else if (event->type() == QEvent::FocusOut) {
|
||||
if (LineEditCanceled(event)) {
|
||||
QMetaObject::invokeMethod(this, "ExitEditMode",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, true));
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, false));
|
||||
return true;
|
||||
}
|
||||
if (LineEditChanged(event)) {
|
||||
QMetaObject::invokeMethod(this, "ExitEditMode",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(bool, true));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -368,6 +384,11 @@ void SourceTreeItem::VisibilityChanged(bool visible)
|
|||
vis->setChecked(visible);
|
||||
}
|
||||
|
||||
void SourceTreeItem::LockedChanged(bool locked)
|
||||
{
|
||||
lock->setChecked(locked);
|
||||
}
|
||||
|
||||
void SourceTreeItem::Renamed(const QString &name)
|
||||
{
|
||||
label->setText(name);
|
||||
|
|
@ -386,14 +407,14 @@ void SourceTreeItem::Update(bool force)
|
|||
if (obs_sceneitem_is_group(sceneitem)) {
|
||||
newType = Type::Group;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* if it's a group sub-item */
|
||||
/* ------------------------------------------------- */
|
||||
/* if it's a group sub-item */
|
||||
|
||||
} else if (itemScene != scene) {
|
||||
newType = Type::SubItem;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* if it's a regular item */
|
||||
/* ------------------------------------------------- */
|
||||
/* if it's a regular item */
|
||||
|
||||
} else {
|
||||
newType = Type::Item;
|
||||
|
|
@ -429,9 +450,8 @@ void SourceTreeItem::Update(bool force)
|
|||
|
||||
} else if (type == Type::Group) {
|
||||
expand = new SourceTreeSubItemCheckBox();
|
||||
expand->setSizePolicy(
|
||||
QSizePolicy::Maximum,
|
||||
QSizePolicy::Maximum);
|
||||
expand->setSizePolicy(QSizePolicy::Maximum,
|
||||
QSizePolicy::Maximum);
|
||||
expand->setMaximumSize(10, 16);
|
||||
expand->setMinimumSize(10, 0);
|
||||
#ifdef __APPLE__
|
||||
|
|
@ -439,14 +459,15 @@ void SourceTreeItem::Update(bool force)
|
|||
#endif
|
||||
boxLayout->insertWidget(0, expand);
|
||||
|
||||
obs_data_t *data = obs_sceneitem_get_private_settings(sceneitem);
|
||||
obs_data_t *data =
|
||||
obs_sceneitem_get_private_settings(sceneitem);
|
||||
expand->blockSignals(true);
|
||||
expand->setChecked(obs_data_get_bool(data, "collapsed"));
|
||||
expand->blockSignals(false);
|
||||
obs_data_release(data);
|
||||
|
||||
connect(expand, &QPushButton::toggled,
|
||||
this, &SourceTreeItem::ExpandClicked);
|
||||
connect(expand, &QPushButton::toggled, this,
|
||||
&SourceTreeItem::ExpandClicked);
|
||||
|
||||
} else {
|
||||
spacer = new QSpacerItem(3, 1);
|
||||
|
|
@ -498,10 +519,10 @@ void SourceTreeModel::Clear()
|
|||
hasGroups = false;
|
||||
}
|
||||
|
||||
static bool enumItem(obs_scene_t*, obs_sceneitem_t *item, void *ptr)
|
||||
static bool enumItem(obs_scene_t *, obs_sceneitem_t *item, void *ptr)
|
||||
{
|
||||
QVector<OBSSceneItem> &items =
|
||||
*reinterpret_cast<QVector<OBSSceneItem>*>(ptr);
|
||||
*reinterpret_cast<QVector<OBSSceneItem> *>(ptr);
|
||||
|
||||
if (obs_sceneitem_is_group(item)) {
|
||||
obs_data_t *data = obs_sceneitem_get_private_settings(item);
|
||||
|
|
@ -537,14 +558,15 @@ void SourceTreeModel::SceneChanged()
|
|||
bool select = obs_sceneitem_selected(items[i]);
|
||||
QModelIndex index = createIndex(i, 0);
|
||||
|
||||
st->selectionModel()->select(index, select
|
||||
? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect);
|
||||
st->selectionModel()->select(
|
||||
index, select ? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect);
|
||||
}
|
||||
}
|
||||
|
||||
/* moves a scene item index (blame linux distros for using older Qt builds) */
|
||||
static inline void MoveItem(QVector<OBSSceneItem> &items, int oldIdx, int newIdx)
|
||||
static inline void MoveItem(QVector<OBSSceneItem> &items, int oldIdx,
|
||||
int newIdx)
|
||||
{
|
||||
OBSSceneItem item = items[oldIdx];
|
||||
items.remove(oldIdx);
|
||||
|
|
@ -618,7 +640,7 @@ void SourceTreeModel::ReorderItems()
|
|||
|
||||
/* move items */
|
||||
beginMoveRows(QModelIndex(), idx1Old, idx1Old + count - 1,
|
||||
QModelIndex(), idx1New + count);
|
||||
QModelIndex(), idx1New + count);
|
||||
for (i = 0; i < count; i++) {
|
||||
int to = idx1New + count;
|
||||
if (to > idx1Old)
|
||||
|
|
@ -690,8 +712,7 @@ OBSSceneItem SourceTreeModel::Get(int idx)
|
|||
}
|
||||
|
||||
SourceTreeModel::SourceTreeModel(SourceTree *st_)
|
||||
: QAbstractListModel (st_),
|
||||
st (st_)
|
||||
: QAbstractListModel(st_), st(st_)
|
||||
{
|
||||
obs_frontend_add_event_callback(OBSFrontendEvent, this);
|
||||
}
|
||||
|
|
@ -725,8 +746,7 @@ Qt::ItemFlags SourceTreeModel::flags(const QModelIndex &index) const
|
|||
obs_sceneitem_t *item = items[index.row()];
|
||||
bool is_group = obs_sceneitem_is_group(item);
|
||||
|
||||
return QAbstractListModel::flags(index) |
|
||||
Qt::ItemIsEditable |
|
||||
return QAbstractListModel::flags(index) | Qt::ItemIsEditable |
|
||||
Qt::ItemIsDragEnabled |
|
||||
(is_group ? Qt::ItemIsDropEnabled : Qt::NoItemFlags);
|
||||
}
|
||||
|
|
@ -756,8 +776,8 @@ QString SourceTreeModel::GetNewGroupName()
|
|||
void SourceTreeModel::AddGroup()
|
||||
{
|
||||
QString name = GetNewGroupName();
|
||||
obs_sceneitem_t *group = obs_scene_add_group(GetCurrentScene(),
|
||||
QT_TO_UTF8(name));
|
||||
obs_sceneitem_t *group =
|
||||
obs_scene_add_group(GetCurrentScene(), QT_TO_UTF8(name));
|
||||
if (!group)
|
||||
return;
|
||||
|
||||
|
|
@ -769,7 +789,7 @@ void SourceTreeModel::AddGroup()
|
|||
UpdateGroupState(true);
|
||||
|
||||
QMetaObject::invokeMethod(st, "Edit", Qt::QueuedConnection,
|
||||
Q_ARG(int, 0));
|
||||
Q_ARG(int, 0));
|
||||
}
|
||||
|
||||
void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
||||
|
|
@ -788,8 +808,7 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
|||
}
|
||||
|
||||
obs_sceneitem_t *item = obs_scene_insert_group(
|
||||
scene, QT_TO_UTF8(name),
|
||||
item_order.data(), item_order.size());
|
||||
scene, QT_TO_UTF8(name), item_order.data(), item_order.size());
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -808,7 +827,7 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
|||
int toIdx = newIdx + i + 1;
|
||||
if (fromIdx != toIdx) {
|
||||
beginMoveRows(QModelIndex(), fromIdx, fromIdx,
|
||||
QModelIndex(), toIdx);
|
||||
QModelIndex(), toIdx);
|
||||
MoveItem(items, fromIdx, toIdx);
|
||||
endMoveRows();
|
||||
}
|
||||
|
|
@ -820,7 +839,7 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
|||
obs_sceneitem_select(item, true);
|
||||
|
||||
QMetaObject::invokeMethod(st, "Edit", Qt::QueuedConnection,
|
||||
Q_ARG(int, newIdx));
|
||||
Q_ARG(int, newIdx));
|
||||
}
|
||||
|
||||
void SourceTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
||||
|
|
@ -910,20 +929,20 @@ SourceTree::SourceTree(QWidget *parent_) : QListView(parent_)
|
|||
SourceTreeModel *stm_ = new SourceTreeModel(this);
|
||||
setModel(stm_);
|
||||
setStyleSheet(QString(
|
||||
"*[bgColor=\"1\"]{background-color:rgba(255,68,68,33%);}" \
|
||||
"*[bgColor=\"2\"]{background-color:rgba(255,255,68,33%);}" \
|
||||
"*[bgColor=\"3\"]{background-color:rgba(68,255,68,33%);}" \
|
||||
"*[bgColor=\"4\"]{background-color:rgba(68,255,255,33%);}" \
|
||||
"*[bgColor=\"5\"]{background-color:rgba(68,68,255,33%);}" \
|
||||
"*[bgColor=\"6\"]{background-color:rgba(255,68,255,33%);}" \
|
||||
"*[bgColor=\"7\"]{background-color:rgba(68,68,68,33%);}" \
|
||||
"*[bgColor=\"1\"]{background-color:rgba(255,68,68,33%);}"
|
||||
"*[bgColor=\"2\"]{background-color:rgba(255,255,68,33%);}"
|
||||
"*[bgColor=\"3\"]{background-color:rgba(68,255,68,33%);}"
|
||||
"*[bgColor=\"4\"]{background-color:rgba(68,255,255,33%);}"
|
||||
"*[bgColor=\"5\"]{background-color:rgba(68,68,255,33%);}"
|
||||
"*[bgColor=\"6\"]{background-color:rgba(255,68,255,33%);}"
|
||||
"*[bgColor=\"7\"]{background-color:rgba(68,68,68,33%);}"
|
||||
"*[bgColor=\"8\"]{background-color:rgba(255,255,255,33%);}"));
|
||||
|
||||
setMouseTracking(true);
|
||||
|
||||
UpdateNoSourcesMessage();
|
||||
connect(App(), &OBSApp::StyleChanged,
|
||||
this, &SourceTree::UpdateNoSourcesMessage);
|
||||
connect(App(), &OBSApp::StyleChanged, this,
|
||||
&SourceTree::UpdateNoSourcesMessage);
|
||||
}
|
||||
|
||||
void SourceTree::ResetWidgets()
|
||||
|
|
@ -975,9 +994,9 @@ void SourceTree::SelectItem(obs_sceneitem_t *sceneitem, bool select)
|
|||
|
||||
QModelIndex index = stm->createIndex(i, 0);
|
||||
if (index.isValid())
|
||||
selectionModel()->select(index, select
|
||||
? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect);
|
||||
selectionModel()->select(
|
||||
index, select ? QItemSelectionModel::Select
|
||||
: QItemSelectionModel::Deselect);
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OBSSceneItem);
|
||||
|
|
@ -1021,9 +1040,9 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
obs_sceneitem_t *dropItem = items[row]; /* item being dropped on */
|
||||
bool itemIsGroup = obs_sceneitem_is_group(dropItem);
|
||||
|
||||
obs_sceneitem_t *dropGroup = itemIsGroup
|
||||
? dropItem
|
||||
: obs_sceneitem_get_group(scene, dropItem);
|
||||
obs_sceneitem_t *dropGroup =
|
||||
itemIsGroup ? dropItem
|
||||
: obs_sceneitem_get_group(scene, dropItem);
|
||||
|
||||
/* not a group if moving above the group */
|
||||
if (indicator == QAbstractItemView::AboveItem && itemIsGroup)
|
||||
|
|
@ -1037,7 +1056,8 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
|
||||
bool dropOnCollapsed = false;
|
||||
if (dropGroup) {
|
||||
obs_data_t *data = obs_sceneitem_get_private_settings(dropGroup);
|
||||
obs_data_t *data =
|
||||
obs_sceneitem_get_private_settings(dropGroup);
|
||||
dropOnCollapsed = obs_data_get_bool(data, "collapsed");
|
||||
obs_data_release(data);
|
||||
}
|
||||
|
|
@ -1067,9 +1087,12 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
/* if dropping a group, detect if it's */
|
||||
/* below another group */
|
||||
|
||||
obs_sceneitem_t *itemBelow = row == stm->items.count()
|
||||
? nullptr
|
||||
: stm->items[row];
|
||||
obs_sceneitem_t *itemBelow;
|
||||
if (row == stm->items.count())
|
||||
itemBelow = nullptr;
|
||||
else
|
||||
itemBelow = stm->items[row];
|
||||
|
||||
if (hasGroups) {
|
||||
if (!itemBelow ||
|
||||
obs_sceneitem_get_group(scene, itemBelow) != dropGroup) {
|
||||
|
|
@ -1112,8 +1135,8 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
for (int j = items.size() - 1; j >= 0; j--) {
|
||||
obs_sceneitem_t *subitem = items[j];
|
||||
obs_sceneitem_t *subitemGroup =
|
||||
obs_sceneitem_get_group(scene,
|
||||
subitem);
|
||||
obs_sceneitem_get_group(
|
||||
scene, subitem);
|
||||
|
||||
if (subitemGroup == item) {
|
||||
QModelIndex idx =
|
||||
|
|
@ -1148,7 +1171,7 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
|
||||
if (itemTo != from) {
|
||||
stm->beginMoveRows(QModelIndex(), from, from,
|
||||
QModelIndex(), to);
|
||||
QModelIndex(), to);
|
||||
MoveItem(items, from, itemTo);
|
||||
stm->endMoveRows();
|
||||
}
|
||||
|
|
@ -1167,8 +1190,7 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
obs_sceneitem_t *lastGroup = nullptr;
|
||||
int insertCollapsedIdx = 0;
|
||||
|
||||
auto insertCollapsed = [&] (obs_sceneitem_t *item)
|
||||
{
|
||||
auto insertCollapsed = [&](obs_sceneitem_t *item) {
|
||||
struct obs_sceneitem_order_info info;
|
||||
info.group = lastGroup;
|
||||
info.item = item;
|
||||
|
|
@ -1178,25 +1200,23 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
|
||||
using insertCollapsed_t = decltype(insertCollapsed);
|
||||
|
||||
auto preInsertCollapsed = [] (obs_scene_t *, obs_sceneitem_t *item,
|
||||
void *param)
|
||||
{
|
||||
auto preInsertCollapsed = [](obs_scene_t *, obs_sceneitem_t *item,
|
||||
void *param) {
|
||||
(*reinterpret_cast<insertCollapsed_t *>(param))(item);
|
||||
return true;
|
||||
};
|
||||
|
||||
auto insertLastGroup = [&] ()
|
||||
{
|
||||
obs_data_t *data = obs_sceneitem_get_private_settings(lastGroup);
|
||||
auto insertLastGroup = [&]() {
|
||||
obs_data_t *data =
|
||||
obs_sceneitem_get_private_settings(lastGroup);
|
||||
bool collapsed = obs_data_get_bool(data, "collapsed");
|
||||
obs_data_release(data);
|
||||
|
||||
if (collapsed) {
|
||||
insertCollapsedIdx = 0;
|
||||
obs_sceneitem_group_enum_items(
|
||||
lastGroup,
|
||||
preInsertCollapsed,
|
||||
&insertCollapsed);
|
||||
obs_sceneitem_group_enum_items(lastGroup,
|
||||
preInsertCollapsed,
|
||||
&insertCollapsed);
|
||||
}
|
||||
|
||||
struct obs_sceneitem_order_info info;
|
||||
|
|
@ -1205,8 +1225,7 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
orderList.insert(0, info);
|
||||
};
|
||||
|
||||
auto updateScene = [&] ()
|
||||
{
|
||||
auto updateScene = [&]() {
|
||||
struct obs_sceneitem_order_info info;
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
|
@ -1241,14 +1260,13 @@ void SourceTree::dropEvent(QDropEvent *event)
|
|||
insertLastGroup();
|
||||
}
|
||||
|
||||
obs_scene_reorder_items2(scene,
|
||||
orderList.data(), orderList.size());
|
||||
obs_scene_reorder_items2(scene, orderList.data(),
|
||||
orderList.size());
|
||||
};
|
||||
|
||||
using updateScene_t = decltype(updateScene);
|
||||
|
||||
auto preUpdateScene = [] (void *data, obs_scene_t *)
|
||||
{
|
||||
auto preUpdateScene = [](void *data, obs_scene_t *) {
|
||||
(*reinterpret_cast<updateScene_t *>(data))();
|
||||
};
|
||||
|
||||
|
|
@ -1283,21 +1301,27 @@ void SourceTree::mouseMoveEvent(QMouseEvent *event)
|
|||
SourceTreeItem *item = qobject_cast<SourceTreeItem *>(childAt(pos));
|
||||
|
||||
OBSBasicPreview *preview = OBSBasicPreview::Get();
|
||||
preview->hoveredListItem = !!item ? item->sceneitem : nullptr;
|
||||
|
||||
QListView::mouseMoveEvent(event);
|
||||
|
||||
std::lock_guard<std::mutex> lock(preview->selectMutex);
|
||||
preview->hoveredPreviewItems.clear();
|
||||
if (item)
|
||||
preview->hoveredPreviewItems.push_back(item->sceneitem);
|
||||
}
|
||||
|
||||
void SourceTree::leaveEvent(QEvent *event)
|
||||
{
|
||||
OBSBasicPreview *preview = OBSBasicPreview::Get();
|
||||
preview->hoveredListItem = nullptr;
|
||||
|
||||
QListView::leaveEvent(event);
|
||||
|
||||
std::lock_guard<std::mutex> lock(preview->selectMutex);
|
||||
preview->hoveredPreviewItems.clear();
|
||||
}
|
||||
|
||||
void SourceTree::selectionChanged(
|
||||
const QItemSelection &selected,
|
||||
const QItemSelection &deselected)
|
||||
void SourceTree::selectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected)
|
||||
{
|
||||
{
|
||||
SignalBlocker sourcesSignalBlocker(this);
|
||||
|
|
@ -1406,7 +1430,7 @@ bool SourceTree::GroupedItemsSelected() const
|
|||
|
||||
void SourceTree::Remove(OBSSceneItem item)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
GetStm()->Remove(item);
|
||||
main->SaveProject();
|
||||
|
||||
|
|
@ -1415,9 +1439,9 @@ void SourceTree::Remove(OBSSceneItem item)
|
|||
obs_source_t *sceneSource = obs_scene_get_source(scene);
|
||||
obs_source_t *itemSource = obs_sceneitem_get_source(item);
|
||||
blog(LOG_INFO, "User Removed source '%s' (%s) from scene '%s'",
|
||||
obs_source_get_name(itemSource),
|
||||
obs_source_get_id(itemSource),
|
||||
obs_source_get_name(sceneSource));
|
||||
obs_source_get_name(itemSource),
|
||||
obs_source_get_id(itemSource),
|
||||
obs_source_get_name(sceneSource));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1446,9 +1470,8 @@ void SourceTree::UpdateNoSourcesMessage()
|
|||
|
||||
QColor color = palette().text().color();
|
||||
bool lightTheme = (color.redF() < 0.5);
|
||||
QString file = lightTheme
|
||||
? ":res/images/no_sources.svg"
|
||||
: darkPath.c_str();
|
||||
QString file = lightTheme ? ":res/images/no_sources.svg"
|
||||
: darkPath.c_str();
|
||||
iconNoSources.load(file);
|
||||
|
||||
QTextOption opt(Qt::AlignHCenter);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue