From f0bb941c47419fc75d608187e8b7f73de291497c Mon Sep 17 00:00:00 2001 From: Palakis Date: Wed, 19 Apr 2017 14:36:53 +0200 Subject: [PATCH] New request type : TransitionToProgram --- Utils.cpp | 5 ++++- WSRequestHandler.cpp | 7 +++++++ WSRequestHandler.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Utils.cpp b/Utils.cpp index 6294d2ce..75993608 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -20,6 +20,7 @@ with this program. If not, see #include #include #include +#include #include "obs-websocket.h" Q_DECLARE_METATYPE(OBSScene); @@ -336,12 +337,14 @@ void Utils::TransitionToProgram() // WARNING : if the layout created in OBS' CreateProgramOptions() changes // then this won't work as expected + QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window(); + // The program options widget is the second item in the left-to-right layout QWidget* programOptions = GetPreviewLayout()->itemAt(1)->widget(); // The "Transition" button lies in the mainButtonLayout // which is the first itemin the program options' layout - QLayout* mainButtonLayout = programOptions->layout()->itemAt(0)->layout(); + QLayout* mainButtonLayout = programOptions->layout()->itemAt(1)->layout(); QWidget* transitionBtnWidget = mainButtonLayout->itemAt(0)->widget(); // Try to cast that widget into a button diff --git a/WSRequestHandler.cpp b/WSRequestHandler.cpp index 994ab318..c12ec262 100644 --- a/WSRequestHandler.cpp +++ b/WSRequestHandler.cpp @@ -73,6 +73,7 @@ WSRequestHandler::WSRequestHandler(QWebSocket *client) : messageMap["GetStudioModeStatus"] = WSRequestHandler::HandleGetStudioModeStatus; messageMap["SetPreviewScene"] = WSRequestHandler::HandleSetPreviewScene; + messageMap["TransitionToProgram"] = WSRequestHandler::HandleTransitionToProgram; messageMap["EnableStudioMode"] = WSRequestHandler::HandleEnableStudioMode; messageMap["DisableStudioMode"] = WSRequestHandler::HandleDisableStudioMode; messageMap["ToggleStudioMode"] = WSRequestHandler::HandleToggleStudioMode; @@ -783,6 +784,12 @@ void WSRequestHandler::HandleSetPreviewScene(WSRequestHandler *owner) owner->SendOKResponse(); } +void WSRequestHandler::HandleTransitionToProgram(WSRequestHandler *owner) +{ + Utils::TransitionToProgram(); + owner->SendOKResponse(); +} + void WSRequestHandler::HandleEnableStudioMode(WSRequestHandler *owner) { Utils::EnablePreviewMode(); diff --git a/WSRequestHandler.h b/WSRequestHandler.h index 6b595266..f54f43cd 100644 --- a/WSRequestHandler.h +++ b/WSRequestHandler.h @@ -90,6 +90,7 @@ class WSRequestHandler : public QObject static void HandleGetStudioModeStatus(WSRequestHandler *owner); static void HandleSetPreviewScene(WSRequestHandler *owner); + static void HandleTransitionToProgram(WSRequestHandler *owner); static void HandleEnableStudioMode(WSRequestHandler *owner); static void HandleDisableStudioMode(WSRequestHandler *owner); static void HandleToggleStudioMode(WSRequestHandler *owner);