UI: Upgrade stream link hotlink to a button

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.
master
JohannMG 2019-10-24 21:05:43 -07:00
parent c56de17bdb
commit 3f6cf0e871
6 changed files with 125 additions and 64 deletions

View File

@ -243,6 +243,7 @@ set(obs_SOURCES
combobox-ignorewheel.cpp combobox-ignorewheel.cpp
spinbox-ignorewheel.cpp spinbox-ignorewheel.cpp
record-button.cpp record-button.cpp
url-push-button.cpp
volume-control.cpp volume-control.cpp
adv-audio-control.cpp adv-audio-control.cpp
item-widget-helpers.cpp item-widget-helpers.cpp
@ -298,6 +299,7 @@ set(obs_HEADERS
menu-button.hpp menu-button.hpp
mute-checkbox.hpp mute-checkbox.hpp
record-button.hpp record-button.hpp
url-push-button.hpp
volume-control.hpp volume-control.hpp
adv-audio-control.hpp adv-audio-control.hpp
item-widget-helpers.hpp item-widget-helpers.hpp

View File

@ -162,6 +162,7 @@ Basic.AutoConfig.StreamPage.ConnectAccount="Connect Account (recommended)"
Basic.AutoConfig.StreamPage.DisconnectAccount="Disconnect Account" Basic.AutoConfig.StreamPage.DisconnectAccount="Disconnect Account"
Basic.AutoConfig.StreamPage.DisconnectAccount.Confirm.Title="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.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.UseStreamKey="Use Stream Key" Basic.AutoConfig.StreamPage.UseStreamKey="Use Stream Key"
Basic.AutoConfig.StreamPage.Service="Service" Basic.AutoConfig.StreamPage.Service="Service"
Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..." Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..."

View File

@ -151,8 +151,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>803</width> <width>630</width>
<height>977</height> <height>1035</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_19"> <layout class="QVBoxLayout" name="verticalLayout_19">
@ -775,7 +775,7 @@
<property name="labelAlignment"> <property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="serviceLabel"> <widget class="QLabel" name="serviceLabel">
<property name="text"> <property name="text">
<string>Basic.AutoConfig.StreamPage.Service</string> <string>Basic.AutoConfig.StreamPage.Service</string>
@ -785,7 +785,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="service"> <widget class="QComboBox" name="service">
<property name="maxVisibleItems"> <property name="maxVisibleItems">
<number>20</number> <number>20</number>
@ -921,7 +921,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QStackedWidget" name="serverStackedWidget"> <widget class="QStackedWidget" name="serverStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="servicePage"> <widget class="QWidget" name="servicePage">
<layout class="QHBoxLayout" name="horizontalLayout_21"> <layout class="QHBoxLayout" name="horizontalLayout_21">
@ -1011,10 +1011,23 @@
</property> </property>
</widget> </widget>
</item> </item>
<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>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<spacer name="horizontalSpacer_18"> <spacer name="horizontalSpacer_18">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1027,7 +1040,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_15"> <layout class="QHBoxLayout" name="horizontalLayout_15">
<item> <item>
<widget class="QPushButton" name="connectAccount2"> <widget class="QPushButton" name="connectAccount2">
@ -1051,7 +1064,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_23"> <layout class="QHBoxLayout" name="horizontalLayout_23">
<item> <item>
<widget class="QPushButton" name="disconnectAccount"> <widget class="QPushButton" name="disconnectAccount">
@ -1076,16 +1089,20 @@
</layout> </layout>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="QCheckBox" name="bandwidthTestEnable">
<property name="text">
<string>Basic.Settings.Stream.BandwidthTestMode</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="useAuth"> <widget class="QCheckBox" name="useAuth">
<property name="text"> <property name="text">
<string>Basic.Settings.Stream.Custom.UseAuthentication</string> <string>Basic.Settings.Stream.Custom.UseAuthentication</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="0">
<widget class="QLineEdit" name="authUsername"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="authUsernameLabel"> <widget class="QLabel" name="authUsernameLabel">
<property name="text"> <property name="text">
<string>Basic.Settings.Stream.Custom.Username</string> <string>Basic.Settings.Stream.Custom.Username</string>
@ -1095,7 +1112,10 @@
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QLabel" name="authPwLabel">
<property name="text"> <property name="text">
<string>Basic.Settings.Stream.Custom.Password</string> <string>Basic.Settings.Stream.Custom.Password</string>
@ -1105,7 +1125,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="QWidget" name="authPwWidget" native="true"> <widget class="QWidget" name="authPwWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_25"> <layout class="QHBoxLayout" name="horizontalLayout_25">
<property name="leftMargin"> <property name="leftMargin">
@ -1137,13 +1157,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QCheckBox" name="bandwidthTestEnable">
<property name="text">
<string>Basic.Settings.Stream.BandwidthTestMode</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@ -1180,8 +1193,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>739</width>
<height>631</height> <height>793</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_21"> <layout class="QVBoxLayout" name="verticalLayout_21">
@ -3628,8 +3641,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>555</width> <width>696</width>
<height>469</height> <height>601</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_50"> <layout class="QVBoxLayout" name="verticalLayout_50">
@ -4199,7 +4212,7 @@
<item row="3" column="1"> <item row="3" column="1">
<widget class="QStackedWidget" name="fpsTypes"> <widget class="QStackedWidget" name="fpsTypes">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
@ -4444,8 +4457,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>803</width> <width>759</width>
<height>781</height> <height>930</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_23"> <layout class="QVBoxLayout" name="verticalLayout_23">
@ -5249,6 +5262,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>UrlPushButton</class>
<extends>QPushButton</extends>
<header>url-push-button.hpp</header>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>listWidget</tabstop> <tabstop>listWidget</tabstop>
<tabstop>scrollArea_2</tabstop> <tabstop>scrollArea_2</tabstop>

26
UI/url-push-button.cpp Normal file
View File

@ -0,0 +1,26 @@
#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);
}

20
UI/url-push-button.hpp Normal file
View File

@ -0,0 +1,20 @@
#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;
};

