mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-25 03:15:33 -05:00
Add option to disable registering of pause control hotkeys
This commit is contained in:
parent
22a361f977
commit
b5eb0b3f3e
|
|
@ -82,6 +82,7 @@ AdvSceneSwitcher.macroTab.minimize="Minimize"
|
|||
AdvSceneSwitcher.macroTab.highlightExecutedMacros="Highlight recently executed macros"
|
||||
AdvSceneSwitcher.macroTab.highlightTrueConditions="Highlight conditions of currently selected macro that evaluated to true recently"
|
||||
AdvSceneSwitcher.macroTab.highlightPerformedActions="Highlight recently performed actions of currently selected macro"
|
||||
AdvSceneSwitcher.macroTab.disableHotkeys="Register hotkeys to control pause state of selected macro"
|
||||
|
||||
; Macro Logic
|
||||
AdvSceneSwitcher.logic.none="Ignore entry"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
#include <obs-data.h>
|
||||
|
||||
// Global macro properties
|
||||
class MacroProperties {
|
||||
public:
|
||||
void Save(obs_data_t *obj);
|
||||
|
|
@ -15,15 +17,19 @@ public:
|
|||
bool _highlightActions = false;
|
||||
};
|
||||
|
||||
// Dialog for configuring global and macro specific settings
|
||||
class MacroPropertiesDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroPropertiesDialog(QWidget *parent, const MacroProperties &);
|
||||
static bool AskForSettings(QWidget *parent, MacroProperties &userInput);
|
||||
MacroPropertiesDialog(QWidget *parent, const MacroProperties &,
|
||||
Macro *macro);
|
||||
static bool AskForSettings(QWidget *parent, MacroProperties &userInput,
|
||||
Macro *macro);
|
||||
|
||||
private:
|
||||
QCheckBox *_executed;
|
||||
QCheckBox *_conditions;
|
||||
QCheckBox *_actions;
|
||||
QCheckBox *_hotkeys;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public:
|
|||
bool OnChangePreventedActionsRecently();
|
||||
void ResetUIHelpers();
|
||||
|
||||
void EnablePauseHotkeys(bool);
|
||||
bool PauseHotkeysEnabled();
|
||||
|
||||
private:
|
||||
void SetupHotkeys();
|
||||
void ClearHotkeys();
|
||||
|
|
@ -132,6 +135,7 @@ private:
|
|||
bool _matchOnChange = false;
|
||||
bool _paused = false;
|
||||
int _count = 0;
|
||||
bool _registerHotkeys = true;
|
||||
obs_hotkey_id _pauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
|
|
|
|||
|
|
@ -31,14 +31,17 @@ void MacroProperties::Load(obs_data_t *obj)
|
|||
}
|
||||
|
||||
MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
||||
const MacroProperties &prop)
|
||||
const MacroProperties &prop,
|
||||
Macro *macro)
|
||||
: QDialog(parent),
|
||||
_executed(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.highlightExecutedMacros"))),
|
||||
_conditions(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.highlightTrueConditions"))),
|
||||
_actions(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.highlightPerformedActions")))
|
||||
"AdvSceneSwitcher.macroTab.highlightPerformedActions"))),
|
||||
_hotkeys(new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.macroTab.disableHotkeys")))
|
||||
{
|
||||
setModal(true);
|
||||
setWindowModality(Qt::WindowModality::WindowModal);
|
||||
|
|
@ -49,11 +52,17 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
_executed->setChecked(prop._highlightExecuted);
|
||||
_conditions->setChecked(prop._highlightConditions);
|
||||
_actions->setChecked(prop._highlightActions);
|
||||
if (macro) {
|
||||
_hotkeys->setChecked(macro->PauseHotkeysEnabled());
|
||||
} else {
|
||||
_hotkeys->hide();
|
||||
}
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(_executed);
|
||||
layout->addWidget(_conditions);
|
||||
layout->addWidget(_actions);
|
||||
layout->addWidget(_hotkeys);
|
||||
setLayout(layout);
|
||||
|
||||
QDialogButtonBox *buttonbox = new QDialogButtonBox(
|
||||
|
|
@ -65,9 +74,10 @@ MacroPropertiesDialog::MacroPropertiesDialog(QWidget *parent,
|
|||
}
|
||||
|
||||
bool MacroPropertiesDialog::AskForSettings(QWidget *parent,
|
||||
MacroProperties &userInput)
|
||||
MacroProperties &userInput,
|
||||
Macro *macro)
|
||||
{
|
||||
MacroPropertiesDialog dialog(parent, userInput);
|
||||
MacroPropertiesDialog dialog(parent, userInput, macro);
|
||||
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||
if (dialog.exec() != DialogCode::Accepted) {
|
||||
return false;
|
||||
|
|
@ -75,5 +85,8 @@ bool MacroPropertiesDialog::AskForSettings(QWidget *parent,
|
|||
userInput._highlightExecuted = dialog._executed->isChecked();
|
||||
userInput._highlightConditions = dialog._conditions->isChecked();
|
||||
userInput._highlightActions = dialog._actions->isChecked();
|
||||
if (macro) {
|
||||
macro->EnablePauseHotkeys(dialog._hotkeys->isChecked());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,7 +408,8 @@ void AdvSceneSwitcher::HighlightOnChange()
|
|||
void AdvSceneSwitcher::on_macroProperties_clicked()
|
||||
{
|
||||
MacroProperties prop = switcher->macroProperties;
|
||||
bool accepted = MacroPropertiesDialog::AskForSettings(this, prop);
|
||||
bool accepted = MacroPropertiesDialog::AskForSettings(
|
||||
this, prop, getSelectedMacro());
|
||||
if (!accepted) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ const std::map<LogicType, LogicTypeInfo> MacroCondition::logicTypes = {
|
|||
|
||||
Macro::Macro(const std::string &name)
|
||||
{
|
||||
SetupHotkeys();
|
||||
SetName(name);
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +261,7 @@ bool Macro::Save(obs_data_t *obj)
|
|||
obs_data_set_bool(obj, "parallel", _runInParallel);
|
||||
obs_data_set_bool(obj, "onChange", _matchOnChange);
|
||||
|
||||
obs_data_set_bool(obj, "registerHotkeys", _registerHotkeys);
|
||||
obs_data_array_t *pauseHotkey = obs_hotkey_save(_pauseHotkey);
|
||||
obs_data_set_array(obj, "pauseHotkey", pauseHotkey);
|
||||
obs_data_array_release(pauseHotkey);
|
||||
|
|
@ -341,6 +341,11 @@ bool Macro::Load(obs_data_t *obj)
|
|||
_runInParallel = obs_data_get_bool(obj, "parallel");
|
||||
_matchOnChange = obs_data_get_bool(obj, "onChange");
|
||||
|
||||
obs_data_set_default_bool(obj, "registerHotkeys", true);
|
||||
_registerHotkeys = obs_data_get_bool(obj, "registerHotkeys");
|
||||
if (_registerHotkeys) {
|
||||
SetupHotkeys();
|
||||
}
|
||||
obs_data_array_t *pauseHotkey = obs_data_get_array(obj, "pauseHotkey");
|
||||
obs_hotkey_load(_pauseHotkey, pauseHotkey);
|
||||
obs_data_array_release(pauseHotkey);
|
||||
|
|
@ -352,7 +357,6 @@ bool Macro::Load(obs_data_t *obj)
|
|||
obs_data_get_array(obj, "togglePauseHotkey");
|
||||
obs_hotkey_load(_togglePauseHotkey, togglePauseHotkey);
|
||||
obs_data_array_release(togglePauseHotkey);
|
||||
|
||||
SetHotkeysDesc();
|
||||
|
||||
bool root = true;
|
||||
|
|
@ -470,6 +474,25 @@ void Macro::ResetUIHelpers()
|
|||
}
|
||||
}
|
||||
|
||||
void Macro::EnablePauseHotkeys(bool value)
|
||||
{
|
||||
if (_registerHotkeys == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_registerHotkeys) {
|
||||
ClearHotkeys();
|
||||
} else {
|
||||
SetupHotkeys();
|
||||
}
|
||||
_registerHotkeys = value;
|
||||
}
|
||||
|
||||
bool Macro::PauseHotkeysEnabled()
|
||||
{
|
||||
return _registerHotkeys;
|
||||
}
|
||||
|
||||
static void pauseCB(void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed)
|
||||
{
|
||||
if (pressed) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user