mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-24 06:48:24 -05:00
allow selection of previous scene for exe,file,region,window and scene group for idle switches (#106)
This commit is contained in:
parent
fe9457427f
commit
69d452f978
|
|
@ -160,11 +160,7 @@ AdvSceneSwitcher.timeTab.entry="{{triggers}} um {{time}} wechsle zu {{scenes}} m
|
|||
; Idle Tab
|
||||
AdvSceneSwitcher.idleTab.title="Inaktivitätserkennung"
|
||||
AdvSceneSwitcher.idleTab.enable="Aktiviere Inaktivitätserkennung"
|
||||
AdvSceneSwitcher.idleTab.condition1="Nach "
|
||||
AdvSceneSwitcher.idleTab.condition2="ohne Keyboard- oder Mauseingaben"
|
||||
AdvSceneSwitcher.idleTab.switchToScene="wechsle zu Szene"
|
||||
AdvSceneSwitcher.idleTab.usingTransition1="mit"
|
||||
AdvSceneSwitcher.idleTab.usingTransition2=" "
|
||||
AdvSceneSwitcher.idleTab.idleswitch="After {{duration}} ohne Keyboard- oder Mauseingaben wechsle zu {{scenes}} mit {{transitions}}"
|
||||
AdvSceneSwitcher.idleTab.dontSwitchIfFocus1="Wechsle nicht wenn"
|
||||
AdvSceneSwitcher.idleTab.dontSwitchIfFocus2="im Fokus ist"
|
||||
|
||||
|
|
|
|||
|
|
@ -160,11 +160,7 @@ AdvSceneSwitcher.timeTab.entry="{{triggers}} at {{time}} switch to {{scenes}} us
|
|||
; Idle Tab
|
||||
AdvSceneSwitcher.idleTab.title="Idle"
|
||||
AdvSceneSwitcher.idleTab.enable="Enable Idle Detection"
|
||||
AdvSceneSwitcher.idleTab.condition1="After "
|
||||
AdvSceneSwitcher.idleTab.condition2="of no keyboard or mouse inputs "
|
||||
AdvSceneSwitcher.idleTab.switchToScene="switch to scene"
|
||||
AdvSceneSwitcher.idleTab.usingTransition1="using the"
|
||||
AdvSceneSwitcher.idleTab.usingTransition2="transition"
|
||||
AdvSceneSwitcher.idleTab.idleswitch="After {{duration}} of no keyboard or mouse inputs switch to scene {{scenes}} using the {{transitions}}"
|
||||
AdvSceneSwitcher.idleTab.dontSwitchIfFocus1="Do not switch if"
|
||||
AdvSceneSwitcher.idleTab.dontSwitchIfFocus2="is in focus"
|
||||
|
||||
|
|
|
|||
|
|
@ -2482,91 +2482,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_26">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.idleTab.condition1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="idleSpinBox">
|
||||
<property name="suffix">
|
||||
<string>s</string>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.idleTab.condition2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.idleTab.switchToScene</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="idleScenes">
|
||||
<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_28">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.idleTab.usingTransition1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="idleTransitions"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.idleTab.usingTransition2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_25">
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="idleWidgetLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_25">
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ public:
|
|||
void UpdateNonMatchingScene(const QString &name);
|
||||
void UpdateAutoStopScene(const QString &name);
|
||||
void UpdateAutoStartScene(const QString &name);
|
||||
void UpdateIdleDataTransition(const QString &name);
|
||||
void UpdateIdleDataScene(const QString &name);
|
||||
void SetEditSceneGroup(SceneGroup &sg);
|
||||
|
||||
void loadUI();
|
||||
|
|
@ -167,9 +165,6 @@ public slots:
|
|||
void on_executableRemove_clicked();
|
||||
|
||||
void on_idleCheckBox_stateChanged(int state);
|
||||
void on_idleTransitions_currentTextChanged(const QString &text);
|
||||
void on_idleScenes_currentTextChanged(const QString &text);
|
||||
void on_idleSpinBox_valueChanged(int i);
|
||||
void on_ignoreIdleWindows_currentRowChanged(int idx);
|
||||
void on_ignoreIdleAdd_clicked();
|
||||
void on_ignoreIdleRemove_clicked();
|
||||
|
|
|
|||
|
|
@ -15,3 +15,18 @@ struct IdleData : SceneSwitcherEntry {
|
|||
void save(obs_data_t *obj);
|
||||
void load(obs_data_t *obj);
|
||||
};
|
||||
|
||||
class IdleWidget : public SwitchWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IdleWidget(QWidget *parent, IdleData *s);
|
||||
|
||||
private slots:
|
||||
void DurationChanged(int dur);
|
||||
|
||||
private:
|
||||
QSpinBox *duration;
|
||||
|
||||
IdleData *switchData;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ void ExecutableSwitch::load(obs_data_t *obj)
|
|||
|
||||
ExecutableSwitchWidget::ExecutableSwitchWidget(QWidget *parent,
|
||||
ExecutableSwitch *s)
|
||||
: SwitchWidget(parent, s, false, true)
|
||||
: SwitchWidget(parent, s, true, true)
|
||||
{
|
||||
processes = new QComboBox();
|
||||
requiresFocus = new QCheckBox(obs_module_text(
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ void FileSwitch::load(obs_data_t *obj)
|
|||
}
|
||||
|
||||
FileSwitchWidget::FileSwitchWidget(QWidget *parent, FileSwitch *s)
|
||||
: SwitchWidget(parent, s, false, true)
|
||||
: SwitchWidget(parent, s, true, true)
|
||||
{
|
||||
fileType = new QComboBox();
|
||||
filePath = new QLineEdit();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "headers/utility.hpp"
|
||||
|
||||
bool IdleData::pause = false;
|
||||
IdleWidget *idleWidget = nullptr;
|
||||
|
||||
void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
|
|
@ -57,69 +58,14 @@ void AdvSceneSwitcher::on_idleCheckBox_stateChanged(int state)
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
ui->idleScenes->setDisabled(true);
|
||||
ui->idleSpinBox->setDisabled(true);
|
||||
ui->idleTransitions->setDisabled(true);
|
||||
|
||||
switcher->idleData.idleEnable = false;
|
||||
idleWidget->setDisabled(true);
|
||||
} else {
|
||||
ui->idleScenes->setDisabled(false);
|
||||
ui->idleSpinBox->setDisabled(false);
|
||||
ui->idleTransitions->setDisabled(false);
|
||||
|
||||
switcher->idleData.idleEnable = true;
|
||||
|
||||
UpdateIdleDataTransition(ui->idleTransitions->currentText());
|
||||
UpdateIdleDataScene(ui->idleScenes->currentText());
|
||||
idleWidget->setDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::UpdateIdleDataTransition(const QString &name)
|
||||
{
|
||||
obs_weak_source_t *transition = GetWeakTransitionByQString(name);
|
||||
switcher->idleData.transition = transition;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::UpdateIdleDataScene(const QString &name)
|
||||
{
|
||||
switcher->idleData.usePreviousScene =
|
||||
(name ==
|
||||
obs_module_text("AdvSceneSwitcher.selectPreviousScene"));
|
||||
obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData());
|
||||
obs_weak_source_t *ws = obs_source_get_weak_source(scene);
|
||||
|
||||
switcher->idleData.scene = ws;
|
||||
|
||||
obs_weak_source_release(ws);
|
||||
obs_source_release(scene);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_idleTransitions_currentTextChanged(const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateIdleDataTransition(text);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_idleScenes_currentTextChanged(const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateIdleDataScene(text);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_idleSpinBox_valueChanged(int i)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->idleData.time = i;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_ignoreIdleWindows_currentRowChanged(int idx)
|
||||
{
|
||||
if (loading)
|
||||
|
|
@ -250,8 +196,6 @@ void SwitcherData::loadIdleSwitches(obs_data_t *obj)
|
|||
|
||||
void AdvSceneSwitcher::setupIdleTab()
|
||||
{
|
||||
populateSceneSelection(ui->idleScenes, true, false);
|
||||
populateTransitionSelection(ui->idleTransitions);
|
||||
populateWindowSelection(ui->ignoreIdleWindowsWindows);
|
||||
|
||||
for (auto &window : switcher->ignoreIdleWindows) {
|
||||
|
|
@ -262,26 +206,14 @@ void AdvSceneSwitcher::setupIdleTab()
|
|||
item->setData(Qt::UserRole, text);
|
||||
}
|
||||
|
||||
idleWidget = new IdleWidget(this, &switcher->idleData);
|
||||
ui->idleWidgetLayout->addWidget(idleWidget);
|
||||
ui->idleCheckBox->setChecked(switcher->idleData.idleEnable);
|
||||
if (switcher->idleData.usePreviousScene) {
|
||||
ui->idleScenes->setCurrentText(obs_module_text(
|
||||
"AdvSceneSwitcher.selectPreviousScene"));
|
||||
} else {
|
||||
ui->idleScenes->setCurrentText(
|
||||
GetWeakSourceName(switcher->idleData.scene).c_str());
|
||||
}
|
||||
ui->idleTransitions->setCurrentText(
|
||||
GetWeakSourceName(switcher->idleData.transition).c_str());
|
||||
ui->idleSpinBox->setValue(switcher->idleData.time);
|
||||
|
||||
if (ui->idleCheckBox->checkState()) {
|
||||
ui->idleScenes->setDisabled(false);
|
||||
ui->idleSpinBox->setDisabled(false);
|
||||
ui->idleTransitions->setDisabled(false);
|
||||
idleWidget->setDisabled(false);
|
||||
} else {
|
||||
ui->idleScenes->setDisabled(true);
|
||||
ui->idleSpinBox->setDisabled(true);
|
||||
ui->idleTransitions->setDisabled(true);
|
||||
idleWidget->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,3 +234,41 @@ void IdleData::load(obs_data_t *obj)
|
|||
idleEnable = obs_data_get_bool(obj, "idleEnable");
|
||||
time = obs_data_get_int(obj, "idleTime");
|
||||
}
|
||||
|
||||
IdleWidget::IdleWidget(QWidget *parent, IdleData *s)
|
||||
: SwitchWidget(parent, s, true, true)
|
||||
{
|
||||
duration = new QSpinBox();
|
||||
|
||||
duration->setMinimum(0);
|
||||
duration->setMaximum(1000000);
|
||||
duration->setSuffix("s");
|
||||
|
||||
QWidget::connect(duration, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(DurationChanged(int)));
|
||||
|
||||
if (s) {
|
||||
duration->setValue(s->time);
|
||||
}
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{duration}}", duration},
|
||||
{"{{scenes}}", scenes},
|
||||
{"{{transitions}}", transitions}};
|
||||
placeWidgets(obs_module_text("AdvSceneSwitcher.idleTab.idleswitch"),
|
||||
mainLayout, widgetPlaceholders);
|
||||
setLayout(mainLayout);
|
||||
|
||||
switchData = s;
|
||||
|
||||
loading = false;
|
||||
}
|
||||
|
||||
void IdleWidget::DurationChanged(int dur)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->idleData.time = dur;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ void ScreenRegionSwitch::load(obs_data_t *obj)
|
|||
}
|
||||
|
||||
ScreenRegionWidget::ScreenRegionWidget(QWidget *parent, ScreenRegionSwitch *s)
|
||||
: SwitchWidget(parent, s, false, true)
|
||||
: SwitchWidget(parent, s, true, true)
|
||||
{
|
||||
minX = new QSpinBox();
|
||||
minY = new QSpinBox();
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ void WindowSwitch::load(obs_data_t *obj)
|
|||
}
|
||||
|
||||
WindowSwitchWidget::WindowSwitchWidget(QWidget *parent, WindowSwitch *s)
|
||||
: SwitchWidget(parent, s, false, true)
|
||||
: SwitchWidget(parent, s, true, true)
|
||||
{
|
||||
windows = new QComboBox();
|
||||
fullscreen = new QCheckBox(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user