View File

@ -1,10 +1,12 @@
#include <QMessageBox> #include <QMessageBox>
#include <QUrl>
#include "window-basic-settings.hpp" #include "window-basic-settings.hpp"
#include "obs-frontend-api.h" #include "obs-frontend-api.h"
#include "obs-app.hpp" #include "obs-app.hpp"
#include "window-basic-main.hpp" #include "window-basic-main.hpp"
#include "qt-wrappers.hpp" #include "qt-wrappers.hpp"
#include "url-push-button.hpp"
#ifdef BROWSER_AVAILABLE #ifdef BROWSER_AVAILABLE
#include <browser-panel.hpp> #include <browser-panel.hpp>
@ -177,44 +179,34 @@ void OBSBasicSettings::SaveStream1Settings()
void OBSBasicSettings::UpdateKeyLink() void OBSBasicSettings::UpdateKeyLink()
{ {
bool custom = IsCustomService(); if (IsCustomService()) {
QString serviceName = ui->service->currentText(); ui->getStreamKeyButton->hide();
return;
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>";
} 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>";
} 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 == "Facebook Live") {
text += " <a href=\"https://";
text += "www.facebook.com/live/create";
text += "\">";
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
} }
ui->streamKeyLabel->setText(text); QString serviceName = ui->service->currentText();
QString streamKeyLink;
if (serviceName == "Twitch") {
streamKeyLink = QTStr(
"https://www.twitch.tv/broadcast/dashboard/streamkey");
} else if (serviceName == "YouTube / YouTube Gaming") {
streamKeyLink = QTStr("https://www.youtube.com/live_dashboard");
} else if (serviceName.startsWith("Restream.io")) {
streamKeyLink = QTStr(
"https://restream.io/settings/streaming-setup?from=OBS");
} else if (serviceName == "Facebook Live") {
streamKeyLink +=
QTStr("https://www.facebook.com/live/create?ref=OBS");
} else if (serviceName.startsWith("Twitter")) {
streamKeyLink = QTStr("https://www.pscp.tv/account/producer");
}
if (QString(streamKeyLink).isNull()) {
ui->getStreamKeyButton->hide();
} else {
ui->getStreamKeyButton->setTargetUrl(QUrl(streamKeyLink));
ui->getStreamKeyButton->show();
}
} }
void OBSBasicSettings::LoadServices(bool showAll) void OBSBasicSettings::LoadServices(bool showAll)