mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Set "select <xyz>" to disabled and sort selection alphabetically
This commit is contained in:
parent
546a83ee07
commit
5c4dd6dae1
|
|
@ -81,10 +81,11 @@ static inline void populateFilters(QComboBox *list,
|
|||
list->addItem(name);
|
||||
};
|
||||
|
||||
list->clear();
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.selectFilter"));
|
||||
auto s = obs_weak_source_get_source(weakSource);
|
||||
obs_source_enum_filters(s, enumFilters, list);
|
||||
list->model()->sort(0);
|
||||
addSelectionEntry(list,
|
||||
obs_module_text("AdvSceneSwitcher.selectFilter"));
|
||||
obs_source_release(s);
|
||||
}
|
||||
|
||||
|
|
@ -112,10 +113,10 @@ static inline void populateSourcesWithFilter(QComboBox *list)
|
|||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
list->clear();
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.selectSource"));
|
||||
obs_enum_sources(enumSourcesWithFilters, list);
|
||||
list->model()->sort(0);
|
||||
addSelectionEntry(list,
|
||||
obs_module_text("AdvSceneSwitcher.selectSource"));
|
||||
}
|
||||
|
||||
MacroActionFilterEdit::MacroActionFilterEdit(
|
||||
|
|
@ -174,6 +175,7 @@ void MacroActionFilterEdit::SourceChanged(const QString &text)
|
|||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_source = GetWeakSourceByQString(text);
|
||||
}
|
||||
_filters->clear();
|
||||
populateFilters(_filters, _entryData->_source);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,8 +117,6 @@ static bool enumItem(obs_scene_t *, obs_sceneitem_t *item, void *ptr)
|
|||
static inline void populateSceneItems(QComboBox *list,
|
||||
OBSWeakSource sceneWeakSource = nullptr)
|
||||
{
|
||||
list->clear();
|
||||
list->addItem(obs_module_text("AdvSceneSwitcher.selectItem"));
|
||||
std::set<QString> names;
|
||||
auto s = obs_weak_source_get_source(sceneWeakSource);
|
||||
auto scene = obs_scene_from_source(s);
|
||||
|
|
@ -128,6 +126,8 @@ static inline void populateSceneItems(QComboBox *list,
|
|||
for (auto &name : names) {
|
||||
list->addItem(name);
|
||||
}
|
||||
list->model()->sort(0);
|
||||
addSelectionEntry(list, obs_module_text("AdvSceneSwitcher.selectItem"));
|
||||
}
|
||||
|
||||
MacroActionSceneVisibilityEdit::MacroActionSceneVisibilityEdit(
|
||||
|
|
@ -186,6 +186,7 @@ void MacroActionSceneVisibilityEdit::SceneChanged(const QString &text)
|
|||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_scene = GetWeakSourceByQString(text);
|
||||
}
|
||||
_sources->clear();
|
||||
populateSceneItems(_sources, _entryData->_scene);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,20 @@
|
|||
#include "headers/macro-selection.hpp"
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
MacroSelection::MacroSelection(QWidget *parent) : QComboBox(parent)
|
||||
{
|
||||
addItem(obs_module_text("AdvSceneSwitcher.selectMacro"));
|
||||
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(this->model());
|
||||
QModelIndex firstIndex =
|
||||
model->index(0, modelColumn(), rootModelIndex());
|
||||
QStandardItem *firstItem = model->itemFromIndex(firstIndex);
|
||||
firstItem->setSelectable(false);
|
||||
firstItem->setEnabled(false);
|
||||
|
||||
for (auto &m : switcher->macros) {
|
||||
addItem(QString::fromStdString(m.Name()));
|
||||
}
|
||||
|
|
|
|||
134
src/utility.cpp
134
src/utility.cpp
|
|
@ -232,7 +232,7 @@ bool DisplayMessage(const QString &msg, bool question)
|
|||
void addSelectionEntry(QComboBox *sel, const char *description, bool selectable,
|
||||
const char *tooltip)
|
||||
{
|
||||
sel->addItem(description);
|
||||
sel->insertItem(0, description);
|
||||
|
||||
if (strcmp(tooltip, "") != 0) {
|
||||
sel->setItemData(0, tooltip, Qt::ToolTipRole);
|
||||
|
|
@ -260,31 +260,19 @@ void populateSourceSelection(QComboBox *list, bool addSelect)
|
|||
return true;
|
||||
};
|
||||
|
||||
list->clear();
|
||||
obs_enum_sources(enumSourcesWithSources, list);
|
||||
|
||||
list->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
list, obs_module_text("AdvSceneSwitcher.selectSource"),
|
||||
false);
|
||||
}
|
||||
|
||||
obs_enum_sources(enumSourcesWithSources, list);
|
||||
list->model()->sort(0);
|
||||
}
|
||||
|
||||
void populateTransitionSelection(QComboBox *sel, bool addCurrent,
|
||||
bool addSelect, bool selectable)
|
||||
{
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectTransition"),
|
||||
selectable);
|
||||
}
|
||||
|
||||
if (addCurrent) {
|
||||
sel->addItem(
|
||||
obs_module_text("AdvSceneSwitcher.currentTransition"));
|
||||
}
|
||||
|
||||
obs_frontend_source_list *transitions = new obs_frontend_source_list();
|
||||
obs_frontend_get_transitions(transitions);
|
||||
|
|
@ -296,23 +284,38 @@ void populateTransitionSelection(QComboBox *sel, bool addCurrent,
|
|||
}
|
||||
|
||||
obs_frontend_source_list_free(transitions);
|
||||
|
||||
sel->model()->sort(0);
|
||||
|
||||
if (addCurrent) {
|
||||
sel->insertItem(
|
||||
0,
|
||||
obs_module_text("AdvSceneSwitcher.currentTransition"));
|
||||
}
|
||||
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectTransition"),
|
||||
selectable);
|
||||
}
|
||||
}
|
||||
|
||||
void populateWindowSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel, obs_module_text("AdvSceneSwitcher.selectWindow"));
|
||||
}
|
||||
|
||||
std::vector<std::string> windows;
|
||||
GetWindowList(windows);
|
||||
sort(windows.begin(), windows.end());
|
||||
|
||||
for (std::string &window : windows) {
|
||||
sel->addItem(window.c_str());
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel, obs_module_text("AdvSceneSwitcher.selectWindow"));
|
||||
}
|
||||
#ifdef WIN32
|
||||
sel->setItemData(0, obs_module_text("AdvSceneSwitcher.selectWindowTip"),
|
||||
Qt::ToolTipRole);
|
||||
|
|
@ -321,14 +324,6 @@ void populateWindowSelection(QComboBox *sel, bool addSelect)
|
|||
|
||||
void populateAudioSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectAudioSource"),
|
||||
false,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
}
|
||||
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
|
|
@ -344,22 +339,24 @@ void populateAudioSelection(QComboBox *sel, bool addSelect)
|
|||
|
||||
std::vector<std::string> audioSources;
|
||||
obs_enum_sources(sourceEnum, &audioSources);
|
||||
sort(audioSources.begin(), audioSources.end());
|
||||
|
||||
for (std::string &source : audioSources) {
|
||||
sel->addItem(source.c_str());
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectAudioSource"),
|
||||
false,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
}
|
||||
}
|
||||
|
||||
void populateVideoSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectVideoSource"),
|
||||
false,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
}
|
||||
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
|
|
@ -379,19 +376,20 @@ void populateVideoSelection(QComboBox *sel, bool addSelect)
|
|||
for (std::string &source : videoSources) {
|
||||
sel->addItem(source.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void populateMediaSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectMediaSource"),
|
||||
obs_module_text("AdvSceneSwitcher.selectVideoSource"),
|
||||
false,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
}
|
||||
}
|
||||
|
||||
void populateMediaSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
std::vector<std::string> *list =
|
||||
|
|
@ -406,24 +404,35 @@ void populateMediaSelection(QComboBox *sel, bool addSelect)
|
|||
|
||||
std::vector<std::string> mediaSources;
|
||||
obs_enum_sources(sourceEnum, &mediaSources);
|
||||
sort(mediaSources.begin(), mediaSources.end());
|
||||
for (std::string &source : mediaSources) {
|
||||
sel->addItem(source.c_str());
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectMediaSource"),
|
||||
false,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
}
|
||||
}
|
||||
|
||||
void populateProcessSelection(QComboBox *sel, bool addSelect)
|
||||
{
|
||||
QStringList processes;
|
||||
GetProcessList(processes);
|
||||
processes.sort();
|
||||
for (QString &process : processes) {
|
||||
sel->addItem(process);
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
addSelectionEntry(
|
||||
sel, obs_module_text("AdvSceneSwitcher.selectProcess"));
|
||||
}
|
||||
|
||||
QStringList processes;
|
||||
GetProcessList(processes);
|
||||
processes.sort();
|
||||
for (QString &process : processes)
|
||||
sel->addItem(process);
|
||||
}
|
||||
|
||||
void populateSceneSelection(QComboBox *sel, bool addPrevious,
|
||||
|
|
@ -431,19 +440,6 @@ void populateSceneSelection(QComboBox *sel, bool addPrevious,
|
|||
std::deque<SceneGroup> *sceneGroups, bool addSelect,
|
||||
std::string selectText, bool selectable)
|
||||
{
|
||||
if (addSelect) {
|
||||
if (selectText.empty()) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectScene"),
|
||||
selectable,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
} else {
|
||||
addSelectionEntry(sel, selectText.c_str(), selectable);
|
||||
}
|
||||
}
|
||||
|
||||
BPtr<char *> scenes = obs_frontend_get_scene_names();
|
||||
char **temp = scenes;
|
||||
while (*temp) {
|
||||
|
|
@ -462,6 +458,20 @@ void populateSceneSelection(QComboBox *sel, bool addPrevious,
|
|||
sel->addItem(QString::fromStdString(sg.name));
|
||||
}
|
||||
}
|
||||
|
||||
sel->model()->sort(0);
|
||||
if (addSelect) {
|
||||
if (selectText.empty()) {
|
||||
addSelectionEntry(
|
||||
sel,
|
||||
obs_module_text("AdvSceneSwitcher.selectScene"),
|
||||
selectable,
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.invaildEntriesWillNotBeSaved"));
|
||||
} else {
|
||||
addSelectionEntry(sel, selectText.c_str(), selectable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMetaObject::Connection PulseWidget(QWidget *widget, QColor endColor,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user