update UI of scene sequence tab

This commit is contained in:
WarmUpTill
2020-10-18 01:51:07 +02:00
parent 3ac795fc72
commit 491108678e
7 changed files with 288 additions and 470 deletions

View File

@@ -46,7 +46,7 @@ if(BUILD_OUT_OF_TREE)
src/headers/switch-time.hpp
src/headers/switch-transitions.hpp
src/headers/switch-window.hpp
src/headers/swtich-sequence.hpp
src/headers/switch-sequence.hpp
src/headers/switch-generic.hpp
)
@@ -196,7 +196,7 @@ else ()
src/headers/switch-time.hpp
src/headers/switch-transitions.hpp
src/headers/switch-window.hpp
src/headers/swtich-sequence.hpp
src/headers/switch-sequence.hpp
src/headers/switch-generic.hpp
)

View File

@@ -2814,99 +2814,6 @@
<string notr="true">Sequence</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>When</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sceneSequenceScenes1">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>is active switch to</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sceneSequenceScenes2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>after</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sceneSequenceSpinBox">
<property name="suffix">
<string/>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sceneSequenceDelayUnits"/>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>using</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sceneSequenceTransitions"/>
</item>
<item>
<spacer name="horizontalSpacer_9">
<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>
<widget class="QLabel" name="label_35">
<property name="text">
@@ -3059,19 +2966,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="intervalWarning">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>SWITCHER CONDITION CHECK INTERVAL LONGER THAN SHORTEST SCENE ROUND TRIP WAIT (This might lead to undesired switching behaviour)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -36,7 +36,6 @@ public:
int PauseScenesFindByData(const QString &scene);
int PauseWindowsFindByData(const QString &window);
int IgnoreWindowsFindByData(const QString &window);
int SceneSequenceFindByData(const QString &scene1);
int SceneTransitionsFindByData(const QString &scene1,
const QString &scene2);
int DefaultTransitionsFindByData(const QString &scene);
@@ -117,14 +116,12 @@ public slots:
void on_ignoreWindowsAdd_clicked();
void on_ignoreWindowsRemove_clicked();
void on_sceneSequences_currentRowChanged(int idx);
void on_sceneSequenceAdd_clicked();
void on_sceneSequenceRemove_clicked();
void on_sceneSequenceSave_clicked();
void on_sceneSequenceLoad_clicked();
void on_sceneSequenceUp_clicked();
void on_sceneSequenceDown_clicked();
void on_sceneSequenceDelayUnits_currentIndexChanged(int index);
void on_autoStopSceneCheckBox_stateChanged(int state);
void on_autoStopScenes_currentTextChanged(const QString &text);

View File

@@ -0,0 +1,65 @@
#pragma once
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto round_trip_func = 1;
constexpr auto default_priority_1 = round_trip_func;
typedef enum {
SECONDS,
MINUTES,
HOURS,
} delay_units;
struct SceneSequenceSwitch : SceneSwitcherEntry {
OBSWeakSource startScene = nullptr;
double delay = 0;
int delayMultiplier = 1;
const char *getType() { return "sequence"; }
bool initialized();
bool valid();
void logSleep(int dur);
inline SceneSequenceSwitch(){};
inline SceneSequenceSwitch(OBSWeakSource startScene_,
OBSWeakSource scene_,
OBSWeakSource transition_, double delay_,
int delayMultiplier_, bool usePreviousScene_)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
startScene(startScene_),
delay(delay_),
delayMultiplier(delayMultiplier_)
{
}
};
class SequenceWidget : public SwitchWidget {
Q_OBJECT
public:
SequenceWidget(SceneSequenceSwitch *s);
SceneSequenceSwitch *getSwitchData();
void setSwitchData(SceneSequenceSwitch *s);
static void swapSwitchData(SequenceWidget *s1, SequenceWidget *s2);
void UpdateDelay();
private slots:
void DelayChanged(double delay);
void DelayUnitsChanged(int idx);
void StartSceneChanged(const QString &text);
private:
QDoubleSpinBox *delay;
QComboBox *delayUnits;
QComboBox *startScenes;
QLabel *whenLabel;
QLabel *switchLabel;
QLabel *afterLabel;
QLabel *usingLabel;
SceneSequenceSwitch *switchData;
};

View File

