From c482f463e05d31a818d16511dff0020bf37cd041 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 14 Nov 2018 20:02:02 -0800 Subject: [PATCH] UI: Remove "service type" from auto-config stream page The "Custom" service has been moved, and is now an item called "Custom" in the "Services" combo box. This simplifies the stream page of auto-configuration and removes an unnecessary widget. Overall a minor but nice slimline/improvement on user experience. --- UI/data/locale/en-US.ini | 1 + UI/forms/AutoConfigStreamPage.ui | 225 +++++++++++++++---------------- UI/window-basic-auto-config.cpp | 49 +++---- UI/window-basic-auto-config.hpp | 1 + 4 files changed, 135 insertions(+), 141 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 3b06e7685..851ba744c 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -127,6 +127,7 @@ Basic.AutoConfig.StreamPage="Stream Information" Basic.AutoConfig.StreamPage.SubTitle="Please enter your stream information" Basic.AutoConfig.StreamPage.Service="Service" Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..." +Basic.AutoConfig.StreamPage.Service.Custom="Custom" Basic.AutoConfig.StreamPage.Server="Server" Basic.AutoConfig.StreamPage.StreamKey="Stream Key" Basic.AutoConfig.StreamPage.StreamKey.LinkToSite="(Link)" diff --git a/UI/forms/AutoConfigStreamPage.ui b/UI/forms/AutoConfigStreamPage.ui index 594f99e0c..6f4d27a3b 100644 --- a/UI/forms/AutoConfigStreamPage.ui +++ b/UI/forms/AutoConfigStreamPage.ui @@ -20,7 +20,7 @@ Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - + Basic.AutoConfig.StreamPage.Service @@ -30,103 +30,17 @@ - + - - - - Basic.AutoConfig.StreamPage.StreamKey - - - true - - - key - - - - - - - - - - - - - - - QLineEdit::Password - - - - - - - Show - - - - - - - - - Basic.AutoConfig.StreamPage.PerformBandwidthTest - - - true - - - - - - - Basic.AutoConfig.StreamPage.PreferHardwareEncoding.ToolTip - - - Basic.AutoConfig.StreamPage.PreferHardwareEncoding - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 90 - 20 - - - - - + Basic.AutoConfig.StreamPage.Server - - - - Basic.Settings.Stream.StreamType - - - - - - - + 0 @@ -171,7 +85,109 @@ - + + + + Basic.AutoConfig.StreamPage.StreamKey + + + true + + + key + + + + + + + + + + + + + + + QLineEdit::Password + + + + + + + Show + + + + + + + + + Basic.Settings.Output.VideoBitrate + + + bitrate + + + + + + + + + + 500 + + + 10000 + + + 2500 + + + + + + + Basic.AutoConfig.StreamPage.PreferHardwareEncoding.ToolTip + + + Basic.AutoConfig.StreamPage.PreferHardwareEncoding + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 90 + 20 + + + + + + + + Basic.AutoConfig.StreamPage.PerformBandwidthTest + + + true + + + + BandwidthTest.Region @@ -208,36 +224,9 @@ - - - - - - - 500 - - - 10000 - - - 2500 - - - - - - - Basic.Settings.Output.VideoBitrate - - - bitrate - - - - streamType service server customServer diff --git a/UI/window-basic-auto-config.cpp b/UI/window-basic-auto-config.cpp index 7ddf2afa8..10d2b58c3 100644 --- a/UI/window-basic-auto-config.cpp +++ b/UI/window-basic-auto-config.cpp @@ -210,6 +210,11 @@ bool AutoConfigVideoPage::validatePage() /* ------------------------------------------------------------------------- */ +enum class ListOpt : int { + ShowAll = 1, + Custom +}; + AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent) : QWizardPage (parent), ui (new Ui_AutoConfigStreamPage) @@ -218,16 +223,11 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent) ui->bitrateLabel->setVisible(false); ui->bitrate->setVisible(false); - ui->streamType->addItem(obs_service_get_display_name("rtmp_common")); - ui->streamType->addItem(obs_service_get_display_name("rtmp_custom")); - setTitle(QTStr("Basic.AutoConfig.StreamPage")); setSubTitle(QTStr("Basic.AutoConfig.StreamPage.SubTitle")); LoadServices(false); - connect(ui->streamType, SIGNAL(currentIndexChanged(int)), - this, SLOT(ServiceChanged())); connect(ui->service, SIGNAL(currentIndexChanged(int)), this, SLOT(ServiceChanged())); connect(ui->customServer, SIGNAL(textChanged(const QString &)), @@ -238,8 +238,6 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent) connect(ui->service, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateServerList())); - connect(ui->streamType, SIGNAL(currentIndexChanged(int)), - this, SLOT(UpdateKeyLink())); connect(ui->service, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateKeyLink())); @@ -270,12 +268,17 @@ int AutoConfigStreamPage::nextId() const return AutoConfig::TestPage; } +inline bool AutoConfigStreamPage::IsCustom() const +{ + return ui->service->currentData().toInt() == (int)ListOpt::Custom; +} + bool AutoConfigStreamPage::validatePage() { OBSData service_settings = obs_data_create(); obs_data_release(service_settings); - wiz->customServer = ui->streamType->currentIndex() == 1; + wiz->customServer = IsCustom(); const char *serverType = wiz->customServer ? "rtmp_custom" @@ -360,7 +363,8 @@ void AutoConfigStreamPage::on_show_clicked() void AutoConfigStreamPage::ServiceChanged() { - bool showMore = ui->service->currentData().toBool(); + bool showMore = + ui->service->currentData().toInt() == (int)ListOpt::ShowAll; if (showMore) return; @@ -368,18 +372,12 @@ void AutoConfigStreamPage::ServiceChanged() bool regionBased = service == "Twitch" || service == "Smashcast"; bool testBandwidth = ui->doBandwidthTest->isChecked(); - bool custom = ui->streamType->currentIndex() == 1; + bool custom = IsCustom(); /* Test three closest servers if "Auto" is available for Twitch */ if (service == "Twitch" && wiz->twitchAuto) regionBased = false; - ui->service->setVisible(!custom); - ui->serviceLabel->setVisible(!custom); - - ui->formLayout->removeWidget(ui->serviceLabel); - ui->formLayout->removeWidget(ui->service); - ui->formLayout->removeWidget(ui->serverLabel); ui->formLayout->removeWidget(ui->serverStackedWidget); @@ -392,8 +390,6 @@ void AutoConfigStreamPage::ServiceChanged() ui->serverStackedWidget->setVisible(true); ui->serverLabel->setVisible(true); } else { - ui->formLayout->insertRow(1, ui->serviceLabel, ui->service); - if (!testBandwidth) ui->formLayout->insertRow(2, ui->serverLabel, ui->serverStackedWidget); @@ -414,7 +410,7 @@ void AutoConfigStreamPage::ServiceChanged() void AutoConfigStreamPage::UpdateKeyLink() { - bool custom = ui->streamType->currentIndex() == 1; + bool custom = IsCustom(); QString serviceName = ui->service->currentText(); bool isYoutube = false; @@ -487,9 +483,13 @@ void AutoConfigStreamPage::LoadServices(bool showAll) if (!showAll) { ui->service->addItem( QTStr("Basic.AutoConfig.StreamPage.Service.ShowAll"), - QVariant(true)); + QVariant((int)ListOpt::ShowAll)); } + ui->service->insertItem(0, + QTStr("Basic.AutoConfig.StreamPage.Service.Custom"), + QVariant((int)ListOpt::Custom)); + obs_properties_destroy(props); ui->service->blockSignals(false); @@ -498,7 +498,8 @@ void AutoConfigStreamPage::LoadServices(bool showAll) void AutoConfigStreamPage::UpdateServerList() { QString serviceName = ui->service->currentText(); - bool showMore = ui->service->currentData().toBool(); + bool showMore = + ui->service->currentData().toInt() == (int)ListOpt::ShowAll; if (showMore) { LoadServices(true); @@ -536,7 +537,7 @@ void AutoConfigStreamPage::UpdateCompleted() if (ui->key->text().isEmpty()) { ready = false; } else { - bool custom = ui->streamType->currentIndex() == 1; + bool custom = IsCustom(); if (custom) { ready = !ui->customServer->text().isEmpty(); } else { @@ -646,7 +647,9 @@ AutoConfig::AutoConfig(QWidget *parent) serverList->setCurrentIndex(idx); } else { streamPage->ui->customServer->setText(server.c_str()); - streamPage->ui->streamType->setCurrentIndex(1); + int idx = streamPage->ui->service->findData( + QVariant((int)ListOpt::Custom)); + streamPage->ui->service->setCurrentIndex(idx); } if (!key.empty()) diff --git a/UI/window-basic-auto-config.hpp b/UI/window-basic-auto-config.hpp index 3478df2c7..4f7e6bb70 100644 --- a/UI/window-basic-auto-config.hpp +++ b/UI/window-basic-auto-config.hpp @@ -160,6 +160,7 @@ class AutoConfigStreamPage : public QWizardPage { bool ready = false; void LoadServices(bool showAll); + inline bool IsCustom() const; public: AutoConfigStreamPage(QWidget *parent = nullptr);