From e241518f8d510d1bafb17d9afef67a90cf05ec2d Mon Sep 17 00:00:00 2001 From: Palakis Date: Thu, 20 Apr 2017 09:53:31 +0200 Subject: [PATCH] Add StudioModeSwitched event --- PROTOCOL.md | 7 +++++++ Utils.cpp | 1 - WSEvents.cpp | 14 ++++++++++++++ WSEvents.h | 3 ++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index ec5dae51..fa0ded54 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -22,6 +22,7 @@ The protocol in general is based on the OBS Remote protocol created by Bill Hami - ["TransitionListChanged"](#transitionlistchanged) - ["TransitionBegin"](#transitionbegin) - ["PreviewSceneChanged"](#previewscenechanged) + - ["StudioModeSwitched"](#studiomodeswitched) - ["ProfileChanged"](#profilechanged) - ["ProfileListChanged"](#profilelistchanged) - ["StreamStarting"](#streamstarting) @@ -166,6 +167,12 @@ The selected Preview scene changed (only in Studio Mode). --- +#### "StudioModeSwitched" +Studio Mode has been switched on or off. +- **"new-state"** (bool) : new state of Studio Mode: true if enabled, false if disabled. + +--- + #### "ProfileChanged" Triggered when switching to another profile or when renaming the current profile. diff --git a/Utils.cpp b/Utils.cpp index d92a20c5..70d0fafe 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -323,7 +323,6 @@ obs_scene_t* Utils::GetPreviewScene() QListWidget* sceneList = GetSceneListControl(); QList selected = sceneList->selectedItems(); - blog(LOG_INFO, "GetPreviewSceneName: %d selected item(s)", selected.count()); // Qt::UserRole == QtUserRole::OBSRef obs_scene_t* scene = Utils::SceneListItemToScene(selected.first()); diff --git a/WSEvents.cpp b/WSEvents.cpp index 4ae179a1..343e0f02 100644 --- a/WSEvents.cpp +++ b/WSEvents.cpp @@ -19,6 +19,7 @@ with this program. If not, see #include #include +#include #include "Utils.h" #include "WSEvents.h" #include "obs-websocket.h" @@ -71,6 +72,9 @@ WSEvents::WSEvents(WSServer *srv) QListWidget* sceneList = Utils::GetSceneListControl(); connect(sceneList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(SelectedSceneChanged(QListWidgetItem*, QListWidgetItem*))); + QPushButton* modeSwitch = Utils::GetPreviewModeButtonControl(); + connect(modeSwitch, SIGNAL(clicked(bool)), this, SLOT(ModeSwitchClicked(bool))); + transition_handler = nullptr; scene_handler = nullptr; @@ -589,4 +593,14 @@ void WSEvents::SelectedSceneChanged(QListWidgetItem *current, QListWidgetItem *p obs_data_release(data); } +} + +void WSEvents::ModeSwitchClicked(bool checked) +{ + obs_data_t* data = obs_data_create(); + obs_data_set_bool(data, "new-state", checked); + + broadcastUpdate("StudioModeSwitched", data); + + obs_data_release(data); } \ No newline at end of file diff --git a/WSEvents.h b/WSEvents.h index 31c3bf23..5e9d02bf 100644 --- a/WSEvents.h +++ b/WSEvents.h @@ -42,10 +42,11 @@ class WSEvents : public QObject const char* GetRecordingTimecode(); private Q_SLOTS: + void deferredInitOperations(); void StreamStatus(); void TransitionDurationChanged(int ms); void SelectedSceneChanged(QListWidgetItem *current, QListWidgetItem *prev); - void deferredInitOperations(); + void ModeSwitchClicked(bool checked); private: WSServer *_srv;