@@ -18,7 +18,7 @@
#include "switch-time.hpp"
#include "switch-transitions.hpp"
#include "switch-window.hpp"
#include "swtich-sequence.hpp"
#include "switch-sequence.hpp"
constexpr auto default_interval = 300;
constexpr auto previous_scene_name = "Previous Scene";
@@ -72,8 +72,7 @@ struct SwitcherData {
std::vector<std::string> ignoreWindowsSwitches;
std::vector<SceneSequenceSwitch> sceneSequenceSwitches;
int sceneSequenceMultiplier = 1;
std::deque<SceneSequenceSwitch> sceneSequenceSwitches;
std::deque<RandomSwitch> randomSwitches;

View File

@@ -1,44 +0,0 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto round_trip_func = 1;
constexpr auto default_priority_1 = round_trip_func;
struct SceneSequenceSwitch : SceneSwitcherEntry {
OBSWeakSource startScene;
double delay;
std::string sceneSequenceStr;
const char *getType() { return "sequence"; }
bool valid()
{
return WeakSourceValid(startScene) &&
(usePreviousScene || WeakSourceValid(scene)) &&
WeakSourceValid(transition);
}
void logSleep(int dur)
{
blog(LOG_INFO, "Advanced Scene Switcher sequence sleep %d",
dur);
}
inline SceneSequenceSwitch(OBSWeakSource startScene_,
OBSWeakSource scene_,
OBSWeakSource transition_, double delay_,
bool usePreviousScene_, std::string str)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
startScene(startScene_),
delay(delay_),
sceneSequenceStr(str)
{
}
};
static inline QString MakeSceneSequenceSwitchName(const QString &scene1,
const QString &scene2,
const QString &transition,
double delay);

View File

@@ -4,102 +4,22 @@
#include "headers/advanced-scene-switcher.hpp"
constexpr auto seconds_index = 0;
constexpr auto minutes_index = 1;
constexpr auto hours_index = 2;
void SceneSwitcher::on_sceneSequenceDelayUnits_currentIndexChanged(int index)
{
if (loading)
return;
std::lock_guard<std::mutex> lock(switcher->m);
double val = ui->sceneSequenceSpinBox->value();
switch (switcher->sceneSequenceMultiplier) {
case 1:
val /= pow(60, index);
break;
case 60:
val /= pow(60, index - 1);
break;
case 3600:
val /= pow(60, index - 2);
break;
}
ui->sceneSequenceSpinBox->setValue(val);
switch (index) {
case seconds_index:
switcher->sceneSequenceMultiplier = 1;
break;
case minutes_index:
switcher->sceneSequenceMultiplier = 60;
break;
case hours_index:
switcher->sceneSequenceMultiplier = 3600;
break;
}
}
static QMetaObject::Connection addPulse;
void SceneSwitcher::on_sceneSequenceAdd_clicked()
{
QString scene1Name = ui->sceneSequenceScenes1->currentText();
QString scene2Name = ui->sceneSequenceScenes2->currentText();
QString transitionName = ui->sceneSequenceTransitions->currentText();
ui->sceneSequences->disconnect(addPulse);
if (scene1Name.isEmpty() || scene2Name.isEmpty())
return;
std::lock_guard<std::mutex> lock(switcher->m);
switcher->sceneSequenceSwitches.emplace_back();
double delay = ui->sceneSequenceSpinBox->value() *
switcher->sceneSequenceMultiplier;
if (scene1Name == scene2Name)
return;
OBSWeakSource source1 = GetWeakSourceByQString(scene1Name);
OBSWeakSource source2 = GetWeakSourceByQString(scene2Name);
OBSWeakSource transition = GetWeakTransitionByQString(transitionName);
QString text = MakeSceneSequenceSwitchName(scene1Name, scene2Name,
transitionName, delay);
QVariant v = QVariant::fromValue(text);
int idx = SceneSequenceFindByData(scene1Name);
if (idx == -1) {
QListWidgetItem *item =
new QListWidgetItem(text, ui->sceneSequences);
item->setData(Qt::UserRole, v);
std::lock_guard<std::mutex> lock(switcher->m);
switcher->sceneSequenceSwitches.emplace_back(
source1, source2, transition, delay,
(scene2Name == QString(previous_scene_name)),
text.toUtf8().constData());
} else {
QListWidgetItem *item = ui->sceneSequences->item(idx);
item->setText(text);
{
std::lock_guard<std::mutex> lock(switcher->m);
for (auto &s : switcher->sceneSequenceSwitches) {
if (s.startScene == source1) {
s.scene = source2;
s.delay = delay;
s.transition = transition;
s.usePreviousScene =
(scene2Name ==
QString(previous_scene_name));
s.sceneSequenceStr =
text.toUtf8().constData();
break;
}
}
}
}
QListWidgetItem *item;
item = new QListWidgetItem(ui->sceneSequences);
ui->sceneSequences->addItem(item);
SequenceWidget *sw =
new SequenceWidget(&switcher->sceneSequenceSwitches.back());
item->setSizeHint(sw->minimumSizeHint());
ui->sceneSequences->setItemWidget(item, sw);
}
void SceneSwitcher::on_sceneSequenceRemove_clicked()
@@ -108,26 +28,53 @@ void SceneSwitcher::on_sceneSequenceRemove_clicked()
if (!item)
return;
std::string text =
item->data(Qt::UserRole).toString().toUtf8().constData();
{
std::lock_guard<std::mutex> lock(switcher->m);
int idx = ui->sceneSequences->currentRow();
auto &switches = switcher->sceneSequenceSwitches;
for (auto it = switches.begin(); it != switches.end(); ++it) {
auto &s = *it;
if (s.sceneSequenceStr == text) {
switches.erase(it);
break;
}
}
switches.erase(switches.begin() + idx);
}
delete item;
}
void SceneSwitcher::on_sceneSequenceUp_clicked()
{
int index = ui->sceneSequences->currentRow();
if (!listMoveUp(ui->sceneSequences))
return;
SequenceWidget *s1 = (SequenceWidget *)ui->sceneSequences->itemWidget(
ui->sceneSequences->item(index));
SequenceWidget *s2 = (SequenceWidget *)ui->sceneSequences->itemWidget(
ui->sceneSequences->item(index - 1));
SequenceWidget::swapSwitchData(s1, s2);
std::lock_guard<std::mutex> lock(switcher->m);
std::swap(switcher->sceneSequenceSwitches[index],
switcher->sceneSequenceSwitches[index - 1]);
}
void SceneSwitcher::on_sceneSequenceDown_clicked()
{
int index = ui->sceneSequences->currentRow();
if (!listMoveDown(ui->sceneSequences))
return;
SequenceWidget *s1 = (SequenceWidget *)ui->sceneSequences->itemWidget(
ui->sceneSequences->item(index));
SequenceWidget *s2 = (SequenceWidget *)ui->sceneSequences->itemWidget(
ui->sceneSequences->item(index + 1));
SequenceWidget::swapSwitchData(s1, s2);
std::lock_guard<std::mutex> lock(switcher->m);
std::swap(switcher->sceneSequenceSwitches[index],
switcher->sceneSequenceSwitches[index + 1]);
}
void SceneSwitcher::on_sceneSequenceSave_clicked()
{
QString directory = QFileDialog::getSaveFileName(
@@ -145,50 +92,6 @@ void SceneSwitcher::on_sceneSequenceSave_clicked()
obs_data_release(obj);
}
// to be removed once support for old file format is dropped
bool oldSceneRoundTripLoad(QFile *file)
{
QTextStream in(file);
std::vector<QString> lines;
std::vector<SceneSequenceSwitch> newSceneRoundTripSwitch;
while (!in.atEnd()) {
QString line = in.readLine();
lines.push_back(line);
if (lines.size() == 5) {
OBSWeakSource scene1 = GetWeakSourceByQString(lines[0]);
OBSWeakSource scene2 = GetWeakSourceByQString(lines[1]);
OBSWeakSource transition =
GetWeakTransitionByQString(lines[4]);
if (WeakSourceValid(scene1) &&
((lines[1] == QString(previous_scene_name)) ||
(WeakSourceValid(scene2))) &&
WeakSourceValid(transition)) {
newSceneRoundTripSwitch.emplace_back(
SceneSequenceSwitch(
GetWeakSourceByQString(lines[0]),
GetWeakSourceByQString(lines[1]),
GetWeakTransitionByQString(
lines[4]),
lines[2].toDouble() / 1000.,
(lines[1] ==
QString(previous_scene_name)),
lines[3].toStdString()));
}
lines.clear();
}
}
if (lines.size() != 0 || newSceneRoundTripSwitch.size() == 0)
return false;
switcher->sceneSequenceSwitches.clear();
switcher->sceneSequenceSwitches = newSceneRoundTripSwitch;
return true;
}
void SceneSwitcher::on_sceneSequenceLoad_clicked()
{
std::lock_guard<std::mutex> lock(switcher->m);
@@ -208,23 +111,9 @@ void SceneSwitcher::on_sceneSequenceLoad_clicked()
if (!obj) {
QMessageBox Msgbox;
QString txt =
"Advanced Scene Switcher failed to import settings!\n";
txt += "Falling back to old format.";
Msgbox.setText(txt);
Msgbox.setText(
"Advanced Scene Switcher failed to import settings!");
Msgbox.exec();
if (oldSceneRoundTripLoad(&file)) {
QString txt =
"Advanced Scene Switcher settings imported successfully!\n";
txt += "Please resave settings as support for old format will be dropped in next version.";
Msgbox.setText(txt);
Msgbox.exec();
close();
} else {
Msgbox.setText(
"Advanced Scene Switcher failed to import settings!");
Msgbox.exec();
}
return;
}
switcher->loadSceneSequenceSwitches(obj);
@@ -238,13 +127,16 @@ void SceneSwitcher::on_sceneSequenceLoad_clicked()
}
void SwitcherData::checkSceneSequence(bool &match, OBSWeakSource &scene,
OBSWeakSource &transition,
std::unique_lock<std::mutex> &lock)
OBSWeakSource &transition,
std::unique_lock<std::mutex> &lock)
{
obs_source_t *currentSource = obs_frontend_get_current_scene();
obs_weak_source_t *ws = obs_source_get_weak_source(currentSource);
for (SceneSequenceSwitch &s : sceneSequenceSwitches) {
if (!s.initialized())
continue;
if (s.startScene == ws) {
int dur = s.delay * 1000 - interval;
if (dur > 0) {
@@ -277,87 +169,6 @@ void SwitcherData::checkSceneSequence(bool &match, OBSWeakSource &scene,
obs_weak_source_release(ws);
}
void SceneSwitcher::on_sceneSequences_currentRowChanged(int idx)
{
if (loading)
return;
if (idx == -1)
return;
QListWidgetItem *item = ui->sceneSequences->item(idx);
QString sceneSequence = item->text();
std::lock_guard<std::mutex> lock(switcher->m);
for (auto &s : switcher->sceneSequenceSwitches) {
if (sceneSequence.compare(s.sceneSequenceStr.c_str()) == 0) {
std::string scene1 = GetWeakSourceName(s.startScene);
std::string scene2 = GetWeakSourceName(s.scene);
std::string transitionName =
GetWeakSourceName(s.transition);
double delay = s.delay /
switcher->sceneSequenceMultiplier;
ui->sceneSequenceScenes1->setCurrentText(
scene1.c_str());
ui->sceneSequenceScenes2->setCurrentText(
scene2.c_str());
ui->sceneSequenceTransitions->setCurrentText(
transitionName.c_str());
ui->sceneSequenceSpinBox->setValue(delay);
break;
}
}
}
int SceneSwitcher::SceneSequenceFindByData(const QString &scene1)
{
QRegExp rx(scene1 + " ->.*");
int count = ui->sceneSequences->count();
int idx = -1;
for (int i = 0; i < count; i++) {
QListWidgetItem *item = ui->sceneSequences->item(i);
QString itemString = item->data(Qt::UserRole).toString();
if (rx.exactMatch(itemString)) {
idx = i;
break;
}
}
return idx;
}
void SceneSwitcher::on_sceneSequenceUp_clicked()
{
int index = ui->sceneSequences->currentRow();
if (index != -1 && index != 0) {
ui->sceneSequences->insertItem(
index - 1, ui->sceneSequences->takeItem(index));
ui->sceneSequences->setCurrentRow(index - 1);
std::lock_guard<std::mutex> lock(switcher->m);
iter_swap(switcher->sceneSequenceSwitches.begin() + index,
switcher->sceneSequenceSwitches.begin() + index - 1);
}
}
void SceneSwitcher::on_sceneSequenceDown_clicked()
{
int index = ui->sceneSequences->currentRow();
if (index != -1 && index != ui->sceneSequences->count() - 1) {
ui->sceneSequences->insertItem(
index + 1, ui->sceneSequences->takeItem(index));
ui->sceneSequences->setCurrentRow(index + 1);
std::lock_guard<std::mutex> lock(switcher->m);
iter_swap(switcher->sceneSequenceSwitches.begin() + index,
switcher->sceneSequenceSwitches.begin() + index + 1);
}
}
void SwitcherData::saveSceneSequenceSwitches(obs_data_t *obj)
{
obs_data_array_t *sceneSequenceArray = obs_data_array_create();
@@ -383,8 +194,9 @@ void SwitcherData::saveSceneSequenceSwitches(obs_data_t *obj)
obs_data_set_string(array_obj, "transition",
transitionName);
obs_data_set_double(array_obj, "delay", s.delay);
obs_data_array_push_back(sceneSequenceArray,
array_obj);
obs_data_set_int(array_obj, "delayMultiplier",
s.delayMultiplier);
obs_data_array_push_back(sceneSequenceArray, array_obj);
obs_source_release(source1);
obs_source_release(source2);
obs_source_release(transition);
@@ -414,34 +226,19 @@ void SwitcherData::loadSceneSequenceSwitches(obs_data_t *obj)
obs_data_get_string(array_obj, "sceneRoundTripScene2");
const char *transition =
obs_data_get_string(array_obj, "transition");
double delay = 0;
// To be removed in future version
// to be compatible with older versions
if (!obs_data_has_user_value(array_obj, "delay")) {
delay = double(obs_data_get_int(array_obj,
"sceneRoundTripDelay"));
delay = delay * 1000. +
double(obs_data_get_int(
array_obj, "sceneRoundTripDelayMs"));
delay /= 1000.;
} else {
delay = obs_data_get_double(array_obj, "delay");
}
std::string str = MakeSceneSequenceSwitchName(
scene1, scene2, transition, delay)
.toUtf8()
.constData();
const char *sceneSequenceStr = str.c_str();
double delay = obs_data_get_double(array_obj, "delay");
int delayMultiplier =
obs_data_get_int(array_obj, "delayMultiplier");
if (delayMultiplier == 0 ||
(delayMultiplier != 1 && delayMultiplier % 60 != 0))
delayMultiplier = 1;
switcher->sceneSequenceSwitches.emplace_back(
GetWeakSourceByName(scene1),
GetWeakSourceByName(scene2),
GetWeakTransitionByName(transition), delay,
(strcmp(scene2, previous_scene_name) == 0),
sceneSequenceStr);
delayMultiplier,
(strcmp(scene2, previous_scene_name) == 0));
obs_data_release(array_obj);
}
@@ -450,58 +247,168 @@ void SwitcherData::loadSceneSequenceSwitches(obs_data_t *obj)
void SceneSwitcher::setupSequenceTab()
{
populateSceneSelection(ui->sceneSequenceScenes1, false);
populateSceneSelection(ui->sceneSequenceScenes2, true);
populateTransitionSelection(ui->sceneSequenceTransitions);
double smallestDelay = double(switcher->interval) / 1000;
for (auto &s : switcher->sceneSequenceSwitches) {
std::string sceneName1 = GetWeakSourceName(s.startScene);
std::string sceneName2 = (s.usePreviousScene)
? previous_scene_name
: GetWeakSourceName(s.scene);
std::string transitionName = GetWeakSourceName(s.transition);
QString text = MakeSceneSequenceSwitchName(
sceneName1.c_str(), sceneName2.c_str(),
transitionName.c_str(), s.delay);
QListWidgetItem *item =
new QListWidgetItem(text, ui->sceneSequences);
item->setData(Qt::UserRole, text);
if (s.delay < smallestDelay)
smallestDelay = s.delay;
QListWidgetItem *item;
item = new QListWidgetItem(ui->sceneSequences);
ui->sceneSequences->addItem(item);
SequenceWidget *sw = new SequenceWidget(&s);
item->setSizeHint(sw->minimumSizeHint());
ui->sceneSequences->setItemWidget(item, sw);
}
(smallestDelay * 1000 < switcher->interval)
? ui->intervalWarning->setVisible(true)
: ui->intervalWarning->setVisible(false);
ui->sceneSequenceDelayUnits->addItem("seconds");
ui->sceneSequenceDelayUnits->addItem("minutes");
ui->sceneSequenceDelayUnits->addItem("hours");
if (switcher->sceneSequenceSwitches.size() == 0)
addPulse = PulseWidget(ui->sceneSequenceAdd, QColor(Qt::green));
}
switch (switcher->sceneSequenceMultiplier) {
case 1:
ui->sceneSequenceDelayUnits->setCurrentIndex(0);
bool SceneSequenceSwitch::initialized()
{
return SceneSwitcherEntry::initialized() && startScene;
}
bool SceneSequenceSwitch::valid()
{
return !initialized() ||
(SceneSwitcherEntry::valid() && WeakSourceValid(startScene));
}
void SceneSequenceSwitch::logSleep(int dur)
{
blog(LOG_INFO, "Advanced Scene Switcher sequence sleep %d", dur);
}
void populateDelayUnits(QComboBox *list)
{
list->addItem("seconds");
list->addItem("minutes");
list->addItem("hours");
}
SequenceWidget::SequenceWidget(SceneSequenceSwitch *s) : SwitchWidget(s, false)
{
delay = new QDoubleSpinBox();
delayUnits = new QComboBox();
startScenes = new QComboBox();
whenLabel = new QLabel("When");
switchLabel = new QLabel("is active switch to");
afterLabel = new QLabel("after");
usingLabel = new QLabel("using");
QWidget::connect(delay, SIGNAL(valueChanged(double)), this,
SLOT(DelayChanged(double)));
QWidget::connect(delayUnits, SIGNAL(currentIndexChanged(int)), this,
SLOT(DelayUnitsChanged(int)));
QWidget::connect(startScenes,
SIGNAL(currentTextChanged(const QString &)), this,
SLOT(StartSceneChanged(const QString &)));
delay->setMaximum(99999.000000);
SceneSwitcher::populateSceneSelection(startScenes, false);
populateDelayUnits(delayUnits);
if (s) {
switch (s->delayMultiplier) {
case 1:
delayUnits->setCurrentIndex(0);
break;
case 60:
delayUnits->setCurrentIndex(1);
break;
case 3600:
delayUnits->setCurrentIndex(2);
break;
default:
delayUnits->setCurrentIndex(0);
}
startScenes->setCurrentText(
GetWeakSourceName(s->startScene).c_str());
}
setStyleSheet("* { background-color: transparent; }");
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(whenLabel);
mainLayout->addWidget(startScenes);
mainLayout->addWidget(switchLabel);
mainLayout->addWidget(scenes);
mainLayout->addWidget(afterLabel);
mainLayout->addWidget(delay);
mainLayout->addWidget(delayUnits);
mainLayout->addWidget(usingLabel);
mainLayout->addWidget(transitions);
mainLayout->addStretch();
setLayout(mainLayout);
switchData = s;
loading = false;
UpdateDelay();
}
SceneSequenceSwitch *SequenceWidget::getSwitchData()
{
return switchData;
}
void SequenceWidget::setSwitchData(SceneSequenceSwitch *s)
{
switchData = s;
}
void SequenceWidget::swapSwitchData(SequenceWidget *s1, SequenceWidget *s2)
{
SwitchWidget::swapSwitchData(s1, s2);
SceneSequenceSwitch *t = s1->getSwitchData();
s1->setSwitchData(s2->getSwitchData());
s2->setSwitchData(t);
}
void SequenceWidget::UpdateDelay()
{
if (switchData)
delay->setValue(switchData->delay /
switchData->delayMultiplier);
}
void SequenceWidget::DelayChanged(double delay)
{
if (loading || !switchData)
return;
switchData->delay = delay * switchData->delayMultiplier;
}
void SequenceWidget::DelayUnitsChanged(int idx)
{
if (loading || !switchData)
return;
delay_units unit = (delay_units)idx;
switch (unit) {
case SECONDS:
switchData->delayMultiplier = 1;
break;
case 60:
ui->sceneSequenceDelayUnits->setCurrentIndex(1);
case MINUTES:
switchData->delayMultiplier = 60;
break;
case 3600:
ui->sceneSequenceDelayUnits->setCurrentIndex(2);
case HOURS:
switchData->delayMultiplier = 60 * 60;
break;
default:
break;
}
UpdateDelay();
}
static inline QString MakeSceneSequenceSwitchName(const QString &scene1,
const QString &scene2,
const QString &transition,
double delay)
void SequenceWidget::StartSceneChanged(const QString &text)
{
return scene1 + QStringLiteral(" -> wait for ") +
QString::number(delay) + QStringLiteral(" seconds -> ") +
scene2 + QStringLiteral(" (using ") + transition +
QStringLiteral(" transition)");
if (loading || !switchData)
return;
std::lock_guard<std::mutex> lock(switcher->m);
switchData->startScene = GetWeakSourceByQString(text);
}