Skip to content

Commit

Permalink
UI: Upgrade stream key link to button in Wizard
Browse files Browse the repository at this point in the history
Follow up to #2145: #2145
The wizard has a stream link URL as well, adding the button in the
wizard to match. Additionally, fixing a few  errors in the UI layout
and spacing where items were not padded.
  • Loading branch information
JohannMG committed Jan 7, 2020
1 parent eadb96f commit ee2c520
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 78 deletions.
69 changes: 48 additions & 21 deletions UI/forms/AutoConfigStreamPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>335</height>
<width>692</width>
<height>407</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -44,6 +44,9 @@
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
Expand Down Expand Up @@ -73,6 +76,19 @@
<item row="1" column="1">
<widget class="QComboBox" name="service"/>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -279,6 +295,13 @@
</property>
</widget>
</item>
<item>
<widget class="UrlPushButton" name="streamKeyButton">
<property name="text">
<string>Basic.AutoConfig.StreamPage.GetStreamKey</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -321,22 +344,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>87</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="doBandwidthTest">
<property name="text">
Expand All @@ -347,7 +354,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QGroupBox" name="region">
<property name="title">
<string>BandwidthTest.Region</string>
Expand Down Expand Up @@ -384,26 +391,46 @@
</layout>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QPushButton" name="connectAccount2">
<property name="text">
<string>Basic.AutoConfig.StreamPage.ConnectAccount</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QPushButton" name="disconnectAccount">
<property name="text">
<string>Basic.AutoConfig.StreamPage.DisconnectAccount</string>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UrlPushButton</class>
<extends>QPushButton</extends>
<header>url-push-button.hpp</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
Expand Down
79 changes: 31 additions & 48 deletions UI/window-basic-auto-config.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "window-basic-auto-config.hpp"
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "obs-app.hpp"

#include <QMessageBox>
#include <QScreen>

#include <obs.hpp>

#include "window-basic-auto-config.hpp"
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "obs-app.hpp"
#include "url-push-button.hpp"

#include "ui_AutoConfigStartPage.h"
#include "ui_AutoConfigVideoPage.h"
#include "ui_AutoConfigStreamPage.h"
Expand Down Expand Up @@ -289,7 +290,7 @@ int AutoConfigStreamPage::nextId() const
return AutoConfig::TestPage;
}

inline bool AutoConfigStreamPage::IsCustom() const
inline bool AutoConfigStreamPage::IsCustomService() const
{
return ui->service->currentData().toInt() == (int)ListOpt::Custom;
}
Expand All @@ -299,7 +300,7 @@ bool AutoConfigStreamPage::validatePage()
OBSData service_settings = obs_data_create();
obs_data_release(service_settings);

wiz->customServer = IsCustom();
wiz->customServer = IsCustomService();

const char *serverType = wiz->customServer ? "rtmp_custom"
: "rtmp_common";
Expand Down Expand Up @@ -480,7 +481,7 @@ void AutoConfigStreamPage::ServiceChanged()
std::string service = QT_TO_UTF8(ui->service->currentText());
bool regionBased = service == "Twitch" || service == "Smashcast";
bool testBandwidth = ui->doBandwidthTest->isChecked();
bool custom = IsCustom();
bool custom = IsCustomService();

ui->disconnectAccount->setVisible(false);

Expand Down Expand Up @@ -553,51 +554,35 @@ void AutoConfigStreamPage::ServiceChanged()

