Display all scene items when selecting "current scene"

This commit is contained in:
WarmUpTill 2021-06-22 20:56:13 +02:00 committed by WarmUpTill
parent 034a1b0c93
commit efef29603b
3 changed files with 38 additions and 4 deletions

View File

@ -12,6 +12,8 @@
#include <unordered_map>
#include "scene-group.hpp"
class SceneSelection;
bool WeakSourceValid(obs_weak_source_t *ws);
std::string GetWeakSourceName(obs_weak_source_t *weak_source);
OBSWeakSource GetWeakSourceByName(const char *name);
@ -74,3 +76,4 @@ void populateFilterSelection(QComboBox *list,
OBSWeakSource weakSource = nullptr);
void populateSceneItemSelection(QComboBox *list,
OBSWeakSource sceneWeakSource = nullptr);
void populateSceneItemSelection(QComboBox *list, SceneSelection &s);

View File

@ -149,8 +149,7 @@ void MacroActionSceneVisibilityEdit::UpdateEntryData()
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
_scenes->SetScene(_entryData->_scene);
populateSceneItemSelection(_sources,
_entryData->_scene.GetScene(false));
populateSceneItemSelection(_sources, _entryData->_scene);
_sources->setCurrentText(
GetWeakSourceName(_entryData->_source).c_str());
}
@ -165,8 +164,7 @@ void MacroActionSceneVisibilityEdit::SceneChanged(const SceneSelection &s)
_entryData->_scene = s;
}
_sources->clear();
populateSceneItemSelection(_sources,
_entryData->_scene.GetScene(false));
populateSceneItemSelection(_sources, _entryData->_scene);
}
void MacroActionSceneVisibilityEdit::SourceChanged(const QString &text)

View File

@ -1,5 +1,6 @@
#include "headers/utility.hpp"
#include "headers/platform-funcs.hpp"
#include "headers/scene-selection.hpp"
#include <QTextStream>
#include <QLabel>
@ -666,6 +667,38 @@ void populateSceneItemSelection(QComboBox *list, OBSWeakSource sceneWeakSource)
list->setCurrentIndex(0);
}
void populateSceneItemSelection(QComboBox *list, SceneSelection &s)
{
std::set<QString> names;
if (s.GetType() == SceneSelectionType::CURRENT) {
auto enumScenes = [](void *param, obs_source_t *source) {
if (!source) {
return true;
}
std::set<QString> *names =
reinterpret_cast<std::set<QString> *>(param);
auto scene = obs_scene_from_source(source);
obs_scene_enum_items(scene, enumSceneItem, names);
return true;
};
obs_enum_scenes(enumScenes, &names);
} else {
auto source = obs_weak_source_get_source(s.GetScene(false));
auto scene = obs_scene_from_source(source);
obs_scene_enum_items(scene, enumSceneItem, &names);
obs_source_release(source);
}
for (auto &name : names) {
list->addItem(name);
}
list->model()->sort(0);
addSelectionEntry(list, obs_module_text("AdvSceneSwitcher.selectItem"));
list->setCurrentIndex(0);
}
QMetaObject::Connection PulseWidget(QWidget *widget, QColor endColor,
QColor startColor, QString specifier)
{