Add in platform icons, fix vertical warning bug, WIP new output dialog

This commit is contained in:
David Marsh 2024-07-16 14:16:40 +01:00
parent 3a52231f3c
commit 4b4703f37b
15 changed files with 174 additions and 8 deletions

View File

@ -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)

View File

@ -26,6 +26,7 @@
#include <sstream>
#include <util/platform.h>
#include "output-dialog.hpp"
template<typename T> 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);

View File

@ -26,3 +26,5 @@ Stream="Stream"
MainOutputNotActive="Main output not active!"
NewVersion="New version (%1) available <a href='https://aitum.tv/download/multi/'>here</a>"
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."

BIN
media/facebook.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
media/tiktok.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
media/trovo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
media/twitch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
media/twitter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
media/unknown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
media/youtube.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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;
}

View File

@ -7,6 +7,7 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QTimer>
#include <QString>
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);
};

41
output-dialog.cpp Normal file
View File

@ -0,0 +1,41 @@
#include "output-dialog.hpp"
#include <QDialog>
#include <QWizard>
#include <QWizardPage>
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;
}

16
output-dialog.hpp Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <QWizard>
#include <QWizardPage>
#include <QDialog>
class OutputDialog : public QWizard {
Q_OBJECT
private:
QWizardPage *WizardPage1();
QWizardPage *WizardPage2();
QWizardPage *WizardPage3();
public:
OutputDialog(QDialog *parent);
};

View File

@ -3,5 +3,12 @@
<file>media/aitum.png</file>
<file>media/stream.svg</file>
<file>media/streaming.svg</file>
<file>media/facebook.png</file>
<file>media/tiktok.png</file>
<file>media/trovo.png</file>
<file>media/twitch.png</file>
<file>media/twitter.png</file>
<file>media/unknown.png</file>
<file>media/youtube.png</file>
</qresource>
</RCC>