diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d48fc6..43d0944 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,10 +51,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_SOURCE_D target_sources(${PROJECT_NAME} PRIVATE config-dialog.cpp + output-dialog.cpp multistream.cpp file-updater.c resources.qrc config-dialog.hpp + output-dialog.hpp multistream.hpp file-updater.h) diff --git a/config-dialog.cpp b/config-dialog.cpp index be207e1..a0b270a 100644 --- a/config-dialog.cpp +++ b/config-dialog.cpp @@ -26,6 +26,7 @@ #include #include +#include "output-dialog.hpp" template std::string to_string_with_precision(const T a_value, const int n = 6) { @@ -161,10 +162,45 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) AddServer(mainOutputsLayout, s); obs_data_release(s); }); + + auto addButtonTest = new QPushButton(QIcon(":/res/images/plus.svg"), QString::fromUtf8(obs_module_text("AddOutput")) + " Test"); + addButtonTest->setProperty("themeID", QVariant(QString::fromUtf8("addIconSmall"))); + connect(addButtonTest, &QPushButton::clicked, [this] { + auto outputDialog = new OutputDialog(this); + + if (outputDialog->exec() == QDialog::Accepted) { + // got a result + blog(LOG_WARNING, "[Aitum Multistream] output accepted"); + } else { + blog(LOG_WARNING, "[Aitum Multistream] output rejected"); + } + + delete outputDialog; + + + + + +// if (!settings) +// return; +// auto outputs = obs_data_get_array(settings, "outputs"); +// if (!outputs) { +// outputs = obs_data_array_create(); +// obs_data_set_array(settings, "outputs", outputs); +// } +// auto s = obs_data_create(); +// obs_data_set_string(s, "name", obs_module_text("Unnamed")); +// obs_data_array_push_back(outputs, s); +// obs_data_array_release(outputs); +// AddServer(mainOutputsLayout, s); +// obs_data_release(s); + }); //streaming_title_layout->addWidget(guide_link, 0, Qt::AlignRight); streaming_title_layout->addWidget(addButton, 0, Qt::AlignRight); + streaming_title_layout->addWidget(addButtonTest, 0, Qt::AlignRight); + mainOutputsLayout->addRow(streaming_title_layout); auto serverGroup = new QGroupBox; @@ -177,9 +213,13 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) serverLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); serverLayout->setLabelAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); - auto main_title = new QLabel(QString::fromUtf8(obs_module_text("MainOutput"))); - main_title->setStyleSheet(QString::fromUtf8("font-weight: bold;")); - serverLayout->addRow(main_title); + auto mainTitle = new QLabel(QString::fromUtf8(obs_module_text("SettingsMainCanvasTitle"))); + mainTitle->setStyleSheet(QString::fromUtf8("font-weight: bold;")); + serverLayout->addRow(mainTitle); + + auto mainDescription = new QLabel(QString::fromUtf8(obs_module_text("SettingsMainCanvasDescription"))); +// mainTitle->setStyleSheet(QString::fromUtf8("font-weight: bold;")); + serverLayout->addRow(mainDescription); serverGroup->setLayout(serverLayout); diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 2ba154a..3d721ff 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -26,3 +26,5 @@ Stream="Stream" MainOutputNotActive="Main output not active!" NewVersion="New version (%1) available here" NoVerticalWarning="The Vertical plugin is not installed, or you are using an older version." +SettingsMainCanvasTitle="Main Canvas" +SettingsMainCanvasDescription="You can manage your Main Canvas (the default canvas) settings here. \nPlease note that to change your Built-in Output settings, you need to do this from within the normal OBS settings." diff --git a/media/facebook.png b/media/facebook.png new file mode 100644 index 0000000..b042da5 Binary files /dev/null and b/media/facebook.png differ diff --git a/media/tiktok.png b/media/tiktok.png new file mode 100644 index 0000000..166f8ca Binary files /dev/null and b/media/tiktok.png differ diff --git a/media/trovo.png b/media/trovo.png new file mode 100644 index 0000000..127696a Binary files /dev/null and b/media/trovo.png differ diff --git a/media/twitch.png b/media/twitch.png new file mode 100644 index 0000000..0671138 Binary files /dev/null and b/media/twitch.png differ diff --git a/media/twitter.png b/media/twitter.png new file mode 100644 index 0000000..c5a12cc Binary files /dev/null and b/media/twitter.png differ diff --git a/media/unknown.png b/media/unknown.png new file mode 100644 index 0000000..e584466 Binary files /dev/null and b/media/unknown.png differ diff --git a/media/youtube.png b/media/youtube.png new file mode 100644 index 0000000..135634a Binary files /dev/null and b/media/youtube.png differ diff --git a/multistream.cpp b/multistream.cpp index ff499cc..d73c5f2 100644 --- a/multistream.cpp +++ b/multistream.cpp @@ -67,7 +67,7 @@ bool obs_module_load(void) void obs_module_post_load() { - multistream_dock->LoadVerticalOutputs(); + multistream_dock->LoadVerticalOutputs(true); } void obs_module_unload() @@ -105,6 +105,29 @@ void RemoveWidget(QWidget *widget) delete widget; } +// Platform icons deciphered from endpoints +QIcon MultistreamDock::getPlatformFromEndpoint(QString endpoint) { + + if (endpoint.contains(QString::fromUtf8(".contribute.live-video.net"))) { // twitch + return platformIconTwitch; + } else if (endpoint.contains(QString::fromUtf8(".youtube.com"))) { // youtube + return platformIconYouTube; + } else if (endpoint.contains(QString::fromUtf8("fa723fc1b171.global-contribute.live-video.net"))) { // kick + return platformIconUnknown; + } else if (endpoint.contains(QString::fromUtf8(".tiktokcdn-"))) { // tiktok + return platformIconTikTok; + } else if (endpoint.contains(QString::fromUtf8(".pscp.tv"))) { // twitter + return platformIconTwitter; + } else if (endpoint.contains(QString::fromUtf8("livepush.trovo.live/live"))) { // trovo + return platformIconTrovo; + } else if (endpoint.contains(QString::fromUtf8(".facebook.com"))) { // facebook + return platformIconFacebook; + } else { // unknown + return platformIconUnknown; + } + +} + // Output button styling void MultistreamDock::outputButtonStyle(QPushButton *button) { @@ -123,6 +146,7 @@ auto outputTitleStyle = QString("QLabel{}"); // "Built -in str auto outputGroupStyle = QString("background-color: %1; padding: 0px;") .arg(QPalette().color(QPalette::ColorRole::Mid).name(QColor::HexRgb)); // wrapper around above + // For showing warning for no vertical integration void showVerticalWarning(QVBoxLayout *verticalLayout) { @@ -174,6 +198,15 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent) auto bisHeaderLabel = new QLabel(QString::fromUtf8(obs_module_text("BuiltinStream"))); bisHeaderLabel->setStyleSheet(outputTitleStyle); + // blank because we're not pulling settings through from bis, fix this + auto platformIconLabel = new QLabel; + auto platformIcon = getPlatformFromEndpoint(QString::fromUtf8("")); +// platformIcon. + + platformIconLabel->setPixmap(platformIcon.pixmap(30, 30)); + + l2->addWidget(platformIconLabel); + l2->addWidget(bisHeaderLabel, 1); mainStreamButton = new QPushButton; @@ -258,7 +291,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent) SaveSettings(); LoadSettings(); configDialog->SaveVerticalSettings(); - LoadVerticalOutputs(); + LoadVerticalOutputs(false); } else { current_config = settings; } @@ -459,6 +492,7 @@ void MultistreamDock::LoadSettings() void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) { auto name = QString::fromUtf8(obs_data_get_string(data, "name")); + auto endpoint = QString::fromUtf8(obs_data_get_string(data, "stream_server")); if (vertical) { for (int i = 1; i < verticalCanvasLayout->count(); i++) { auto item = verticalCanvasLayout->itemAt(i); @@ -482,6 +516,15 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) auto streamLayout = new QVBoxLayout; auto l2 = new QHBoxLayout; + + + auto platformIconLabel = new QLabel; + auto platformIcon = getPlatformFromEndpoint(endpoint); + + platformIconLabel->setPixmap(platformIcon.pixmap(30, 30)); + + l2->addWidget(platformIconLabel); + l2->addWidget(new QLabel(name), 1); auto streamButton = new QPushButton; streamButton->setMinimumHeight(30); @@ -807,13 +850,15 @@ void MultistreamDock::NewerVersionAvailable(QString version) configButton->setStyleSheet(QString::fromUtf8("background: rgb(192,128,0);")); } -void MultistreamDock::LoadVerticalOutputs() +void MultistreamDock::LoadVerticalOutputs(bool firstLoad) { auto ph = obs_get_proc_handler(); struct calldata cd; calldata_init(&cd); if (!proc_handler_call(ph, "aitum_vertical_get_stream_settings", &cd)) { - showVerticalWarning(verticalCanvasLayout); // show warning + if (firstLoad) { // only display warning on first load + showVerticalWarning(verticalCanvasLayout); // show warning + } calldata_free(&cd); return; } diff --git a/multistream.hpp b/multistream.hpp index a20da7e..8d42702 100644 --- a/multistream.hpp +++ b/multistream.hpp @@ -7,6 +7,7 @@ #include #include #include +#include class OBSBasicSettings; @@ -40,8 +41,20 @@ private: void outputButtonStyle(QPushButton *button); + QIcon getPlatformFromEndpoint(QString endpoint); + QIcon streamActiveIcon = QIcon(":/aitum/media/streaming.svg"); QIcon streamInactiveIcon = QIcon(":/aitum/media/stream.svg"); + + // Platform icons + QIcon platformIconTwitch = QIcon(":/aitum/media/twitch.png"); + QIcon platformIconYouTube = QIcon(":/aitum/media/youtube.png"); +// QIcon platformIconKick = QIcon(":/aitum/media/stream.svg"); + QIcon platformIconTikTok = QIcon(":/aitum/media/tiktok.png"); + QIcon platformIconTwitter = QIcon(":/aitum/media/twitter.png"); + QIcon platformIconTrovo = QIcon(":/aitum/media/trovo.png"); + QIcon platformIconFacebook = QIcon(":/aitum/media/facebook.png"); + QIcon platformIconUnknown = QIcon(":/aitum/media/unknown.png"); static void frontend_event(enum obs_frontend_event event, void *private_data); @@ -54,5 +67,5 @@ private slots: public: MultistreamDock(QWidget *parent = nullptr); ~MultistreamDock(); - void LoadVerticalOutputs(); + void LoadVerticalOutputs(bool firstLoad = true); }; diff --git a/output-dialog.cpp b/output-dialog.cpp new file mode 100644 index 0000000..c5ec4f1 --- /dev/null +++ b/output-dialog.cpp @@ -0,0 +1,41 @@ +#include "output-dialog.hpp" + +#include +#include +#include + +OutputDialog::OutputDialog(QDialog *parent) : QWizard(parent) { + setWindowTitle("this is my wizard title!!"); + + addPage(WizardPage1()); + addPage(WizardPage2()); + addPage(WizardPage3()); + + show(); +} + +QWizardPage *OutputDialog::WizardPage1() { + auto page = new QWizardPage(this); + + page->setTitle(QString("page 1")); + + return page; +} + +QWizardPage *OutputDialog::WizardPage2() { + auto page = new QWizardPage(this); + + page->setTitle(QString("page 2")); + + return page; +} + +QWizardPage *OutputDialog::WizardPage3() { + auto page = new QWizardPage(this); + + page->setTitle(QString("page 3")); + page->setFinalPage(true); + + return page; +} + diff --git a/output-dialog.hpp b/output-dialog.hpp new file mode 100644 index 0000000..4470655 --- /dev/null +++ b/output-dialog.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include +#include +#include + +class OutputDialog : public QWizard { + Q_OBJECT +private: + QWizardPage *WizardPage1(); + QWizardPage *WizardPage2(); + QWizardPage *WizardPage3(); + +public: + OutputDialog(QDialog *parent); +}; diff --git a/resources.qrc b/resources.qrc index 00b29c5..7c8d372 100644 --- a/resources.qrc +++ b/resources.qrc @@ -3,5 +3,12 @@ media/aitum.png media/stream.svg media/streaming.svg + media/facebook.png + media/tiktok.png + media/trovo.png + media/twitch.png + media/twitter.png + media/unknown.png + media/youtube.png