Update the UI's status element if the status changed externally (#126)

This commit is contained in:
WarmUpTill 2021-02-20 18:58:07 +01:00 committed by GitHub
parent f4902933ab
commit 499ba7dd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -129,6 +129,7 @@ void AdvSceneSwitcher::SetStarted()
ui->pluginRunningText->setText(
obs_module_text("AdvSceneSwitcher.status.active"));
ui->pluginRunningText->disconnect(inactivePluse);
currentStatusActive = true;
}
void AdvSceneSwitcher::SetStopped()
@ -139,6 +140,7 @@ void AdvSceneSwitcher::SetStopped()
obs_module_text("AdvSceneSwitcher.status.inactive"));
inactivePluse = PulseWidget(ui->pluginRunningText, QColor(Qt::red),
QColor(0, 0, 0, 0), "QLabel ");
currentStatusActive = false;
}
void AdvSceneSwitcher::on_toggleStartButton_clicked()
@ -681,6 +683,21 @@ void populateAutoStartEventSelection(QComboBox *cb)
"AdvSceneSwitcher.generalTab.status.autoStart.recordingAndStreaming"));
}
void AdvSceneSwitcher::updateStatus()
{
if (switcher->th && switcher->th->isRunning()) {
if (currentStatusActive) {
return;
}
SetStarted();
} else {
if (!currentStatusActive) {
return;
}
SetStopped();
}
}
void AdvSceneSwitcher::setupGeneralTab()
{
populateSceneSelection(ui->noMatchSwitchScene, false);
@ -780,4 +797,10 @@ void AdvSceneSwitcher::setupGeneralTab()
} else {
SetStopped();
}
// Updates the UI status element if the status changed externally
// (e.g. via hotkeys)
QTimer *statusTimer = new QTimer(this);
connect(statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
statusTimer->start(1000);
}

View File

@ -23,6 +23,7 @@ class AdvSceneSwitcher : public QDialog {
public:
std::unique_ptr<Ui_AdvSceneSwitcher> ui;
bool loading = true;
bool currentStatusActive = false;
AdvSceneSwitcher(QWidget *parent);
@ -219,6 +220,7 @@ public slots:
void on_threadPriority_currentTextChanged(const QString &text);
void updateScreenRegionCursorPos();
void updateStatus();
void on_close_clicked();