From f3996855c36dbcaee8566c83a6c02f829f161238 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Tue, 19 Mar 2024 19:29:25 +0100 Subject: [PATCH] Add example OBS websocket message --- plugins/base/macro-action-websocket.cpp | 27 +++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/base/macro-action-websocket.cpp b/plugins/base/macro-action-websocket.cpp index 3f35691e..994a21dc 100644 --- a/plugins/base/macro-action-websocket.cpp +++ b/plugins/base/macro-action-websocket.cpp @@ -307,9 +307,32 @@ void MacroActionWebsocketEdit::APITypeChanged(int index) return; } - auto lock = LockContext(); - _entryData->_api = static_cast(index); + { + auto lock = LockContext(); + _entryData->_api = + static_cast(index); + } SetWidgetVisibility(); + + // Set example OBS websocket message if the default message or an empty + // message was entered as neither of those are valid OBS websocket + // messages + if ((std::string(_entryData->_message).empty() || + std::string(_entryData->_message) == + obs_module_text("AdvSceneSwitcher.enterText")) && + _entryData->_api == MacroActionWebsocket::API::OBS_WEBSOCKET) { + static constexpr std::string_view example = + "{\n" + " \"d\": {\n" + " \"requestData\" : {},\n" + " \"requestId\": \"someUniqueIdHere\",\n" + " \"requestType\" : \"StartRecord\"\n" + " },\n" + " \"op\": 6\n" + "}"; + _message->setPlainText(QString(example.data())); + } + emit HeaderInfoChanged( QString::fromStdString(_entryData->GetShortDesc())); }