mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Add "disable" effect to macro conditions using "ignore" logic selection
This commit is contained in:
parent
aa87911b71
commit
b0eede8a85
|
|
@ -7,8 +7,6 @@
|
|||
#include "section.hpp"
|
||||
#include "switch-button.hpp"
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
|
||||
namespace advss {
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
|
|
@ -119,17 +117,6 @@ void MacroActionEdit::SetEntryData(std::shared_ptr<MacroAction> *data)
|
|||
_entryData = data;
|
||||
}
|
||||
|
||||
void MacroActionEdit::SetDisableEffect(bool value)
|
||||
{
|
||||
if (value) {
|
||||
auto effect = new QGraphicsOpacityEffect(this);
|
||||
effect->setOpacity(0.5);
|
||||
_section->setGraphicsEffect(effect);
|
||||
} else {
|
||||
_section->setGraphicsEffect(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionEdit::ActionEnableChanged(bool value)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
|
|
@ -147,13 +134,9 @@ void MacroActionEdit::UpdateActionState()
|
|||
return;
|
||||
}
|
||||
|
||||
SetEnableAppearance((*_entryData)->Enabled());
|
||||
}
|
||||
|
||||
void MacroActionEdit::SetEnableAppearance(bool value)
|
||||
{
|
||||
_enable->setChecked(value);
|
||||
SetDisableEffect(!value);
|
||||
const bool enabled = (*_entryData)->Enabled();
|
||||
SetEnableAppearance(enabled);
|
||||
_enable->setChecked(enabled);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroSegment> MacroActionEdit::Data() const
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ private slots:
|
|||
|
||||
private:
|
||||
std::shared_ptr<MacroSegment> Data() const;
|
||||
void SetDisableEffect(bool);
|
||||
void SetEnableAppearance(bool);
|
||||
|
||||
FilterComboBox *_actionSelection;
|
||||
SwitchButton *_enable;
|
||||
|
|
|
|||
|
|
@ -11,15 +11,12 @@ bool MacroAction::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroSegment::Save(obj);
|
||||
obs_data_set_string(obj, "id", GetId().c_str());
|
||||
obs_data_set_bool(obj, "enabled", _enabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroAction::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroSegment::Load(obj);
|
||||
obs_data_set_default_bool(obj, "enabled", true);
|
||||
_enabled = obs_data_get_bool(obj, "enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -28,16 +25,6 @@ void MacroAction::LogAction() const
|
|||
ablog(LOG_INFO, "performed action %s", GetId().c_str());
|
||||
}
|
||||
|
||||
void MacroAction::SetEnabled(bool value)
|
||||
{
|
||||
_enabled = value;
|
||||
}
|
||||
|
||||
bool MacroAction::Enabled() const
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
void MacroAction::ResolveVariablesToFixedValues() {}
|
||||
|
||||
std::string_view MacroAction::GetDefaultID()
|
||||
|
|
|
|||
|
|
@ -19,13 +19,9 @@ public:
|
|||
// Used to resolve variables before actions are added to action queues
|
||||
virtual void ResolveVariablesToFixedValues();
|
||||
|
||||
void SetEnabled(bool);
|
||||
bool Enabled() const;
|
||||
|
||||
static std::string_view GetDefaultID();
|
||||
|
||||
private:
|
||||
bool _enabled = true;
|
||||
};
|
||||
|
||||
class EXPORT MacroRefAction : virtual public MacroAction {
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ void MacroConditionEdit::LogicSelectionChanged(int idx)
|
|||
const auto logic = static_cast<Logic::Type>(
|
||||
_logicSelection->itemData(idx).toInt());
|
||||
(*_entryData)->SetLogicType(logic);
|
||||
|
||||
SetEnableAppearance(logic != Logic::Type::NONE);
|
||||
}
|
||||
|
||||
bool MacroConditionEdit::IsRootNode()
|
||||
|
|
@ -164,6 +166,7 @@ void MacroConditionEdit::SetLogicSelection()
|
|||
const auto logic = (*_entryData)->GetLogicType();
|
||||
_logicSelection->setCurrentIndex(
|
||||
_logicSelection->findData(static_cast<int>(logic)));
|
||||
SetEnableAppearance(logic != Logic::Type::NONE);
|
||||
}
|
||||
|
||||
void MacroConditionEdit::SetRootNode(bool root)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QEvent>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
|
|
@ -24,24 +25,24 @@ bool MacroSegment::Save(obs_data_t *obj) const
|
|||
obs_data_set_bool(data, "collapsed", _collapsed);
|
||||
obs_data_set_bool(data, "useCustomLabel", _useCustomLabel);
|
||||
obs_data_set_string(data, "customLabel", _customLabel.c_str());
|
||||
obs_data_set_bool(data, "enabled", _enabled);
|
||||
obs_data_set_int(data, "version", 1);
|
||||
obs_data_set_obj(obj, "segmentSettings", data);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroSegment::Load(obs_data_t *obj)
|
||||
{
|
||||
OBSDataAutoRelease data = obs_data_get_obj(obj, "segmentSettings");
|
||||
_collapsed = obs_data_get_bool(data, "collapsed");
|
||||
_useCustomLabel = obs_data_get_bool(data, "useCustomLabel");
|
||||
_customLabel = obs_data_get_string(data, "customLabel");
|
||||
obs_data_set_default_bool(data, "enabled", true);
|
||||
_enabled = obs_data_get_bool(data, "enabled");
|
||||
|
||||
// TODO: remove this fallback at some point
|
||||
if (obs_data_has_user_value(obj, "segmentSettings")) {
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_get_obj(obj, "segmentSettings");
|
||||
_collapsed = obs_data_get_bool(data, "collapsed");
|
||||
_useCustomLabel = obs_data_get_bool(data, "useCustomLabel");
|
||||
_customLabel = obs_data_get_string(data, "customLabel");
|
||||
} else {
|
||||
_collapsed = obs_data_get_bool(obj, "collapsed");
|
||||
_useCustomLabel = false;
|
||||
_customLabel = obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.segment.defaultCustomLabel");
|
||||
if (!obs_data_has_user_value(data, "version")) {
|
||||
_enabled = obs_data_get_bool(obj, "enabled");
|
||||
}
|
||||
|
||||
ClearAvailableTempvars();
|
||||
|
|
@ -73,6 +74,16 @@ bool MacroSegment::GetHighlightAndReset()
|
|||
return false;
|
||||
}
|
||||
|
||||
void MacroSegment::SetEnabled(bool value)
|
||||
{
|
||||
_enabled = value;
|
||||
}
|
||||
|
||||
bool MacroSegment::Enabled() const
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
std::string MacroSegment::GetVariableValue() const
|
||||
{
|
||||
if (_supportsVariableValue) {
|
||||
|
|
@ -320,6 +331,22 @@ void MacroSegmentEdit::Collapsed(bool collapsed)
|
|||
}
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::SetDisableEffect(bool value)
|
||||
{
|
||||
if (value) {
|
||||
auto effect = new QGraphicsOpacityEffect(this);
|
||||
effect->setOpacity(0.5);
|
||||
_section->setGraphicsEffect(effect);
|
||||
} else {
|
||||
_section->setGraphicsEffect(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::SetEnableAppearance(bool value)
|
||||
{
|
||||
SetDisableEffect(!value);
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::SetFocusPolicyOfWidgets()
|
||||
{
|
||||
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public:
|
|||
virtual std::string GetId() const = 0;
|
||||
void EnableHighlight();
|
||||
bool GetHighlightAndReset();
|
||||
void SetEnabled(bool);
|
||||
bool Enabled() const;
|
||||
virtual std::string GetVariableValue() const;
|
||||
|
||||
protected:
|
||||
|
|
@ -75,6 +77,7 @@ private:
|
|||
// UI helper
|
||||
bool _highlight = false;
|
||||
bool _collapsed = false;
|
||||
bool _enabled = true;
|
||||
|
||||
// Custom header labels
|
||||
bool _useCustomLabel = false;
|
||||
|
|
@ -118,6 +121,9 @@ signals:
|
|||
void SceneGroupRenamed(const QString &oldName, const QString newName);
|
||||
|
||||
protected:
|
||||
void SetDisableEffect(bool);
|
||||
void SetEnableAppearance(bool);
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
|
||||
Section *_section;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user