mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-22 02:12:40 +01:00
Abstract platform icons into utils
This commit is contained in:
parent
19680098bf
commit
a054d60f66
@ -51,11 +51,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_SOURCE_D
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
config-dialog.cpp
|
||||
config-utils.cpp
|
||||
output-dialog.cpp
|
||||
multistream.cpp
|
||||
file-updater.c
|
||||
resources.qrc
|
||||
config-dialog.hpp
|
||||
config-utils.hpp
|
||||
output-dialog.hpp
|
||||
multistream.hpp
|
||||
file-updater.h)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <sstream>
|
||||
#include <util/platform.h>
|
||||
#include "output-dialog.hpp"
|
||||
#include "config-utils.hpp"
|
||||
|
||||
template<typename T> std::string to_string_with_precision(const T a_value, const int n = 6)
|
||||
{
|
||||
@ -41,30 +42,6 @@ template<typename T> std::string to_string_with_precision(const T a_value, const
|
||||
void RemoveWidget(QWidget *widget);
|
||||
void RemoveLayoutItem(QLayoutItem *item);
|
||||
|
||||
// Platform icons deciphered from endpoints
|
||||
QIcon OBSBasicSettings::getPlatformFromEndpoint(QString endpoint)
|
||||
{
|
||||
|
||||
if (endpoint.contains(QString::fromUtf8(".contribute.live-video.net")) ||
|
||||
endpoint.contains(QString::fromUtf8(".twitch.tv"))) { // 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 platformIconKick;
|
||||
} 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"))) { // trovo
|
||||
return platformIconTrovo;
|
||||
} else if (endpoint.contains(QString::fromUtf8(".facebook.com"))) { // facebook
|
||||
return platformIconFacebook;
|
||||
} else { // unknown
|
||||
return platformIconUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
|
||||
{
|
||||
setMinimumWidth(983);
|
||||
@ -438,7 +415,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
auto server_title_layout = new QHBoxLayout;
|
||||
|
||||
auto platformIconLabel = new QLabel;
|
||||
auto platformIcon = getPlatformFromEndpoint(QString::fromUtf8(obs_data_get_string(settings, "stream_server")));
|
||||
auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(QString::fromUtf8(obs_data_get_string(settings, "stream_server")));
|
||||
platformIconLabel->setPixmap(platformIcon.pixmap(30, 30));
|
||||
server_title_layout->addWidget(platformIconLabel, 0);
|
||||
|
||||
|
@ -55,17 +55,6 @@ private:
|
||||
|
||||
QPushButton *verticalAddButton;
|
||||
|
||||
// Platform icons
|
||||
QIcon platformIconTwitch = QIcon(":/aitum/media/twitch.png");
|
||||
QIcon platformIconYouTube = QIcon(":/aitum/media/youtube.png");
|
||||
QIcon platformIconKick = QIcon(":/aitum/media/kick.png");
|
||||
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");
|
||||
QIcon getPlatformFromEndpoint(QString endpoint);
|
||||
|
||||
private slots:
|
||||
void SetGeneralIcon(const QIcon &icon);
|
||||
void SetStreamIcon(const QIcon &icon);
|
||||
|
57
config-utils.cpp
Normal file
57
config-utils.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "config-utils.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QComboBox>
|
||||
#include <QAbstractButton>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
#include "obs.h"
|
||||
#include "obs-module.h"
|
||||
#include "obs-frontend-api.h"
|
||||
#include <util/dstr.h>
|
||||
|
||||
|
||||
// Generate buttons for default/custom stuff
|
||||
QPushButton *ConfigUtils::generateButton(QString buttonText) {
|
||||
auto styles = QString::fromUtf8("QPushButton[unselected=\"true\"] { background: pink; }");
|
||||
|
||||
auto button = new QPushButton(buttonText);
|
||||
button->setStyleSheet(styles);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
// For setting the active property stuff on buttons
|
||||
void ConfigUtils::updateButtonStyles(QPushButton *defaultButton, QPushButton *customButton, int activeIndex) {
|
||||
defaultButton->setProperty("unselected", activeIndex != 0 ? true : false);
|
||||
customButton->setProperty("unselected", activeIndex != 1 ? true : false);
|
||||
}
|
||||
|
||||
|
||||
// Platform icons deciphered from endpoints
|
||||
QIcon ConfigUtils::getPlatformIconFromEndpoint(QString endpoint)
|
||||
{
|
||||
|
||||
if (endpoint.contains(QString::fromUtf8(".contribute.live-video.net")) ||
|
||||
endpoint.contains(QString::fromUtf8(".twitch.tv"))) { // twitch
|
||||
return QIcon(":/aitum/media/twitch.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8(".youtube.com"))) { // youtube
|
||||
return QIcon(":/aitum/media/youtube.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8("fa723fc1b171.global-contribute.live-video.net"))) { // kick
|
||||
return QIcon(":/aitum/media/kick.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8(".tiktokcdn-"))) { // tiktok
|
||||
return QIcon(":/aitum/media/tiktok.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8(".pscp.tv"))) { // twitter
|
||||
return QIcon(":/aitum/media/twitter.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8("livepush.trovo.live"))) { // trovo
|
||||
return QIcon(":/aitum/media/trovo.png");
|
||||
} else if (endpoint.contains(QString::fromUtf8(".facebook.com"))) { // facebook
|
||||
return QIcon(":/aitum/media/facebook.png");
|
||||
} else { // unknown
|
||||
return QIcon(":/aitum/media/unknown.png");
|
||||
}
|
||||
}
|
20
config-utils.hpp
Normal file
20
config-utils.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
#include "obs.h"
|
||||
|
||||
class ConfigUtils {
|
||||
public:
|
||||
static QPushButton *generateButton(QString buttonText);
|
||||
static void updateButtonStyles(QPushButton *defaultButton, QPushButton *customButton, int activeIndex);
|
||||
|
||||
|
||||
static QIcon getPlatformIconFromEndpoint(QString endpoint);
|
||||
};
|
@ -24,7 +24,7 @@ Server="Server"
|
||||
Key="Key"
|
||||
Stream="Stream"
|
||||
EditServerSettings="Output Settings"
|
||||
EditEncoderSettings="Encoder Settings"
|
||||
EditEncoderSettings="Advanced Settings"
|
||||
BackButton="< Back"
|
||||
SaveOutput="Save Output"
|
||||
CreateOutput="Create Output"
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <util/config-file.h>
|
||||
#include <util/platform.h>
|
||||
#include "config-utils.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "file-updater.h"
|
||||
}
|
||||
@ -106,30 +108,6 @@ 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")) ||
|
||||
endpoint.contains(QString::fromUtf8(".twitch.tv"))) { // 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 platformIconKick;
|
||||
} 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"))) { // 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)
|
||||
{
|
||||
@ -217,7 +195,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
||||
|
||||
// blank because we're not pulling settings through from bis, fix this
|
||||
mainPlatformIconLabel = new QLabel;
|
||||
auto platformIcon = getPlatformFromEndpoint(QString::fromUtf8(""));
|
||||
auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(QString::fromUtf8(""));
|
||||
|
||||
mainPlatformIconLabel->setPixmap(platformIcon.pixmap(30, 30));
|
||||
|
||||
@ -362,7 +340,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
||||
auto url = QString::fromUtf8(obs_service_get_connect_info(service, OBS_SERVICE_CONNECT_INFO_SERVER_URL));
|
||||
if (url != mainPlatformUrl) {
|
||||
mainPlatformUrl = url;
|
||||
auto platformIcon = getPlatformFromEndpoint(url);
|
||||
auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(url);
|
||||
mainPlatformIconLabel->setPixmap(platformIcon.pixmap(30, 30));
|
||||
}
|
||||
|
||||
@ -572,7 +550,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical)
|
||||
auto l2 = new QHBoxLayout;
|
||||
|
||||
auto platformIconLabel = new QLabel;
|
||||
auto platformIcon = getPlatformFromEndpoint(endpoint);
|
||||
auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(endpoint);
|
||||
|
||||
platformIconLabel->setPixmap(platformIcon.pixmap(30, 30));
|
||||
|
||||
|
@ -48,20 +48,9 @@ private:
|
||||
void storeMainStreamEncoders();
|
||||
QStringList mainEncoderDescriptions = QStringList(MAX_OUTPUT_VIDEO_ENCODERS);
|
||||
|
||||
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/kick.png");
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user