mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Use the same widget for main settings window and status dock
This commit is contained in:
parent
16ee789c82
commit
82503286ea
|
|
@ -257,7 +257,7 @@ set(advanced-scene-switcher_HEADERS
|
|||
src/headers/duration-control.hpp
|
||||
src/headers/file-selection.hpp
|
||||
src/headers/section.hpp
|
||||
src/headers/status-dock.hpp
|
||||
src/headers/status-control.hpp
|
||||
src/headers/platform-funcs.hpp
|
||||
src/headers/utility.hpp
|
||||
src/headers/volume-control.hpp
|
||||
|
|
@ -354,7 +354,7 @@ set(advanced-scene-switcher_SOURCES
|
|||
src/transition-selection.cpp
|
||||
src/name-dialog.cpp
|
||||
src/duration-control.cpp
|
||||
src/status-dock.cpp
|
||||
src/status-control.cpp
|
||||
src/section.cpp
|
||||
src/utility.cpp
|
||||
src/volume-control.cpp
|
||||
|
|
|
|||
|
|
@ -56,10 +56,30 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="statusLayout">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="autoStartEvent"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_64">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.onStartup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="startupBehavior"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="placeholder" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.autoStart</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="checkInterval">
|
||||
<property name="minimumSize">
|
||||
|
|
@ -82,6 +102,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.hotkeytips</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
|
|
@ -90,66 +117,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="toggleStartButton">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.start</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="placeholder2" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_47">
|
||||
<item>
|
||||
<widget class="QLabel" name="pluginRunningText">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.status.inactive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.hotkeytips</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_64">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.onStartup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.currentStatus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.generalTab.status.autoStart</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="autoStartEvent"/>
|
||||
<widget class="QWidget" name="placeholder3" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <obs-frontend-api.h>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/status-dock.hpp"
|
||||
#include "headers/status-control.hpp"
|
||||
#include "headers/curl-helper.hpp"
|
||||
#include "headers/utility.hpp"
|
||||
#include "headers/version.h"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/status-dock.hpp"
|
||||
#include "headers/status-control.hpp"
|
||||
#include "headers/utility.hpp"
|
||||
#include "headers/version.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
|
||||
QMetaObject::Connection inactivePluse;
|
||||
|
||||
void AdvSceneSwitcher::on_close_clicked()
|
||||
{
|
||||
close();
|
||||
|
|
@ -147,41 +145,6 @@ void AdvSceneSwitcher::on_checkInterval_valueChanged(int value)
|
|||
switcher->interval = value;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetStarted()
|
||||
{
|
||||
ui->toggleStartButton->setText(
|
||||
obs_module_text("AdvSceneSwitcher.generalTab.status.stop"));
|
||||
ui->pluginRunningText->setText(
|
||||
obs_module_text("AdvSceneSwitcher.status.active"));
|
||||
ui->pluginRunningText->disconnect(inactivePluse);
|
||||
currentStatusActive = true;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetStopped()
|
||||
{
|
||||
ui->toggleStartButton->setText(
|
||||
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
|
||||
ui->pluginRunningText->setText(
|
||||
obs_module_text("AdvSceneSwitcher.status.inactive"));
|
||||
if (!switcher->disableHints) {
|
||||
inactivePluse = PulseWidget(ui->pluginRunningText,
|
||||
QColor(Qt::red), QColor(0, 0, 0, 0),
|
||||
"QLabel ");
|
||||
}
|
||||
currentStatusActive = false;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_toggleStartButton_clicked()
|
||||
{
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
switcher->Stop();
|
||||
SetStopped();
|
||||
} else {
|
||||
switcher->Start();
|
||||
SetStarted();
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::closeEvent(QCloseEvent *)
|
||||
{
|
||||
if (!switcher) {
|
||||
|
|
@ -791,21 +754,6 @@ 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);
|
||||
|
|
@ -926,17 +874,14 @@ void AdvSceneSwitcher::setupGeneralTab()
|
|||
ui->autoStartEvent->setCurrentIndex(
|
||||
static_cast<int>(switcher->autoStartEvent));
|
||||
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
SetStarted();
|
||||
} 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);
|
||||
// Set up status control
|
||||
auto statusControl = new StatusControl(this, true);
|
||||
ui->statusLayout->addWidget(statusControl->StatusPrefixLabel(), 1, 0);
|
||||
auto tmp = new QHBoxLayout;
|
||||
tmp->addWidget(statusControl->StatusLabel());
|
||||
tmp->addStretch();
|
||||
ui->statusLayout->addLayout(tmp, 1, 1);
|
||||
ui->statusLayout->addWidget(statusControl->Button(), 2, 1);
|
||||
|
||||
setWindowTitle(windowTitle() + " - " + g_GIT_TAG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class AdvSceneSwitcher : public QDialog {
|
|||
public:
|
||||
std::unique_ptr<Ui_AdvSceneSwitcher> ui;
|
||||
bool loading = true;
|
||||
bool currentStatusActive = false;
|
||||
|
||||
AdvSceneSwitcher(QWidget *parent);
|
||||
~AdvSceneSwitcher();
|
||||
|
|
@ -36,9 +35,6 @@ public:
|
|||
void reject() override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
void SetStarted();
|
||||
void SetStopped();
|
||||
|
||||
void SetShowFrames();
|
||||
void SetHideFrames();
|
||||
void clearFrames(QListWidget *list);
|
||||
|
|
@ -109,7 +105,6 @@ public slots:
|
|||
void on_autoStartEvent_currentIndexChanged(int index);
|
||||
void on_noMatchSwitchScene_currentTextChanged(const QString &text);
|
||||
void on_checkInterval_valueChanged(int value);
|
||||
void on_toggleStartButton_clicked();
|
||||
void on_tabMoved(int from, int to);
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
|
|
@ -272,7 +267,6 @@ public slots:
|
|||
void on_threadPriority_currentTextChanged(const QString &text);
|
||||
|
||||
void updateScreenRegionCursorPos();
|
||||
void updateStatus();
|
||||
|
||||
void on_close_clicked();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@
|
|||
#include <QTimer>
|
||||
#include <obs-data.h>
|
||||
|
||||
class StatusDock : public QDockWidget {
|
||||
class StatusControl : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StatusDock(QWidget *parent = 0);
|
||||
StatusControl(QWidget *parent = 0, bool noLayout = false);
|
||||
QPushButton *Button() { return _button; }
|
||||
QLabel *StatusLabel() { return _status; }
|
||||
QLabel *StatusPrefixLabel() { return _statusPrefix; }
|
||||
|
||||
private slots:
|
||||
void ButtonClicked();
|
||||
|
|
@ -21,7 +24,18 @@ private:
|
|||
|
||||
QPushButton *_button;
|
||||
QLabel *_status;
|
||||
QLabel *_statusPrefix;
|
||||
QTimer _timer;
|
||||
QMetaObject::Connection _pulse;
|
||||
|
||||
bool _setToStopped = true;
|
||||
};
|
||||
|
||||
class StatusDock : public QDockWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StatusDock(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
extern StatusDock *dock;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "headers/status-dock.hpp"
|
||||
#include "headers/status-control.hpp"
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/utility.hpp"
|
||||
|
||||
|
|
@ -8,31 +8,39 @@
|
|||
|
||||
StatusDock *dock = nullptr;
|
||||
|
||||
StatusDock::StatusDock(QWidget *parent)
|
||||
: QDockWidget(obs_module_text("AdvSceneSwitcher.windowTitle"), parent)
|
||||
StatusControl::StatusControl(QWidget *parent, bool noLayout) : QWidget(parent)
|
||||
{
|
||||
_button = new QPushButton(
|
||||
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
|
||||
_status =
|
||||
new QLabel(obs_module_text("AdvSceneSwitcher.status.inactive"));
|
||||
_button = new QPushButton("-", this);
|
||||
_status = new QLabel("-", this);
|
||||
_statusPrefix = new QLabel(
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.status.currentStatus"),
|
||||
this);
|
||||
|
||||
QWidget::connect(_button, SIGNAL(clicked()), this,
|
||||
SLOT(ButtonClicked()));
|
||||
QHBoxLayout *statusLayout = new QHBoxLayout;
|
||||
statusLayout->addWidget(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.status.currentStatus")));
|
||||
statusLayout->addWidget(_status);
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addLayout(statusLayout);
|
||||
layout->addWidget(_button);
|
||||
layout->addStretch();
|
||||
QWidget *tmp = new QWidget;
|
||||
tmp->setLayout(layout);
|
||||
setWidget(tmp);
|
||||
|
||||
if (!noLayout) {
|
||||
QHBoxLayout *statusLayout = new QHBoxLayout();
|
||||
statusLayout->addWidget(_statusPrefix);
|
||||
statusLayout->addWidget(_status);
|
||||
statusLayout->addStretch();
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addLayout(statusLayout);
|
||||
layout->addWidget(_button);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
if (switcher->stop) {
|
||||
SetStopped();
|
||||
} else {
|
||||
SetStarted();
|
||||
}
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(UpdateStatus()));
|
||||
_timer.start(1000);
|
||||
}
|
||||
|
||||
void StatusDock::ButtonClicked()
|
||||
void StatusControl::ButtonClicked()
|
||||
{
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
switcher->Stop();
|
||||
|
|
@ -43,27 +51,52 @@ void StatusDock::ButtonClicked()
|
|||
}
|
||||
}
|
||||
|
||||
void StatusDock::UpdateStatus()
|
||||
void StatusControl::UpdateStatus()
|
||||
{
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
SetStopped();
|
||||
} else {
|
||||
if (!_setToStopped) {
|
||||
return;
|
||||
}
|
||||
SetStarted();
|
||||
} else {
|
||||
if (_setToStopped) {
|
||||
return;
|
||||
}
|
||||
SetStopped();
|
||||
}
|
||||
}
|
||||
|
||||
void StatusDock::SetStopped()
|
||||
void StatusControl::SetStarted()
|
||||
{
|
||||
_button->setText(
|
||||
obs_module_text("AdvSceneSwitcher.generalTab.status.stop"));
|
||||
_status->setText(obs_module_text("AdvSceneSwitcher.status.active"));
|
||||
_status->disconnect(_pulse);
|
||||
_setToStopped = false;
|
||||
}
|
||||
|
||||
void StatusDock::SetStarted()
|
||||
void StatusControl::SetStopped()
|
||||
{
|
||||
_button->setText(
|
||||
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
|
||||
_status->setText(obs_module_text("AdvSceneSwitcher.status.inactive"));
|
||||
if (!switcher->disableHints) {
|
||||
_pulse = PulseWidget(_status, QColor(Qt::red),
|
||||
QColor(0, 0, 0, 0), "QLabel ");
|
||||
}
|
||||
_setToStopped = true;
|
||||
}
|
||||
|
||||
StatusDock::StatusDock(QWidget *parent)
|
||||
: QDockWidget(obs_module_text("AdvSceneSwitcher.windowTitle"), parent)
|
||||
{
|
||||
// Not sure why an extra QWidget wrapper is necessary...
|
||||
// without it the dock widget seems to be partially transparent.
|
||||
QWidget *tmp = new QWidget;
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->addWidget(new StatusControl(this));
|
||||
tmp->setLayout(layout);
|
||||
setWidget(tmp);
|
||||
}
|
||||
|
||||
void saveDock(obs_data_t *obj)
|
||||
Loading…
Reference in New Issue
Block a user