mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Add hotkey to delete macro segments
This commit is contained in:
parent
89efb6d1c8
commit
eeedf11c6a
|
|
@ -676,6 +676,7 @@ 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.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?"
|
||||
AdvSceneSwitcher.askForMacro="Select macro {{macroSelection}}"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ SwitcherData *GetSwitcher()
|
|||
return switcher;
|
||||
}
|
||||
|
||||
AdvSceneSwitcher *AdvSceneSwitcher::window = nullptr;
|
||||
|
||||
/******************************************************************************
|
||||
* Create the Advanced Scene Switcher settings window
|
||||
******************************************************************************/
|
||||
|
|
@ -667,8 +669,6 @@ void LoadPlugins()
|
|||
}
|
||||
}
|
||||
|
||||
AdvSceneSwitcher *ssWindow;
|
||||
|
||||
extern "C" void InitSceneSwitcher()
|
||||
{
|
||||
blog(LOG_INFO, "version: %s", g_GIT_TAG);
|
||||
|
|
@ -686,15 +686,16 @@ extern "C" void InitSceneSwitcher()
|
|||
|
||||
auto cb = []() {
|
||||
if (switcher->settingsWindowOpened) {
|
||||
ssWindow->show();
|
||||
ssWindow->raise();
|
||||
ssWindow->activateWindow();
|
||||
AdvSceneSwitcher::window->show();
|
||||
AdvSceneSwitcher::window->raise();
|
||||
AdvSceneSwitcher::window->activateWindow();
|
||||
} else {
|
||||
ssWindow =
|
||||
AdvSceneSwitcher::window =
|
||||
new AdvSceneSwitcher(static_cast<QMainWindow *>(
|
||||
obs_frontend_get_main_window()));
|
||||
ssWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ssWindow->show();
|
||||
AdvSceneSwitcher::window->setAttribute(
|
||||
Qt::WA_DeleteOnClose);
|
||||
AdvSceneSwitcher::window->show();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public:
|
|||
AdvSceneSwitcher(QWidget *parent);
|
||||
~AdvSceneSwitcher();
|
||||
|
||||
static AdvSceneSwitcher *window;
|
||||
|
||||
void reject() override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
|
|
@ -130,6 +132,7 @@ public slots:
|
|||
void on_actionRemove_clicked();
|
||||
void on_actionUp_clicked();
|
||||
void on_actionDown_clicked();
|
||||
void DeleteMacroSegementHotkey();
|
||||
void ShowMacroContextMenu(const QPoint &);
|
||||
void ShowMacroActionsContextMenu(const QPoint &);
|
||||
void ShowMacroConditionsContextMenu(const QPoint &);
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ 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 removeMacroSegment = OBS_INVALID_HOTKEY_ID;
|
||||
|
||||
bool saveWindowGeo = false;
|
||||
QPoint windowPos = {};
|
||||
|
|
|
|||
|
|
@ -34,6 +34,17 @@ void startStopToggleHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
|||
}
|
||||
}
|
||||
|
||||
void removeMacroSegmentHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
|
||||
bool pressed)
|
||||
{
|
||||
if (pressed && switcher->settingsWindowOpened &&
|
||||
AdvSceneSwitcher::window) {
|
||||
QMetaObject::invokeMethod(AdvSceneSwitcher::window,
|
||||
"DeleteMacroSegementHotkey",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void registerHotkeys()
|
||||
{
|
||||
switcher->startHotkey = obs_hotkey_register_frontend(
|
||||
|
|
@ -49,6 +60,11 @@ void registerHotkeys()
|
|||
obs_module_text(
|
||||
"AdvSceneSwitcher.hotkey.startStopToggleSwitcherHotkey"),
|
||||
startStopToggleHotkeyFunc, NULL);
|
||||
switcher->removeMacroSegment = obs_hotkey_register_frontend(
|
||||
"removeMacroSegmentSwitcherHotkey",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.hotkey.removeMacroSegmentHotkey"),
|
||||
removeMacroSegmentHotkeyFunc, NULL);
|
||||
|
||||
switcher->hotkeysRegistered = true;
|
||||
}
|
||||
|
|
@ -67,6 +83,12 @@ void SwitcherData::saveHotkeys(obs_data_t *obj)
|
|||
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 SwitcherData::loadHotkeys(obs_data_t *obj)
|
||||
|
|
@ -89,4 +111,9 @@ void SwitcherData::loadHotkeys(obs_data_t *obj)
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -592,3 +592,12 @@ void AdvSceneSwitcher::SetSelection(MacroSegmentList *list, int idx)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::DeleteMacroSegementHotkey()
|
||||
{
|
||||
if (currentActionIdx != -1) {
|
||||
RemoveMacroAction(currentActionIdx);
|
||||
} else if (currentConditionIdx != -1) {
|
||||
RemoveMacroCondition(currentConditionIdx);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user