Skip to content

Commit

Permalink
UI: Upgrade stream link hotlink to a button
Browse files Browse the repository at this point in the history
Most of the top streaming services now have a link in the stream key
label. Upgrading this button to a button clarifies the assistance
for the important step of setting up a stream.

Creates a new type of button for URL opening simply which also
automatically updates the tootip to the current URL.

Includes addition of Twitter/Periscope URL to make this feature more
complete.
  • Loading branch information
JohannMG committed Oct 25, 2019
1 parent c56de17 commit a57d6fa
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 59 deletions.
2 changes: 2 additions & 0 deletions UI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ set(obs_SOURCES
combobox-ignorewheel.cpp
spinbox-ignorewheel.cpp
record-button.cpp
url-push-button.cpp
volume-control.cpp
adv-audio-control.cpp
item-widget-helpers.cpp
Expand Down Expand Up @@ -298,6 +299,7 @@ set(obs_HEADERS
menu-button.hpp
mute-checkbox.hpp
record-button.hpp
url-push-button.hpp
volume-control.hpp
adv-audio-control.hpp
item-widget-helpers.hpp
Expand Down
2 changes: 2 additions & 0 deletions UI/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ Basic.AutoConfig.StreamPage.ConnectAccount="Connect Account (recommended)"
Basic.AutoConfig.StreamPage.DisconnectAccount="Disconnect Account"
Basic.AutoConfig.StreamPage.DisconnectAccount.Confirm.Title="Disconnect Account?"
Basic.AutoConfig.StreamPage.DisconnectAccount.Confirm.Text="This change will apply immediately. Are you sure you want to disconnect your account?"
Basic.AutoConfig.StreamPage.GetStreamKey="Get Stream Key"
Basic.AutoConfig.StreamPage.GetStreamKey.ToolTip="Open in browser to fetch streamkey"
Basic.AutoConfig.StreamPage.UseStreamKey="Use Stream Key"
Basic.AutoConfig.StreamPage.Service="Service"
Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..."
Expand Down
93 changes: 65 additions & 28 deletions UI/forms/OBSBasicSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<item>
<widget class="QStackedWidget" name="settingsPages">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="generalPage">
<layout class="QVBoxLayout" name="verticalLayout_18">
Expand Down Expand Up @@ -151,8 +151,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>977</height>
<width>630</width>
<height>1035</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
Expand Down Expand Up @@ -775,7 +775,7 @@
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="serviceLabel">
<property name="text">
<string>Basic.AutoConfig.StreamPage.Service</string>
Expand All @@ -785,7 +785,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="service">
<property name="maxVisibleItems">
<number>20</number>
Expand Down Expand Up @@ -921,7 +921,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="serverStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="servicePage">
<layout class="QHBoxLayout" name="horizontalLayout_21">
Expand Down Expand Up @@ -1014,7 +1014,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -1027,7 +1027,7 @@
</property>
</spacer>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QPushButton" name="connectAccount2">
Expand All @@ -1051,7 +1051,7 @@
</item>
</layout>
</item>
<item row="3" column="1">
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QPushButton" name="disconnectAccount">
Expand All @@ -1076,16 +1076,20 @@
</layout>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="useAuth">
<widget class="QCheckBox" name="bandwidthTestEnable">
<property name="text">
<string>Basic.Settings.Stream.Custom.UseAuthentication</string>
<string>Basic.Settings.Stream.BandwidthTestMode</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="authUsername"/>
<widget class="QCheckBox" name="useAuth">
<property name="text">
<string>Basic.Settings.Stream.Custom.UseAuthentication</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="authUsernameLabel">
<property name="text">
<string>Basic.Settings.Stream.Custom.Username</string>
Expand All @@ -1095,7 +1099,10 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="7" column="1">
<widget class="QLineEdit" name="authUsername"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="authPwLabel">
<property name="text">
<string>Basic.Settings.Stream.Custom.Password</string>
Expand All @@ -1105,7 +1112,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QWidget" name="authPwWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_25">
<property name="leftMargin">
Expand Down Expand Up @@ -1137,12 +1144,35 @@
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="bandwidthTestEnable">
<property name="text">
<string>Basic.Settings.Stream.BandwidthTestMode</string>
</property>
</widget>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="UrlPushButton" name="getStreamKeyButton">
<property name="toolTip">
<string/>
</property>
<property name="toolTipDuration">
<number>-4</number>
</property>
<property name="text">
<string>Basic.AutoConfig.StreamPage.GetStreamKey</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_26">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -1180,8 +1210,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>631</height>
<width>739</width>
<height>793</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
Expand Down Expand Up @@ -3628,8 +3658,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>555</width>
<height>469</height>
<width>696</width>
<height>601</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_50">
Expand Down Expand Up @@ -4199,7 +4229,7 @@
<item row="3" column="1">
<widget class="QStackedWidget" name="fpsTypes">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QHBoxLayout" name="horizontalLayout_2">
Expand Down Expand Up @@ -4444,8 +4474,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>781</height>
<width>759</width>
<height>930</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
Expand Down Expand Up @@ -5249,6 +5279,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UrlPushButton</class>
<extends>QPushButton</extends>
<header>url-push-button.hpp</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>listWidget</tabstop>
<tabstop>scrollArea_2</tabstop>
Expand Down
27 changes: 27 additions & 0 deletions UI/url-push-button.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "url-push-button.hpp"

#include <QUrl>
#include <QMouseEvent>
#include <QDesktopServices>

void UrlPushButton::setTargetUrl(QUrl url)
{
setToolTip(url.toString());
m_targetUrl = url;
}

QUrl UrlPushButton::targetUrl()
{
return m_targetUrl;
}

void UrlPushButton::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
QUrl openUrl = m_targetUrl;
if (openUrl.isEmpty())
return;

QDesktopServices::openUrl(openUrl);
}

21 changes: 21 additions & 0 deletions UI/url-push-button.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <QPushButton>
#include <QUrl>

class UrlPushButton : public QPushButton {
Q_OBJECT
Q_PROPERTY(QUrl targetUrl READ targetUrl WRITE setTargetUrl)

public:
inline UrlPushButton(QWidget *parent = nullptr) : QPushButton(parent) {}
void setTargetUrl(QUrl url);
QUrl targetUrl();

protected:
void mousePressEvent(QMouseEvent *event) override;

private:
QUrl m_targetUrl;
};

54 changes: 23 additions & 31 deletions UI/window-basic-settings-stream.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <QMessageBox>
#include <QUrl>

#include "window-basic-settings.hpp"
#include "obs-frontend-api.h"
#include "obs-app.hpp"
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "url-push-button.hpp"

#ifdef BROWSER_AVAILABLE
#include <browser-panel.hpp>
Expand Down Expand Up @@ -177,44 +179,34 @@ void OBSBasicSettings::SaveStream1Settings()

void OBSBasicSettings::UpdateKeyLink()
{
bool custom = IsCustomService();
QString serviceName = ui->service->currentText();

if (custom)
serviceName = "";
if (IsCustomService()) {
ui->getStreamKeyButton->hide();
return;
}

QString text = QTStr("Basic.AutoConfig.StreamPage.StreamKey");
QString serviceName = ui->service->currentText();
QString streamKeyLink;
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 = QTStr(
"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 = QTStr("https://www.youtube.com/live_dashboard");
} 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>";
streamKeyLink = QTStr(
"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 +=
QTStr("https://www.facebook.com/live/create?ref=OBS");
} else if (serviceName.startsWith("Twitter")) {
streamKeyLink = QTStr("https://www.pscp.tv/account/producer");
}

ui->streamKeyLabel->setText(text);
if (QString(streamKeyLink).isNull()) {
ui->getStreamKeyButton->hide();
} else {
ui->getStreamKeyButton->setTargetUrl(QUrl(streamKeyLink));
ui->getStreamKeyButton->show();
}
}

void OBSBasicSettings::LoadServices(bool showAll)
Expand Down

0 comments on commit a57d6fa

Please sign in to comment.