mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-27 03:36:00 -05:00
Add option to export Websocket, Twitch, HTTP connections
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <help-icon.hpp>
|
||||
#include <layout-helpers.hpp>
|
||||
#include <log-helper.hpp>
|
||||
#include <macro-export-extensions.hpp>
|
||||
#include <obs-module-helper.hpp>
|
||||
#include <plugin-state-helpers.hpp>
|
||||
#include <QDesktopServices>
|
||||
@@ -88,6 +89,49 @@ static bool setupTwitchTokenSupport()
|
||||
AddSaveStep(saveConnections);
|
||||
AddLoadStep(loadConnections);
|
||||
AddPluginCleanupStep([]() { twitchTokens.clear(); });
|
||||
AddMacroExportExtension(
|
||||
{"AdvSceneSwitcher.macroTab.export.twitchConnections",
|
||||
"twitchConnections",
|
||||
[](obs_data_t *data, const QStringList &selectedIds) {
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_array_create();
|
||||
for (const auto &t : twitchTokens) {
|
||||
if (!selectedIds.isEmpty() &&
|
||||
!selectedIds.contains(
|
||||
QString::fromStdString(t->Name())))
|
||||
continue;
|
||||
OBSDataAutoRelease item = obs_data_create();
|
||||
t->Save(item);
|
||||
obs_data_array_push_back(array, item);
|
||||
}
|
||||
obs_data_set_array(data, "twitchConnections", array);
|
||||
},
|
||||
[](obs_data_t *data, const QStringList &) {
|
||||
OBSDataArrayAutoRelease array =
|
||||
obs_data_get_array(data, "twitchConnections");
|
||||
const size_t count = obs_data_array_count(array);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
OBSDataAutoRelease item =
|
||||
obs_data_array_item(array, i);
|
||||
auto token = TwitchToken::Create();
|
||||
token->Load(item);
|
||||
if (!GetWeakTwitchTokenByName(token->Name())
|
||||
.expired())
|
||||
continue;
|
||||
twitchTokens.emplace_back(token);
|
||||
TwitchConnectionSignalManager::Instance()->Add(
|
||||
QString::fromStdString(token->Name()));
|
||||
}
|
||||
},
|
||||
[]() -> QList<QPair<QString, QString>> {
|
||||
QList<QPair<QString, QString>> items;
|
||||
for (const auto &t : twitchTokens) {
|
||||
const QString name =
|
||||
QString::fromStdString(t->Name());
|
||||
items.append({name, name});
|
||||
}
|
||||
return items;
|
||||
}});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user