void AutoConfigStreamPage::UpdateKeyLink()
{
bool custom = IsCustom();
if (IsCustomService()) {
ui->doBandwidthTest->setEnabled(true);
return;
}

QString serviceName = ui->service->currentText();
bool isYoutube = false;
QString streamKeyLink;

if (custom)
serviceName = "";

QString text = QTStr("Basic.AutoConfig.StreamPage.StreamKey");
if (serviceName == "Twitch") {
text += " <a href=\"https://";
text += "www.twitch.tv/broadcast/dashboard/streamkey";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
streamKeyLink = "https://www.twitch.tv/broadcast/dashboard/streamkey";
} else if (serviceName == "YouTube / YouTube Gaming") {
text += " <a href=\"https://";
text += "www.youtube.com/live_dashboard";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";

streamKeyLink = "https://www.youtube.com/live_dashboard";
isYoutube = true;
} else if (serviceName.startsWith("Restream.io")) {
text += " <a href=\"https://";
text += "restream.io/settings/streaming-setup?from=OBS";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
} else if (serviceName == "YouStreamer") {
text += " <a href=\"https://";
text += "app.youstreamer.com/stream";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
streamKeyLink = "https://restream.io/settings/streaming-setup?from=OBS";
} else if (serviceName == "Facebook Live") {
text += " <a href=\"https://";
text += "www.facebook.com/live/create";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
streamKeyLink = "https://www.facebook.com/live/create?ref=OBS";
} else if (serviceName.startsWith("Twitter")) {
streamKeyLink = "https://www.pscp.tv/account/producer";
} else if (serviceName.startsWith("YouStreamer")) {
streamKeyLink = "https://www.app.youstreamer.com/stream/";
}

if (QString(streamKeyLink).isNull()) {
ui->streamKeyButton->hide();
} else {
ui->streamKeyButton->setTargetUrl(QUrl(streamKeyLink));
ui->streamKeyButton->show();
}

if (isYoutube) {
Expand All @@ -606,8 +591,6 @@ void AutoConfigStreamPage::UpdateKeyLink()
} else {
ui->doBandwidthTest->setEnabled(true);
}

ui->streamKeyLabel->setText(text);
}

void AutoConfigStreamPage::LoadServices(bool showAll)
Expand Down Expand Up @@ -704,7 +687,7 @@ void AutoConfigStreamPage::UpdateCompleted()
(ui->key->text().isEmpty() && !auth)) {
ready = false;
} else {
bool custom = IsCustom();
bool custom = IsCustomService();
if (custom) {
ready = !ui->customServer->text().isEmpty();
} else {
Expand Down
2 changes: 1 addition & 1 deletion UI/window-basic-auto-config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AutoConfigStreamPage : public QWizardPage {
bool ready = false;

void LoadServices(bool showAll);
inline bool IsCustom() const;
inline bool IsCustomService() const;

public:
AutoConfigStreamPage(QWidget *parent = nullptr);
Expand Down
15 changes: 7 additions & 8 deletions UI/window-basic-settings-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,17 @@ void OBSBasicSettings::UpdateKeyLink()
QString serviceName = ui->service->currentText();
QString streamKeyLink;
if (serviceName == "Twitch") {
streamKeyLink = QTStr(
"https://www.twitch.tv/broadcast/dashboard/streamkey");
streamKeyLink = "https://www.twitch.tv/broadcast/dashboard/streamkey";
} else if (serviceName == "YouTube / YouTube Gaming") {
streamKeyLink = QTStr("https://www.youtube.com/live_dashboard");
streamKeyLink = "https://www.youtube.com/live_dashboard";
} else if (serviceName.startsWith("Restream.io")) {
streamKeyLink = QTStr(
"https://restream.io/settings/streaming-setup?from=OBS");
streamKeyLink = "https://restream.io/settings/streaming-setup?from=OBS";
} else if (serviceName == "Facebook Live") {
streamKeyLink +=
QTStr("https://www.facebook.com/live/create?ref=OBS");
streamKeyLink = "https://www.facebook.com/live/create?ref=OBS";
} else if (serviceName.startsWith("Twitter")) {
streamKeyLink = QTStr("https://www.pscp.tv/account/producer");
streamKeyLink = "https://www.pscp.tv/account/producer";
} else if (serviceName.startsWith("YouStreamer")) {
streamKeyLink = "https://www.app.youstreamer.com/stream/";
}

if (QString(streamKeyLink).isNull()) {
Expand Down

0 comments on commit ee2c520

Please sign in to comment.