mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-15 13:53:19 -05:00
Do not allow duplicates in condtion and action type selection
This commit is contained in:
@@ -54,8 +54,15 @@ std::string MacroActionFactory::GetIdByName(const QString &name)
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : MacroActionFactory::GetActionTypes()) {
|
||||
list->addItem(obs_module_text(entry.second._name.c_str()));
|
||||
for (auto &[_, action] : MacroActionFactory::GetActionTypes()) {
|
||||
QString entry(obs_module_text(action._name.c_str()));
|
||||
if (list->findText(entry) == -1) {
|
||||
list->addItem(entry);
|
||||
} else {
|
||||
blog(LOG_WARNING,
|
||||
"did not insert duplicate action entry with name \"%s\"",
|
||||
entry.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
list->model()->sort(0);
|
||||
}
|
||||
@@ -64,10 +71,9 @@ MacroActionEdit::MacroActionEdit(QWidget *parent,
|
||||
std::shared_ptr<MacroAction> *entryData,
|
||||
const std::string &id)
|
||||
: MacroSegmentEdit(switcher->macroProperties._highlightActions, parent),
|
||||
_actionSelection(new QComboBox()),
|
||||
_entryData(entryData)
|
||||
{
|
||||
_actionSelection = new QComboBox();
|
||||
|
||||
QWidget::connect(_actionSelection,
|
||||
SIGNAL(currentTextChanged(const QString &)), this,
|
||||
SLOT(ActionSelectionChanged(const QString &)));
|
||||
|
||||
@@ -83,8 +83,16 @@ static inline void populateLogicSelection(QComboBox *list, bool root = false)
|
||||
|
||||
static inline void populateConditionSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : MacroConditionFactory::GetConditionTypes()) {
|
||||
list->addItem(obs_module_text(entry.second._name.c_str()));
|
||||
for (auto &[_, condition] :
|
||||
MacroConditionFactory::GetConditionTypes()) {
|
||||
QString entry(obs_module_text(condition._name.c_str()));
|
||||
if (list->findText(entry) == -1) {
|
||||
list->addItem(entry);
|
||||
} else {
|
||||
blog(LOG_WARNING,
|
||||
"did not insert duplicate condition entry with name \"%s\"",
|
||||
entry.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
list->model()->sort(0);
|
||||
}
|
||||
@@ -94,13 +102,12 @@ MacroConditionEdit::MacroConditionEdit(
|
||||
const std::string &id, bool root)
|
||||
: MacroSegmentEdit(switcher->macroProperties._highlightConditions,
|
||||
parent),
|
||||
_logicSelection(new QComboBox()),
|
||||
_conditionSelection(new QComboBox()),
|
||||
_dur(new DurationConstraintEdit()),
|
||||
_entryData(entryData),
|
||||
_isRoot(root)
|
||||
{
|
||||
_logicSelection = new QComboBox();
|
||||
_conditionSelection = new QComboBox();
|
||||
_dur = new DurationConstraintEdit();
|
||||
|
||||
QWidget::connect(_logicSelection, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(LogicSelectionChanged(int)));
|
||||
QWidget::connect(_conditionSelection,
|
||||
|
||||
Reference in New Issue
Block a user