mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-21 16:55:29 -05:00
add generic PulseWidget function to highlight widgets
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include <QDir>
|
||||
#include <QAction>
|
||||
#include <QtGui/qstandarditemmodel.h>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
@@ -208,6 +210,40 @@ bool SceneSwitcher::listMoveDown(QListWidget *list)
|
||||
return true;
|
||||
}
|
||||
|
||||
QMetaObject::Connection SceneSwitcher::PulseWidget(QWidget *widget,
|
||||
QColor endColor,
|
||||
QColor startColor,
|
||||
QString specifier)
|
||||
{
|
||||
widget->setStyleSheet(specifier + "{ \
|
||||
border-style: outset; \
|
||||
border-width: 2px; \
|
||||
border-radius: 10px; \
|
||||
border-color: rgb(0,0,0,0) \
|
||||
}");
|
||||
|
||||
QGraphicsColorizeEffect *eEffect = new QGraphicsColorizeEffect(widget);
|
||||
widget->setGraphicsEffect(eEffect);
|
||||
QPropertyAnimation *paAnimation =
|
||||
new QPropertyAnimation(eEffect, "color");
|
||||
paAnimation->setStartValue(startColor);
|
||||
paAnimation->setEndValue(endColor);
|
||||
paAnimation->setDuration(1000);
|
||||
// play backward to return to original state on timer end
|
||||
paAnimation->setDirection(QAbstractAnimation::Backward);
|
||||
|
||||
auto con = QWidget::connect(
|
||||
paAnimation, &QPropertyAnimation::finished, [paAnimation]() {
|
||||
QTimer::singleShot(1000, [paAnimation] {
|
||||
paAnimation->start();
|
||||
});
|
||||
});
|
||||
|
||||
paAnimation->start();
|
||||
|
||||
return con;
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* Saving and loading
|
||||
********************************************************************************/
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
|
||||
@@ -81,52 +79,19 @@ void SceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
switcher->interval = value;
|
||||
}
|
||||
|
||||
void SceneSwitcher::StartInactivePulse()
|
||||
{
|
||||
ui->pluginRunningText->setStyleSheet("QLabel { \
|
||||
border-style: outset; \
|
||||
border-width: 2px; \
|
||||
border-radius: 10px; \
|
||||
border-color: rgb(0,0,0,0) \
|
||||
}");
|
||||
|
||||
QGraphicsColorizeEffect *eEffect =
|
||||
new QGraphicsColorizeEffect(ui->pluginRunningText);
|
||||
ui->pluginRunningText->setGraphicsEffect(eEffect);
|
||||
QPropertyAnimation *paAnimation =
|
||||
new QPropertyAnimation(eEffect, "color");
|
||||
paAnimation->setStartValue(QColor(0, 0, 0, 0));
|
||||
paAnimation->setEndValue(QColor(Qt::red));
|
||||
paAnimation->setDuration(1000);
|
||||
|
||||
connect(paAnimation, &QPropertyAnimation::finished, [paAnimation]() {
|
||||
if (switcher->stop)
|
||||
QTimer::singleShot(1000, [paAnimation] {
|
||||
paAnimation->start();
|
||||
});
|
||||
});
|
||||
|
||||
paAnimation->start();
|
||||
}
|
||||
|
||||
void SceneSwitcher::ResetInactivePulse()
|
||||
{
|
||||
ui->pluginRunningText->setStyleSheet(
|
||||
"QLabel { background-color: rgb(0,0,0,0); }");
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStarted()
|
||||
{
|
||||
ui->toggleStartButton->setText("Stop");
|
||||
ui->pluginRunningText->setText("Active");
|
||||
ResetInactivePulse();
|
||||
ui->pluginRunningText->disconnect(inactivePluse);
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStopped()
|
||||
{
|
||||
ui->toggleStartButton->setText("Start");
|
||||
ui->pluginRunningText->setText("Inactive");
|
||||
StartInactivePulse();
|
||||
inactivePluse = PulseWidget(ui->pluginRunningText, QColor(Qt::red),
|
||||
QColor(0, 0, 0, 0), "QLabel ");
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_toggleStartButton_clicked()
|
||||
|
||||
@@ -25,6 +25,7 @@ class SceneSwitcher : public QDialog {
|
||||
public:
|
||||
std::unique_ptr<Ui_SceneSwitcher> ui;
|
||||
bool loading = true;
|
||||
QMetaObject::Connection inactivePluse;
|
||||
|
||||
SceneSwitcher(QWidget *parent);
|
||||
|
||||
@@ -82,6 +83,9 @@ public:
|
||||
bool addSelect = true);
|
||||
static void populateProcessSelection(QComboBox *sel,
|
||||
bool addSelect = true);
|
||||
QMetaObject::Connection PulseWidget(QWidget *widget, QColor endColor,
|
||||
QColor = QColor(0, 0, 0, 0),
|
||||
QString specifier = "");
|
||||
|
||||
bool listMoveUp(QListWidget *list);
|
||||
bool listMoveDown(QListWidget *list);
|
||||
@@ -98,8 +102,6 @@ public slots:
|
||||
void on_startupBehavior_currentIndexChanged(int index);
|
||||
void on_noMatchSwitchScene_currentTextChanged(const QString &text);
|
||||
void on_checkInterval_valueChanged(int value);
|
||||
void StartInactivePulse();
|
||||
void ResetInactivePulse();
|
||||
void on_toggleStartButton_clicked();
|
||||
void on_tabMoved(int from, int to);
|
||||
|
||||
|
||||
@@ -4,8 +4,15 @@
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/volume-control.hpp"
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
|
||||
QMetaObject::Connection test;
|
||||
|
||||
void SceneSwitcher::on_audioAdd_clicked()
|
||||
{
|
||||
ui->audioAdd->disconnect(test);
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->audioSwitches.emplace_back();
|
||||
|
||||
@@ -183,6 +190,9 @@ void SceneSwitcher::setupAudioTab()
|
||||
item->setSizeHint(sw->minimumSizeHint());
|
||||
ui->audioSwitches->setItemWidget(item, sw);
|
||||
}
|
||||
|
||||
if (switcher->audioSwitches.size() == 0)
|
||||
test = PulseWidget(ui->audioAdd, QColor(Qt::green));
|
||||
}
|
||||
|
||||
void AudioSwitch::setVolumeLevel(void *data,
|
||||
|
||||
Reference in New Issue
Block a user