Skip to content

Commit

Permalink
UI: Pre-stream wizard buttons are dynamic
Browse files Browse the repository at this point in the history
Hide buttons that are disabled for better user clarity.
  • Loading branch information
JohannMG committed Oct 2, 2020
1 parent d12f225 commit 1fca63e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 20 deletions.
7 changes: 4 additions & 3 deletions UI/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ Basic.Settings.Stream.MissingStreamKey="Stream key is missing.\n\nOpen settings
## Pre-Live Wizard and Settings
Basic.Settings.Stream.PreLiveWizard.RunNow="Check stream settings"
PreLiveWizard.Title="Verify Stream Settings"
PreLiveWizard.Prompt.Title="Verify stream settings before stream?"
PreLiveWizard.Prompt.Title="Verify stream settings before stream"
PreLiveWizard.Prompt.Subtitle.Default="The streaming wizard suggests the most up-to-date settings to improve your stream’s reliability, quality, and latency. \n\nSelect the resolution to stream to your account:"
PreLiveWizard.Prompt.Subtitle.FB="Your destination is set to Facebook Live."
PreLiveWizard.Prompt.Explainer="The Streaming wizard suggests the most up-to-date settings to improve your stream’s reliability, quality, and latency."
Expand All @@ -727,8 +727,9 @@ PreLiveWizard.Configure.ServiceNotAvailable.Description="The service selected in
PreLiveWizard.Configure.Error.Url="Settings setup failed. Query: "
PreLiveWizard.Configure.Error.JsonParse="Problem with server response"
PreLiveWizard.Configure.Error.JsonParse.Description="Wizard is unavailble at the moment."
PreLiveWizard.Selection.Title="Settings Suggested"
PreLiveWizard.Selection.Description="Suggested video settings for your best stream."
PreLiveWizard.Configure.Error.NoData="No new settings recieved."
PreLiveWizard.Selection.Title="Suggested Settings"
PreLiveWizard.Selection.Description="Suggested video settings for your best stream:"
PreLiveWizard.Completed.Title="Encoder configured"
PreLiveWizard.Completed.BodyText="Applied suggested settings and encoder is setup to stream. You can now close the wizard."
PreLiveWizard.Completed.FacebookOnly="To finish going live go to Facebook Live:"
Expand Down
12 changes: 6 additions & 6 deletions UI/pre-stream-wizard/page-loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QSpacerItem>
#include <QVBoxLayout>
#include <QTimer>
#include <QList>

#include "obs-app.hpp"

Expand All @@ -13,6 +14,10 @@ LoadingPage::LoadingPage(QWidget *parent) : QWizardPage(parent)
setTitle(QTStr("PreLiveWizard.Loading.Title"));
setCommitPage(true);

timer_ = new QTimer(this);
connect(timer_, &QTimer::timeout, this, &LoadingPage::tick);
timer_->setSingleShot(false);

labels_.append(QTStr("Loading"));
labels_.append(QTStr("Loading") + ".");
labels_.append(QTStr("Loading") + "." + ".");
Expand All @@ -27,12 +32,7 @@ LoadingPage::LoadingPage(QWidget *parent) : QWizardPage(parent)

