mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Move hightlight and update of paused state into MacroListEntryWidget
This commit is contained in:
parent
37734445e7
commit
001d8b4714
|
|
@ -199,6 +199,7 @@ void AdvSceneSwitcher::on_highlightExecutedMacros_stateChanged(int state)
|
|||
}
|
||||
|
||||
switcher->highlightExecutedMacros = state;
|
||||
emit HighlightMacrosChanged(switcher->highlightExecutedMacros);
|
||||
}
|
||||
|
||||
bool isLegacyTab(const QString &name)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ signals:
|
|||
void MacroAdded(const QString &name);
|
||||
void MacroRemoved(const QString &name);
|
||||
void MacroRenamed(const QString &oldName, const QString newName);
|
||||
void HighlightMacrosChanged(bool value);
|
||||
void SceneGroupAdded(const QString &name);
|
||||
void SceneGroupRemoved(const QString &name);
|
||||
void SceneGroupRenamed(const QString &oldName, const QString newName);
|
||||
|
|
@ -158,7 +159,6 @@ public slots:
|
|||
void ResetOpacityActionControls();
|
||||
void ResetOpacityConditionControls();
|
||||
void HighlightControls();
|
||||
void HighlightMatchedMacros();
|
||||
void MacroDragDropReorder(QModelIndex, int, int, QModelIndex, int);
|
||||
|
||||
void on_screenRegionSwitches_currentRowChanged(int idx);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QTimer>
|
||||
#include <memory>
|
||||
|
||||
class Macro;
|
||||
|
|
@ -10,15 +11,22 @@ class MacroListEntryWidget : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroListEntryWidget(std::shared_ptr<Macro>, QWidget *parent);
|
||||
MacroListEntryWidget(std::shared_ptr<Macro>, bool highlight,
|
||||
QWidget *parent);
|
||||
void SetName(const QString &);
|
||||
void SetMacro(std::shared_ptr<Macro> &);
|
||||
|
||||
private slots:
|
||||
void PauseChanged(int);
|
||||
void HighlightExecuted();
|
||||
void UpdatePaused();
|
||||
void EnableHighlight(bool);
|
||||
|
||||
private:
|
||||
QTimer _timer;
|
||||
QLabel *_name;
|
||||
QCheckBox *_running;
|
||||
std::shared_ptr<Macro> _macro;
|
||||
|
||||
bool _highlightExecutedMacros = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#include "headers/macro-list-entry-widget.hpp"
|
||||
#include "headers/macro.hpp"
|
||||
#include "headers/utility.hpp"
|
||||
|
||||
MacroListEntryWidget::MacroListEntryWidget(std::shared_ptr<Macro> macro,
|
||||
QWidget *parent)
|
||||
: QWidget(parent), _macro(macro)
|
||||
bool highlight, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
_highlightExecutedMacros(highlight),
|
||||
_macro(macro),
|
||||
_name(new QLabel(QString::fromStdString(macro->Name()))),
|
||||
_running(new QCheckBox)
|
||||
{
|
||||
_name = new QLabel(QString::fromStdString(macro->Name()));
|
||||
_running = new QCheckBox();
|
||||
_running->setChecked(!macro->Paused());
|
||||
connect(_running, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(PauseChanged(int)));
|
||||
|
||||
setStyleSheet("\
|
||||
QCheckBox { background-color: rgba(0,0,0,0); }\
|
||||
|
|
@ -21,6 +22,15 @@ MacroListEntryWidget::MacroListEntryWidget(std::shared_ptr<Macro> macro,
|
|||
layout->addWidget(_name);
|
||||
layout->addStretch();
|
||||
setLayout(layout);
|
||||
|
||||
connect(_running, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(PauseChanged(int)));
|
||||
connect(window(), SIGNAL(HighlightMacrosChanged(bool)), this,
|
||||
SLOT(EnableHighlight(bool)));
|
||||
_timer.setInterval(1500);
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(HighlightExecuted()));
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(UpdatePaused()));
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
void MacroListEntryWidget::PauseChanged(int state)
|
||||
|
|
@ -37,3 +47,25 @@ void MacroListEntryWidget::SetMacro(std::shared_ptr<Macro> &m)
|
|||
{
|
||||
_macro = m;
|
||||
}
|
||||
|
||||
void MacroListEntryWidget::EnableHighlight(bool value)
|
||||
{
|
||||
_highlightExecutedMacros = value;
|
||||
}
|
||||
|
||||
void MacroListEntryWidget::HighlightExecuted()
|
||||
{
|
||||
if (!_highlightExecutedMacros) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_macro && _macro->WasExecutedRecently()) {
|
||||
PulseWidget(this, Qt::green, QColor(0, 0, 0, 0), true);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroListEntryWidget::UpdatePaused()
|
||||
{
|
||||
const QSignalBlocker b(_running);
|
||||
_running->setChecked(!_macro->Paused());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
static QTimer highlightMatchTimer;
|
||||
static QMetaObject::Connection addPulse;
|
||||
|
||||
bool macroNameExists(std::string name)
|
||||
|
|
@ -67,7 +66,8 @@ QListWidgetItem *AddNewMacroListEntry(QListWidget *list,
|
|||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(list);
|
||||
item->setData(Qt::UserRole, QString::fromStdString(macro->Name()));
|
||||
auto listEntry = new MacroListEntryWidget(macro, list);
|
||||
auto listEntry = new MacroListEntryWidget(
|
||||
macro, switcher->highlightExecutedMacros, list);
|
||||
item->setSizeHint(listEntry->minimumSizeHint());
|
||||
list->setItemWidget(item, listEntry);
|
||||
return item;
|
||||
|
|
@ -459,11 +459,6 @@ void AdvSceneSwitcher::setupMacroTab()
|
|||
|
||||
ui->macroPriorityWarning->setVisible(
|
||||
switcher->functionNamesByPriority[0] != macro_func);
|
||||
|
||||
highlightMatchTimer.setInterval(1000);
|
||||
connect(&highlightMatchTimer, &QTimer::timeout, this,
|
||||
&AdvSceneSwitcher::HighlightMatchedMacros);
|
||||
highlightMatchTimer.start();
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::ShowMacroContextMenu(const QPoint &pos)
|
||||
|
|
@ -598,28 +593,6 @@ void AdvSceneSwitcher::MinimizeConditions()
|
|||
ui->macroSplitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::HighlightMatchedMacros()
|
||||
{
|
||||
if (loading || !(switcher && switcher->highlightExecutedMacros)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < (int)switcher->macros.size(); idx++) {
|
||||
if (switcher->macros[idx]->WasExecutedRecently()) {
|
||||
auto item = ui->macros->item(idx);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
auto widget = ui->macros->itemWidget(item);
|
||||
if (!widget) {
|
||||
continue;
|
||||
}
|
||||
PulseWidget(widget, Qt::green, QColor(0, 0, 0, 0),
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetSelection(MacroSegmentList *list, int idx)
|
||||
{
|
||||
for (int i = 0; i < list->ContentLayout()->count(); ++i) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user