Skip to content

Commit 89eb3e2

Browse files
committed
UI: PreStream Wizard add completion page
Adds a completion page with content that depends on destinations. Back button is disabled on the last page where application will take place since updating settings is undoable. Various code fixes.
1 parent de747b5 commit 89eb3e2

16 files changed

Lines changed: 153 additions & 46 deletions

UI/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ set(obs_SOURCES
195195
pre-stream-wizard/page-input-display.cpp
196196
pre-stream-wizard/page-start-prompt.cpp
197197
pre-stream-wizard/page-select-settings.cpp
198+
pre-stream-wizard/page-completed.cpp
198199
pre-stream-wizard/setting-selection-row.cpp
199200
pre-stream-wizard/encoder-settings-provider-facebook.cpp
200201
obs-app.cpp
@@ -274,6 +275,7 @@ set(obs_HEADERS
274275
pre-stream-wizard/page-input-display.hpp
275276
pre-stream-wizard/page-start-prompt.hpp
276277
pre-stream-wizard/page-select-settings.hpp
278+
pre-stream-wizard/page-completed.hpp
277279
pre-stream-wizard/setting-selection-row.hpp
278280
pre-stream-wizard/encoder-settings-provider-facebook.hpp
279281
obs-app.hpp

UI/common-settings.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "audio-encoders.hpp"
44

5-
bool IsAdvancedMode(config_t *config)
5+
static bool IsAdvancedMode(config_t *config)
66
{
77
const char *outputMode = config_get_string(config, "Output", "Mode");
88
return (strcmp(outputMode, "Advanced") == 0);
@@ -16,7 +16,7 @@ OBSData CommonSettings::GetDataFromJsonFile(const char *jsonFile)
1616
int ret = GetProfilePath(fullPath, sizeof(fullPath), jsonFile);
1717
if (ret > 0) {
1818
BPtr<char> jsonData = os_quick_read_utf8_file(fullPath);
19-
if (!!jsonData) {
19+
if (jsonData) {
2020
data = obs_data_create_from_json(jsonData);
2121
}
2222
}
@@ -145,7 +145,7 @@ int CommonSettings::GetStreamingAudioBitrate(config_t *config)
145145

146146
int CommonSettings::GetSimpleAudioBitrate(config_t *config)
147147
{
148-
int bitrate = (int)config_get_uint(config, "SimpleOutput", "ABitrate");
148+
int bitrate = config_get_uint(config, "SimpleOutput", "ABitrate");
149149
return FindClosestAvailableAACBitrate(bitrate);
150150
}
151151

@@ -163,9 +163,11 @@ int CommonSettings::GetAdvancedAudioBitrateForTrack(config_t *config,
163163
"Track4Bitrate", "Track5Bitrate", "Track6Bitrate",
164164
};
165165

166-
// Sanity check for out of bounds
166+
// Sanity check for out of bounds, clamp to bounds
167167
if (trackIndex > 5)
168168
trackIndex = 5;
169+
if (trackIndex < 0)
170+
trackIndex = 0;
169171

170172
int bitrate = (int)config_get_uint(config, "AdvOut", names[trackIndex]);
171173
return FindClosestAvailableAACBitrate(bitrate);

UI/data/locale/en-US.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,9 @@ PreLiveWizard.Configure.Error.JsonParse="Problem with server response"
727727
PreLiveWizard.Configure.Error.JsonParse.Description="Wizard is unavailble at the moment."
728728
PreLiveWizard.Selection.Title="Settings Suggested"
729729
PreLiveWizard.Selection.Description="Suggested video settings for your best stream."
730-
730+
PreLiveWizard.Completed.Title="Encoder configured"
731+
PreLiveWizard.Completed.BodyText="Applied suggested settings and encoder is setup to stream. You can now close the wizard."
732+
PreLiveWizard.Completed.FacebookOnly="To finish going live go to Facebook Live:"
731733

732734
# basic mode 'output' settings
733735
Basic.Settings.Output="Output"

UI/pre-stream-wizard/encoder-settings-provider-facebook.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <QJsonObject>
1313
#include <QJsonArray>
1414
#include <QMap>
15-
#include <QDebug>
1615

1716
#include "obs-app.hpp"
1817
#include "obs-config.h"
@@ -57,7 +56,7 @@ void FacebookEncoderSettingsProvider::makeRequest(QUrl &url)
5756
"application/json");
5857

5958
// GET is made async
60-
settingsReply_ = restclient_->get(request);
59+
restclient_->get(request);
6160
// This is the callback when data is ready
6261
connect(restclient_, &QNetworkAccessManager::finished, this,
6362
&FacebookEncoderSettingsProvider::handleResponse);
@@ -66,7 +65,7 @@ void FacebookEncoderSettingsProvider::makeRequest(QUrl &url)
6665
QUrlQuery FacebookEncoderSettingsProvider::inputVideoQueryFromCurrentSettings()
6766
{
6867
// Get input settings, shorten name
69-
EncoderSettingsRequest *input = currentSettings_.get();
68+
EncoderSettingsRequest *input = currentSettings_.data();
7069

7170
QUrlQuery inputVideoSettingsQuery;
7271
inputVideoSettingsQuery.addQueryItem("video_type", "live");
@@ -126,6 +125,10 @@ void addInt(const QJsonObject &json, const char *jsonKey, SettingsMap *map,
126125
if (json[jsonKey].isDouble()) {
127126
map->insert(mapKey,
128127
QPair(QVariant(json[jsonKey].toInt()), true));
128+
} else {
129+
blog(LOG_WARNING,
130+
"FacebookEncoderSettingsProvider could not parse %s to Int",
131+
jsonKey);
129132
}
130133
}
131134

@@ -140,6 +143,10 @@ void addStringDouble(const QJsonObject &json, const char *jsonKey,
140143
double numberValue = valueString.toDouble(&converted);
141144
if (converted) {
142145
map->insert(mapKey, QPair(QVariant(numberValue), true));
146+
} else {
147+
blog(LOG_WARNING,
148+
"FacebookEncoderSettingsProvider couldn't parse %s to Double from String",
149+
jsonKey);
143150
}
144151
}
145152

@@ -149,6 +156,10 @@ void addQString(const QJsonObject &json, const char *jsonKey, SettingsMap *map,
149156
if (json[jsonKey].isString()) {
150157
map->insert(mapKey,
151158
QPair(QVariant(json[jsonKey].toString()), true));
159+
} else {
160+
blog(LOG_WARNING,
161+
"FacebookEncoderSettingsProvider could not parse %s to Strng",
162+
jsonKey);
152163
}
153164
}
154165

@@ -158,6 +169,10 @@ void addBool(const QJsonObject &json, const char *jsonKey, SettingsMap *map,
158169
if (json[jsonKey].isBool()) {
159170
map->insert(mapKey,
160171
QPair(QVariant(json[jsonKey].toBool()), true));
172+
} else {
173+
blog(LOG_WARNING,
174+
"FacebookEncoderSettingsProvider could not parse %s to Bool",
175+
jsonKey);
161176
}
162177
}
163178

UI/pre-stream-wizard/encoder-settings-provider-facebook.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class FacebookEncoderSettingsProvider : public QObject {
3737
private:
3838
QSharedPointer<EncoderSettingsRequest> currentSettings_;
3939
QNetworkAccessManager *restclient_;
40-
QNetworkReply *settingsReply_;
4140

4241
void makeRequest(QUrl &url);
4342
QUrlQuery inputVideoQueryFromCurrentSettings();
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "page-completed.hpp"
2+
3+
#include <QVBoxLayout>
4+
#include <QLabel>
5+
#include <QPushButton>
6+
#include <QUrl>
7+
#include <QSpacerItem>
8+
#include <QDesktopServices>
9+
10+
#include "obs-app.hpp"
11+
12+
namespace StreamWizard {
13+
14+
CompletedPage::CompletedPage(Destination destination,
15+
LaunchContext launchContext, QWidget *parent)
16+
: QWizardPage(parent)
17+
{
18+
destination_ = destination;
19+
launchContext_ = launchContext;
20+
21+
setTitle(QTStr("PreLiveWizard.Completed.Title"));
22+
23+
QVBoxLayout *mainlayout = new QVBoxLayout(this);
24+
setLayout(mainlayout);
25+
26+
// Later will suggest starting stream if launchContext is PreStream
27+
QLabel *closeLabel =
28+
new QLabel(QTStr("PreLiveWizard.Completed.BodyText"), this);
29+
closeLabel->setWordWrap(true);
30+
mainlayout->addWidget(closeLabel);
31+
32+
if (destination_ == Destination::Facebook) {
33+
mainlayout->addSpacerItem(new QSpacerItem(12, 12));
34+
35+
QLabel *facebookGoLiveLabel = new QLabel(
36+
QTStr("PreLiveWizard.Completed.FacebookOnly"), this);
37+
facebookGoLiveLabel->setWordWrap(true);
38+
QPushButton *launchButton = new QPushButton(
39+
QTStr("PreLiveWizard.Prompt.FBResolutionHelpButton.FB"),
40+
this);
41+
launchButton->setToolTip(QTStr(
42+
"PreLiveWizard.Prompt.FBResolutionHelpButton.FB.ToolTip"));
43+
connect(launchButton, &QPushButton::clicked, this,
44+
&CompletedPage::didPushOpenWebsite);
45+
46+
mainlayout->addWidget(facebookGoLiveLabel);
47+
mainlayout->addWidget(launchButton);
48+
}
49+
}
50+
51+
void CompletedPage::didPushOpenWebsite()
52+
{
53+
QUrl helpUrl;
54+
55+
// Prepare per-destination
56+
if (destination_ == Destination::Facebook) {
57+
helpUrl = QUrl(
58+
"https://www.facebook.com/live/producer/?ref=OBS_Wizard",
59+
QUrl::TolerantMode);
60+
} else {
61+
return;
62+
}
63+
// Launch
64+
if (helpUrl.isValid()) {
65+
QDesktopServices::openUrl(helpUrl);
66+
}
67+
}
68+
69+
} // namespace StreamWizard
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <QWizardPage>
4+
5+
#include "pre-stream-current-settings.hpp"
6+
7+
namespace StreamWizard {
8+
9+
// Last Page
10+
class CompletedPage : public QWizardPage {
11+
Q_OBJECT
12+
13+
public:
14+
CompletedPage(Destination destination, LaunchContext launchContext,
15+
QWidget *parent = nullptr);
16+
17+
private:
18+
Destination destination_;
19+
LaunchContext launchContext_;
20+
21+
private slots:
22+
void didPushOpenWebsite();
23+
24+
}; // class CompletedPage
25+
26+
} // namespace StreamWizard

UI/pre-stream-wizard/page-select-settings.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ SelectionPage::SelectionPage(QWidget *parent) : QWizardPage(parent)
1616
{
1717
this->setTitle(QTStr("PreLiveWizard.Selection.Title"));
1818
setupLayout();
19-
}
2019

21-
SelectionPage::~SelectionPage()
22-
{
23-
// nop
20+
setButtonText(QWizard::WizardButton::NextButton,
21+
QTStr("Basic.AutoConfig.ApplySettings"));
22+
setButtonText(QWizard::WizardButton::CommitButton,
23+
QTStr("Basic.AutoConfig.ApplySettings"));
24+
setCommitPage(true);
2425
}
2526

2627
void SelectionPage::setupLayout()
@@ -58,7 +59,7 @@ void SelectionPage::setSettingsMap(QSharedPointer<SettingsMap> settingsMap)
5859
return;
5960
}
6061
settingsMap_ = settingsMap;
61-
SettingsMap *mapInfo = settingsMap_.get();
62+
SettingsMap *mapInfo = settingsMap_.data();
6263

6364
if (mapInfo->contains(SettingsResponseKeys.videoBitrate)) {
6465
QVariant data =
@@ -190,7 +191,7 @@ void SelectionPage::checkboxRowChanged(const char *propertyKey, bool selected)
190191
return;
191192
}
192193

193-
SettingsMap *mapInfo = settingsMap_.get();
194+
SettingsMap *mapInfo = settingsMap_.data();
194195

195196
if (mapInfo == nullptr || !mapInfo->contains(propertyKey)) {
196197
return;

UI/pre-stream-wizard/page-select-settings.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class SelectionPage : public QWizardPage {
2222

2323
public:
2424
SelectionPage(QWidget *parent = nullptr);
25-
~SelectionPage();
2625

2726
// Sets data to layout scrollbox
2827
void setSettingsMap(QSharedPointer<SettingsMap> settingsMap);

UI/pre-stream-wizard/page-start-prompt.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ StartPage::StartPage(Destination dest, LaunchContext launchContext,
3939
resCurrentButton_->setChecked(true);
4040
}
4141
}
42-
43-
StartPage::~StartPage()
44-
{
45-
// nop
46-
}
47-
4842
void StartPage::createLayout()
4943
{
5044
QVBoxLayout *mainlayout = new QVBoxLayout(this);

0 commit comments

Comments
 (0)