void LoadingPage::initializePage()
{
if (timer_ == nullptr) {
timer_ = new QTimer(this);
connect(timer_, &QTimer::timeout, this, &LoadingPage::tick);
}
timer_->setSingleShot(false);
timer_->start(500);
timer_->start(300);
}
void LoadingPage::cleanupPage()
{
Expand Down
6 changes: 0 additions & 6 deletions UI/pre-stream-wizard/page-start-prompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ StartPage::StartPage(Destination dest, LaunchContext launchContext,

setTitle(QTStr("PreLiveWizard.Prompt.Title"));

if (destination_ == Destination::Facebook) {
setSubTitle(QTStr("PreLiveWizard.Prompt.Subtitle.FB"));
} else {
setSubTitle(QTStr("PreLiveWizard.Prompt.Subtitle.Default"));
}

createLayout();
connectRadioButtons();

Expand Down
46 changes: 41 additions & 5 deletions UI/pre-stream-wizard/pre-stream-wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QFormLayout>
#include <QLabel>
#include <QSize>
#include <QList>

#include "obs-app.hpp"
#include "encoder-settings-provider-facebook.hpp"
Expand Down Expand Up @@ -38,6 +39,8 @@ PreStreamWizard::PreStreamWizard(

setWizardStyle(QWizard::ModernStyle);
setWindowTitle(QTStr("PreLiveWizard.Title"));
setOption(QWizard::NoBackButtonOnStartPage, true);
setOption(QWizard::NoBackButtonOnLastPage, true);

// First Page: Explain to the user and confirm sending to API
QSize currentRes(currentSettings_->videoWidth,
Expand All @@ -61,6 +64,7 @@ PreStreamWizard::PreStreamWizard(
new CompletedPage(destination_, launchContext_, this);
setPage(Page_Complete, completedPage);

// Add error page shown instead of completion in failure cases
errorPage_ = new ErrorPage(this);
setPage(Page_Error, errorPage_);
}
Expand Down Expand Up @@ -113,21 +117,26 @@ void PreStreamWizard::onPageChanged(int id)
switch (id) {
case Page_StartPrompt:
setOption(QWizard::NoCancelButton, false);
setButtons(NextStep);
break;

case Page_Loading:
requestSettings();
setButtons(CancelOnly);
break;

case Page_Selections:
selectionPage_->setSettingsMap(newSettingsMap_);
setButtons(CommitStep);
break;

case Page_Complete:
setButtons(FinishOnly);
break;

case Page_Error:
sendToErrorPage_ = false;
setButtons(FinishOnly);
break;
}
}
Expand All @@ -137,22 +146,49 @@ int PreStreamWizard::nextId() const
switch (currentId()) {
case Page_StartPrompt:
return Page_Loading;
case Page_Loading:
return sendToErrorPage_ ? Page_Error : Page_Selections;
case Page_Loading: {
if (sendToErrorPage_)
return Page_Error;
if (newSettingsMap_ == nullptr || newSettingsMap_.isNull()) {
errorPage_->setText(
QTStr("PreLiveWizard.Configure.Error.NoData"),
QTStr("PreLiveWizard.Configure.Error.JsonParse.Description"));
return Page_Error;
}
return Page_Selections;
}
case Page_Selections:
return Page_Complete;
break;
case Page_Complete:
return -1;
case Page_Error:
return -1;
}

if (currentId() == Page_Loading) {
}
return QWizard::nextId();
}

void PreStreamWizard::setButtons(ButtonLayout layout)
{
QList<QWizard::WizardButton> layoutList;
layoutList << QWizard::Stretch;
switch (layout) {
case NextStep:
layoutList << QWizard::NextButton << QWizard::CancelButton;
break;
case CommitStep:
layoutList << QWizard::CommitButton << QWizard::CancelButton;
break;
case CancelOnly:
layoutList << QWizard::CancelButton;
break;
case FinishOnly:
layoutList << QWizard::FinishButton;
break;
}
setButtonLayout(layoutList);
}

void PreStreamWizard::onUserSelectResolution(QSize newSize)
{
blog(LOG_INFO, "Selected res %d x %d", newSize.width(),
Expand Down
9 changes: 9 additions & 0 deletions UI/pre-stream-wizard/pre-stream-wizard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class PreStreamWizard : public QWizard {

void requestSettings();

// Wizard uses custom button layouts to manage user flow & aborts.
enum ButtonLayout {
NextStep,
CancelOnly,
FinishOnly,
CommitStep,
};
void setButtons(ButtonLayout layout);

signals:
// User left the wizard with intention to continue streaming
void userSkippedWizard(void);
Expand Down

0 comments on commit 1fca63e

Please sign in to comment.