mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Add option to highlight macro dock if conditions of macro are true
This commit is contained in:
parent
55c7ac8a32
commit
6869cc8a01
|
|
@ -113,6 +113,7 @@ AdvSceneSwitcher.macroTab.currentDockButtonText.pause="Pause button text:"
|
|||
AdvSceneSwitcher.macroTab.currentDockButtonText.unpause="Unpause button text:"
|
||||
AdvSceneSwitcher.macroTab.currentDockStatusText.true="Conditions true text:"
|
||||
AdvSceneSwitcher.macroTab.currentDockStatusText.false="Conditions false text:"
|
||||
AdvSceneSwitcher.macroTab.currentDockHighlightIfExecuted="Highlight dock if macro actions were recently executed"
|
||||
|
||||
AdvSceneSwitcher.macroDock.pause="Pause"
|
||||
AdvSceneSwitcher.macroDock.unpause="Unpause"
|
||||
|
|
|
|||
|
|
@ -11,13 +11,15 @@ MacroDock::MacroDock(Macro *m, QWidget *parent,
|
|||
const StringVariable &pauseButtonText,
|
||||
const StringVariable &unpauseButtonText,
|
||||
const StringVariable &conditionsTrueText,
|
||||
const StringVariable &conditionsFalseText)
|
||||
const StringVariable &conditionsFalseText,
|
||||
bool enableHighlight)
|
||||
: OBSDock(parent),
|
||||
_runButtonText(runButtonText),
|
||||
_pauseButtonText(pauseButtonText),
|
||||
_unpauseButtonText(unpauseButtonText),
|
||||
_conditionsTrueText(conditionsTrueText),
|
||||
_conditionsFalseText(conditionsFalseText),
|
||||
_highlight(enableHighlight),
|
||||
_run(new QPushButton(runButtonText.c_str())),
|
||||
_pauseToggle(new QPushButton()),
|
||||
_statusText(new QLabel(conditionsFalseText.c_str())),
|
||||
|
|
@ -46,6 +48,7 @@ MacroDock::MacroDock(Macro *m, QWidget *parent,
|
|||
|
||||
UpdateText();
|
||||
QWidget::connect(&_timer, SIGNAL(timeout()), this, SLOT(UpdateText()));
|
||||
QWidget::connect(&_timer, SIGNAL(timeout()), this, SLOT(Highlight()));
|
||||
_timer.start(500);
|
||||
|
||||
// QFrame wrapper is necessary to avoid dock being partially
|
||||
|
|
@ -110,6 +113,11 @@ void MacroDock::SetConditionsFalseText(const StringVariable &text)
|
|||
UpdateText();
|
||||
}
|
||||
|
||||
void MacroDock::EnableHighlight(bool value)
|
||||
{
|
||||
_highlight = value;
|
||||
}
|
||||
|
||||
void MacroDock::RunClicked()
|
||||
{
|
||||
if (!_macro) {
|
||||
|
|
@ -148,4 +156,16 @@ void MacroDock::UpdateText()
|
|||
: _conditionsFalseText.c_str());
|
||||
}
|
||||
|
||||
void MacroDock::Highlight()
|
||||
{
|
||||
if (!_highlight || !_macro) {
|
||||
return;
|
||||
}
|
||||
if (_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
||||
_macro->ExecutedSince(_lastHighlightCheckTime)) {
|
||||
PulseWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
||||
}
|
||||
_lastHighlightCheckTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QTimer>
|
||||
#include <QLabel>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -19,7 +20,8 @@ public:
|
|||
const StringVariable &pauseButtonText,
|
||||
const StringVariable &unpauseButtonText,
|
||||
const StringVariable &conditionsTrueText,
|
||||
const StringVariable &conditionsFalseText);
|
||||
const StringVariable &conditionsFalseText,
|
||||
bool enableHighlight);
|
||||
void SetName(const QString &);
|
||||
void ShowRunButton(bool);
|
||||
void SetRunButtonText(const StringVariable &);
|
||||
|
|
@ -29,11 +31,13 @@ public:
|
|||
void ShowStatusLabel(bool);
|
||||
void SetConditionsTrueText(const StringVariable &);
|
||||
void SetConditionsFalseText(const StringVariable &);
|
||||
void EnableHighlight(bool);
|
||||
|
||||
private slots:
|
||||
void RunClicked();
|
||||
void PauseToggleClicked();
|
||||
void UpdateText();
|
||||
void Highlight();
|
||||
|
||||
private:
|
||||
StringVariable _runButtonText;
|
||||
|
|
@ -41,11 +45,13 @@ private:
|
|||
StringVariable _unpauseButtonText;
|
||||
StringVariable _conditionsTrueText;
|
||||
StringVariable _conditionsFalseText;
|
||||
bool _highlight;
|
||||
QPushButton *_run;
|
||||
QPushButton *_pauseToggle;
|
||||
QLabel *_statusText;
|
||||
|
||||
QTimer _timer;
|
||||
std::chrono::high_resolution_clock::time_point _lastHighlightCheckTime{};
|
||||
|
||||
Macro *_macro;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
"AdvSceneSwitcher.macroTab.currentDockAddPauseButton"))),
|
||||
_currentMacroDockAddStatusLabel(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.currentDockAddStatusLabel"))),
|
||||
_currentMacroDockHighlightIfConditionsTrue(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.currentDockHighlightIfExecuted"))),
|
||||
_runButtonText(new VariableLineEdit(this)),
|
||||
_pauseButtonText(new VariableLineEdit(this)),
|
||||
_unpauseButtonText(new VariableLineEdit(this)),
|
||||
|
|
@ -147,6 +149,9 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
row, 1);
|
||||
_dockLayout->addWidget(_conditionsFalseStatusText, row, 2);
|
||||
_conditionsFalseTextRow = row;
|
||||
row++;
|
||||
_dockLayout->addWidget(_currentMacroDockHighlightIfConditionsTrue, row,
|
||||
1, 1, 2);
|
||||
|
||||
_dockOptions->setLayout(_dockLayout);
|
||||
|
||||
|
|
@ -189,6 +194,8 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
macro->DockHasPauseButton());
|
||||
_currentMacroDockAddStatusLabel->setChecked(
|
||||
macro->DockHasStatusLabel());
|
||||
_currentMacroDockHighlightIfConditionsTrue->setChecked(
|
||||
macro->DockHighlightEnabled());
|
||||
_runButtonText->setText(macro->RunButtonText());
|
||||
_pauseButtonText->setText(macro->PauseButtonText());
|
||||
_unpauseButtonText->setText(macro->UnpauseButtonText());
|
||||
|
|
@ -198,6 +205,7 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
_currentMacroDockAddRunButton->setVisible(dockEnabled);
|
||||
_currentMacroDockAddPauseButton->setVisible(dockEnabled);
|
||||
_currentMacroDockAddStatusLabel->setVisible(dockEnabled);
|
||||
_currentMacroDockHighlightIfConditionsTrue->setVisible(dockEnabled);
|
||||
setGridLayoutRowVisible(_dockLayout, _runButtonTextRow,
|
||||
dockEnabled && macro->DockHasRunButton());
|
||||
setGridLayoutRowVisible(_dockLayout, _pauseButtonTextRow,
|
||||
|
|
@ -217,6 +225,7 @@ void MacroPropertiesDialog::DockEnableChanged(int enabled)
|
|||
_currentMacroDockAddRunButton->setVisible(enabled);
|
||||
_currentMacroDockAddPauseButton->setVisible(enabled);
|
||||
_currentMacroDockAddStatusLabel->setVisible(enabled);
|
||||
_currentMacroDockHighlightIfConditionsTrue->setVisible(enabled);
|
||||
setGridLayoutRowVisible(
|
||||
_dockLayout, _runButtonTextRow,
|
||||
enabled && _currentMacroDockAddRunButton->isChecked());
|
||||
|
|
@ -290,6 +299,8 @@ bool MacroPropertiesDialog::AskForSettings(QWidget *parent,
|
|||
dialog._currentMacroDockAddPauseButton->isChecked());
|
||||
macro->SetDockHasStatusLabel(
|
||||
dialog._currentMacroDockAddStatusLabel->isChecked());
|
||||
macro->SetHighlightEnable(
|
||||
dialog._currentMacroDockHighlightIfConditionsTrue->isChecked());
|
||||
macro->SetRunButtonText(dialog._runButtonText->text().toStdString());
|
||||
macro->SetPauseButtonText(
|
||||
dialog._pauseButtonText->text().toStdString());
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ private:
|
|||
QCheckBox *_currentMacroDockAddRunButton;
|
||||
QCheckBox *_currentMacroDockAddPauseButton;
|
||||
QCheckBox *_currentMacroDockAddStatusLabel;
|
||||
QCheckBox *_currentMacroDockHighlightIfConditionsTrue;
|
||||
VariableLineEdit *_runButtonText;
|
||||
VariableLineEdit *_pauseButtonText;
|
||||
VariableLineEdit *_unpauseButtonText;
|
||||
|
|
|
|||
|
|
@ -605,6 +605,8 @@ void Macro::SaveDockSettings(obs_data_t *obj) const
|
|||
obs_data_set_bool(dockSettings, "hasRunButton", _dockHasRunButton);
|
||||
obs_data_set_bool(dockSettings, "hasPauseButton", _dockHasPauseButton);
|
||||
obs_data_set_bool(dockSettings, "hasStatusLabel", _dockHasStatusLabel);
|
||||
obs_data_set_bool(dockSettings, "highlightIfConditionsTrue",
|
||||
_dockHighlight);
|
||||
_runButtonText.Save(dockSettings, "runButtonText");
|
||||
_pauseButtonText.Save(dockSettings, "pauseButtonText");
|
||||
_unpauseButtonText.Save(dockSettings, "unpauseButtonText");
|
||||
|
|
@ -667,7 +669,8 @@ void Macro::LoadDockSettings(obs_data_t *obj)
|
|||
obs_data_get_bool(dockSettings, "hasPauseButton");
|
||||
_dockHasStatusLabel =
|
||||
obs_data_get_bool(dockSettings, "hasStatusLabel");
|
||||
|
||||
_dockHighlight = obs_data_get_bool(dockSettings,
|
||||
"highlightIfConditionsTrue");
|
||||
_dockIsFloating = obs_data_get_bool(dockSettings, "isFloating");
|
||||
_dockArea = static_cast<Qt::DockWidgetArea>(
|
||||
obs_data_get_int(dockSettings, "area"));
|
||||
|
|
@ -704,7 +707,7 @@ void Macro::EnableDock(bool value)
|
|||
static_cast<QMainWindow *>(obs_frontend_get_main_window());
|
||||
_dock = new MacroDock(this, window, _runButtonText, _pauseButtonText,
|
||||
_unpauseButtonText, _conditionsTrueStatusText,
|
||||
_conditionsFalseStatusText);
|
||||
_conditionsFalseStatusText, _dockHighlight);
|
||||
SetDockWidgetName(); // Used by OBS to restore position
|
||||
|
||||
// Register new dock
|
||||
|
|
@ -754,6 +757,15 @@ void Macro::SetDockHasStatusLabel(bool value)
|
|||
_dock->ShowStatusLabel(value);
|
||||
}
|
||||
|
||||
void Macro::SetHighlightEnable(bool value)
|
||||
{
|
||||
_dockHighlight = value;
|
||||
if (!_dock) {
|
||||
return;
|
||||
}
|
||||
_dock->EnableHighlight(value);
|
||||
}
|
||||
|
||||
void Macro::SetRunButtonText(const std::string &text)
|
||||
{
|
||||
_runButtonText = text;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ public:
|
|||
bool DockHasPauseButton() const { return _dockHasPauseButton; }
|
||||
void SetDockHasStatusLabel(bool value);
|
||||
bool DockHasStatusLabel() const { return _dockHasStatusLabel; }
|
||||
void SetHighlightEnable(bool value);
|
||||
bool DockHighlightEnabled() const { return _dockHighlight; }
|
||||
StringVariable RunButtonText() const { return _runButtonText; }
|
||||
void SetRunButtonText(const std::string &text);
|
||||
StringVariable PauseButtonText() const { return _pauseButtonText; }
|
||||
|
|
@ -151,6 +153,7 @@ private:
|
|||
bool _dockHasRunButton = true;
|
||||
bool _dockHasPauseButton = true;
|
||||
bool _dockHasStatusLabel = false;
|
||||
bool _dockHighlight = false;
|
||||
StringVariable _runButtonText =
|
||||
obs_module_text("AdvSceneSwitcher.macroDock.run");
|
||||
StringVariable _pauseButtonText =
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user