diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 6a4ac3a07..46cce0b84 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -342,6 +342,9 @@ Basic.DisplayCapture="Display Capture" # display context menu Basic.Main.PreviewConextMenu.Enable="Enable Preview" +# disable preview +Basic.Main.Preview.Disable="Disable Preview" + # scale filtering ScaleFiltering="Scale Filtering" ScaleFiltering.Point="Point" diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 0ac126cbf..8909133ab 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -2182,6 +2182,19 @@ void OBSBasic::CreateHotkeys() this, this); LoadHotkeyPair(replayBufHotkeys, "OBSBasic.StartReplayBuffer", "OBSBasic.StopReplayBuffer"); + + togglePreviewHotkeys = obs_hotkey_pair_register_frontend( + "OBSBasic.EnablePreview", + Str("Basic.Main.PreviewConextMenu.Enable"), + "OBSBasic.DisablePreview", + Str("Basic.Main.Preview.Disable"), + MAKE_CALLBACK(!basic.previewEnabled, + basic.EnablePreview, "Enabling preview"), + MAKE_CALLBACK(basic.previewEnabled, + basic.DisablePreview, "Disabling preview"), + this, this); + LoadHotkeyPair(togglePreviewHotkeys, + "OBSBasic.EnablePreview", "OBSBasic.DisablePreview"); #undef MAKE_CALLBACK auto togglePreviewProgram = [] (void *data, obs_hotkey_id, @@ -6192,6 +6205,24 @@ void OBSBasic::TogglePreview() EnablePreviewDisplay(previewEnabled); } +void OBSBasic::EnablePreview() +{ + if (previewProgramMode) + return; + + previewEnabled = true; + EnablePreviewDisplay(true); +} + +void OBSBasic::DisablePreview() +{ + if (previewProgramMode) + return; + + previewEnabled = false; + EnablePreviewDisplay(false); +} + static bool nudge_callback(obs_scene_t*, obs_sceneitem_t *item, void *param) { if (obs_sceneitem_locked(item)) diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index c69c8930b..3495dae26 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -324,7 +324,7 @@ private: int GetTopSelectedSourceItem(); obs_hotkey_pair_id streamingHotkeys, recordingHotkeys, - replayBufHotkeys; + replayBufHotkeys, togglePreviewHotkeys; obs_hotkey_id forceStreamingStopHotkey; void InitDefaultTransitions(); @@ -526,6 +526,9 @@ private slots: void AudioMixerCopyFilters(); void AudioMixerPasteFilters(); + void EnablePreview(); + void DisablePreview(); + private: /* OBS Callbacks */ static void SceneReordered(void *data, calldata_t *params);