mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-13 21:26:42 -05:00
Add hotkey to move current macro segment selection up / down
This commit is contained in:
parent
e61539a878
commit
9ba8a02a11
|
|
@ -708,6 +708,8 @@ AdvSceneSwitcher.hotkey.startStopToggleSwitcherHotkey="Toggle Start/Stop for the
|
|||
AdvSceneSwitcher.hotkey.macro.pause="Pause macro %1"
|
||||
AdvSceneSwitcher.hotkey.macro.unpause="Unpause macro %1"
|
||||
AdvSceneSwitcher.hotkey.macro.togglePause="Toggle pause of macro %1"
|
||||
AdvSceneSwitcher.hotkey.upMacroSegmentHotkey="Move macro segment selection up"
|
||||
AdvSceneSwitcher.hotkey.downMacroSegmentHotkey="Move macro segment selection down"
|
||||
AdvSceneSwitcher.hotkey.removeMacroSegmentHotkey="Remove selected macro segment"
|
||||
|
||||
AdvSceneSwitcher.askBackup="Detected a new version of the Advanced Scene Switcher.\nShould a backup of the old settings be created?"
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ public slots:
|
|||
void on_actionRemove_clicked();
|
||||
void on_actionUp_clicked();
|
||||
void on_actionDown_clicked();
|
||||
void UpMacroSegementHotkey();
|
||||
void DownMacroSegementHotkey();
|
||||
void DeleteMacroSegementHotkey();
|
||||
void ShowMacroContextMenu(const QPoint &);
|
||||
void ShowMacroActionsContextMenu(const QPoint &);
|
||||
|
|
@ -298,9 +300,16 @@ public slots:
|
|||
void on_close_clicked();
|
||||
|
||||
private:
|
||||
bool MacroTabIsInFocus();
|
||||
|
||||
MacroSegmentList *conditionsList = nullptr;
|
||||
MacroSegmentList *actionsList = nullptr;
|
||||
|
||||
enum class MacroSection {
|
||||
CONDITIONS,
|
||||
ACTIONS,
|
||||
};
|
||||
MacroSection lastInteracted = MacroSection::CONDITIONS;
|
||||
int currentConditionIdx = -1;
|
||||
int currentActionIdx = -1;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -219,6 +219,8 @@ struct SwitcherData {
|
|||
obs_hotkey_id startHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id stopHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id toggleHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id upMacroSegment = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id downMacroSegment = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id removeMacroSegment = OBS_INVALID_HOTKEY_ID;
|
||||
|
||||
bool saveWindowGeo = false;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,28 @@ void startStopToggleHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
|||
}
|
||||
}
|
||||
|
||||
void upMacroSegmentHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
||||
bool pressed)
|
||||
{
|
||||
if (pressed && switcher->settingsWindowOpened &&
|
||||
AdvSceneSwitcher::window) {
|
||||
QMetaObject::invokeMethod(AdvSceneSwitcher::window,
|
||||
"UpMacroSegementHotkey",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void downMacroSegmentHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
||||
bool pressed)
|
||||
{
|
||||
if (pressed && switcher->settingsWindowOpened &&
|
||||
AdvSceneSwitcher::window) {
|
||||
QMetaObject::invokeMethod(AdvSceneSwitcher::window,
|
||||
"DownMacroSegementHotkey",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void removeMacroSegmentHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
||||
bool pressed)
|
||||
{
|
||||
|
|
@ -60,6 +82,15 @@ void registerHotkeys()
|
|||
obs_module_text(
|
||||
"AdvSceneSwitcher.hotkey.startStopToggleSwitcherHotkey"),
|
||||
startStopToggleHotkeyFunc, NULL);
|
||||
switcher->upMacroSegment = obs_hotkey_register_frontend(
|
||||
"upMacroSegmentSwitcherHotkey",
|
||||
obs_module_text("AdvSceneSwitcher.hotkey.upMacroSegmentHotkey"),
|
||||
upMacroSegmentHotkeyFunc, NULL);
|
||||
switcher->downMacroSegment = obs_hotkey_register_frontend(
|
||||
"downMacroSegmentSwitcherHotkey",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.hotkey.downMacroSegmentHotkey"),
|
||||
downMacroSegmentHotkeyFunc, NULL);
|
||||
switcher->removeMacroSegment = obs_hotkey_register_frontend(
|
||||
"removeMacroSegmentSwitcherHotkey",
|
||||
obs_module_text(
|
||||
|
|
@ -69,26 +100,28 @@ void registerHotkeys()
|
|||
switcher->hotkeysRegistered = true;
|
||||
}
|
||||
|
||||
void saveHotkey(obs_data_t *obj, obs_hotkey_id id, const char *name)
|
||||
{
|
||||
obs_data_array_t *a = obs_hotkey_save(id);
|
||||
obs_data_set_array(obj, name, a);
|
||||
obs_data_array_release(a);
|
||||
}
|
||||
|
||||
void SwitcherData::saveHotkeys(obs_data_t *obj)
|
||||
{
|
||||
obs_data_array_t *startHotkeyArrray = obs_hotkey_save(startHotkey);
|
||||
obs_data_set_array(obj, "startHotkey", startHotkeyArrray);
|
||||
obs_data_array_release(startHotkeyArrray);
|
||||
saveHotkey(obj, startHotkey, "startHotkey");
|
||||
saveHotkey(obj, stopHotkey, "stopHotkey");
|
||||
saveHotkey(obj, toggleHotkey, "toggleHotkey");
|
||||
saveHotkey(obj, upMacroSegment, "upMacroSegmentHotkey");
|
||||
saveHotkey(obj, downMacroSegment, "downMacroSegmentHotkey");
|
||||
saveHotkey(obj, removeMacroSegment, "removeMacroSegmentHotkey");
|
||||
}
|
||||
|
||||
obs_data_array_t *stopHotkeyArrray = obs_hotkey_save(stopHotkey);
|
||||
|
||||
obs_data_set_array(obj, "stopHotkey", stopHotkeyArrray);
|
||||
obs_data_array_release(stopHotkeyArrray);
|
||||
|
||||
obs_data_array_t *toggleHotkeyArrray = obs_hotkey_save(toggleHotkey);
|
||||
obs_data_set_array(obj, "toggleHotkey", toggleHotkeyArrray);
|
||||
obs_data_array_release(toggleHotkeyArrray);
|
||||
|
||||
obs_data_array_t *removeSegmentArrray =
|
||||
obs_hotkey_save(removeMacroSegment);
|
||||
obs_data_set_array(obj, "removeMacroSegmentHotkey",
|
||||
removeSegmentArrray);
|
||||
obs_data_array_release(removeSegmentArrray);
|
||||
void loadHotkey(obs_data_t *obj, obs_hotkey_id id, const char *name)
|
||||
{
|
||||
obs_data_array_t *a = obs_data_get_array(obj, name);
|
||||
obs_hotkey_load(id, a);
|
||||
obs_data_array_release(a);
|
||||
}
|
||||
|
||||
void SwitcherData::loadHotkeys(obs_data_t *obj)
|
||||
|
|
@ -96,24 +129,10 @@ void SwitcherData::loadHotkeys(obs_data_t *obj)
|
|||
if (!hotkeysRegistered) {
|
||||
registerHotkeys();
|
||||
}
|
||||
|
||||
obs_data_array_t *startHotkeyArrray =
|
||||
obs_data_get_array(obj, "startHotkey");
|
||||
obs_hotkey_load(startHotkey, startHotkeyArrray);
|
||||
obs_data_array_release(startHotkeyArrray);
|
||||
|
||||
obs_data_array_t *stopHotkeyArrray =
|
||||
obs_data_get_array(obj, "stopHotkey");
|
||||
obs_hotkey_load(stopHotkey, stopHotkeyArrray);
|
||||
obs_data_array_release(stopHotkeyArrray);
|
||||
|
||||
obs_data_array_t *toggleHotkeyArrray =
|
||||
obs_data_get_array(obj, "toggleHotkey");
|
||||
obs_hotkey_load(toggleHotkey, toggleHotkeyArrray);
|
||||
obs_data_array_release(toggleHotkeyArrray);
|
||||
|
||||
obs_data_array_t *removeSegmentArrray =
|
||||
obs_data_get_array(obj, "removeMacroSegmentHotkey");
|
||||
obs_hotkey_load(removeMacroSegment, removeSegmentArrray);
|
||||
obs_data_array_release(removeSegmentArrray);
|
||||
loadHotkey(obj, startHotkey, "startHotkey");
|
||||
loadHotkey(obj, stopHotkey, "stopHotkey");
|
||||
loadHotkey(obj, toggleHotkey, "toggleHotkey");
|
||||
loadHotkey(obj, upMacroSegment, "upMacroSegmentHotkey");
|
||||
loadHotkey(obj, downMacroSegment, "downMacroSegmentHotkey");
|
||||
loadHotkey(obj, removeMacroSegment, "removeMacroSegmentHotkey");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ void AdvSceneSwitcher::RemoveMacroAction(int idx)
|
|||
SetActionData(*macro);
|
||||
}
|
||||
MacroActionSelectionChanged(-1);
|
||||
lastInteracted = MacroSection::ACTIONS;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_actionRemove_clicked()
|
||||
|
|
@ -323,6 +324,7 @@ void AdvSceneSwitcher::MacroActionSelectionChanged(int idx)
|
|||
currentActionIdx = -1;
|
||||
} else {
|
||||
currentActionIdx = idx;
|
||||
lastInteracted = MacroSection::ACTIONS;
|
||||
}
|
||||
currentConditionIdx = -1;
|
||||
HighlightControls();
|
||||
|
|
|
|||
|
|
@ -361,6 +361,7 @@ void AdvSceneSwitcher::RemoveMacroCondition(int idx)
|
|||
SetConditionData(*macro);
|
||||
}
|
||||
MacroConditionSelectionChanged(-1);
|
||||
lastInteracted = MacroSection::CONDITIONS;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_conditionRemove_clicked()
|
||||
|
|
@ -474,6 +475,7 @@ void AdvSceneSwitcher::MacroConditionSelectionChanged(int idx)
|
|||
currentConditionIdx = -1;
|
||||
} else {
|
||||
currentConditionIdx = idx;
|
||||
lastInteracted = MacroSection::CONDITIONS;
|
||||
}
|
||||
currentActionIdx = -1;
|
||||
HighlightControls();
|
||||
|
|
|
|||
|
|
@ -601,10 +601,127 @@ void AdvSceneSwitcher::MinimizeConditions()
|
|||
ui->macroSplitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
bool AdvSceneSwitcher::MacroTabIsInFocus()
|
||||
{
|
||||
return isActiveWindow() && isAncestorOf(focusWidget()) &&
|
||||
(ui->tabWidget->currentWidget()->objectName() == "macroTab");
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::UpMacroSegementHotkey()
|
||||
{
|
||||
if (!MacroTabIsInFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto macro = getSelectedMacro();
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
size_t actionSize = macro->Actions().size();
|
||||
size_t conditionSize = macro->Conditions().size();
|
||||
|
||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(0);
|
||||
} else {
|
||||
MacroConditionSelectionChanged(0);
|
||||
}
|
||||
} else {
|
||||
if (actionSize == 0) {
|
||||
MacroConditionSelectionChanged(0);
|
||||
} else {
|
||||
MacroActionSelectionChanged(0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentActionIdx > 0) {
|
||||
MacroActionSelectionChanged(currentActionIdx - 1);
|
||||
return;
|
||||
}
|
||||
if (currentConditionIdx > 0) {
|
||||
MacroConditionSelectionChanged(currentConditionIdx - 1);
|
||||
return;
|
||||
}
|
||||
if (currentActionIdx == 0) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(actionSize - 1);
|
||||
} else {
|
||||
MacroConditionSelectionChanged(conditionSize - 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (currentConditionIdx == 0) {
|
||||
if (actionSize == 0) {
|
||||
MacroConditionSelectionChanged(conditionSize - 1);
|
||||
} else {
|
||||
MacroActionSelectionChanged(actionSize - 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::DownMacroSegementHotkey()
|
||||
{
|
||||
if (!MacroTabIsInFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto macro = getSelectedMacro();
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
size_t actionSize = macro->Actions().size();
|
||||
size_t conditionSize = macro->Conditions().size();
|
||||
|
||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(0);
|
||||
} else {
|
||||
MacroConditionSelectionChanged(0);
|
||||
}
|
||||
} else {
|
||||
if (actionSize == 0) {
|
||||
MacroConditionSelectionChanged(0);
|
||||
} else {
|
||||
MacroActionSelectionChanged(0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentActionIdx < actionSize - 1) {
|
||||
MacroActionSelectionChanged(currentActionIdx + 1);
|
||||
return;
|
||||
}
|
||||
if (currentConditionIdx < conditionSize - 1) {
|
||||
MacroConditionSelectionChanged(currentConditionIdx + 1);
|
||||
return;
|
||||
}
|
||||
if (currentActionIdx == actionSize - 1) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(0);
|
||||
} else {
|
||||
MacroConditionSelectionChanged(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (currentConditionIdx == conditionSize - 1) {
|
||||
if (actionSize == 0) {
|
||||
MacroConditionSelectionChanged(0);
|
||||
} else {
|
||||
MacroActionSelectionChanged(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::DeleteMacroSegementHotkey()
|
||||
{
|
||||
if (!isActiveWindow() || !isAncestorOf(focusWidget()) ||
|
||||
!(ui->tabWidget->currentWidget()->objectName() == "macroTab")) {
|
||||
if (!MacroTabIsInFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user