Sfoglia il codice sorgente

UI: Add support for "More Info" link from service

(Jim) Allows the ability to get a link from the service's settings about
a specific service selection the user chooses and display it as a "More
Info" button that the user can click to find out more information about
that particular service.
Maya Venkatraman 5 anni fa
parent
commit
41f4a0b0b9

+ 1 - 0
UI/data/locale/en-US.ini

@@ -174,6 +174,7 @@ 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.MoreInfo="More Info"
 Basic.AutoConfig.StreamPage.UseStreamKey="Use Stream Key"
 Basic.AutoConfig.StreamPage.Service="Service"
 Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..."

+ 26 - 1
UI/forms/AutoConfigStreamPage.ui

@@ -74,7 +74,32 @@
        </widget>
       </item>
       <item row="1" column="1">
-       <widget class="QComboBox" name="service"/>
+       <widget class="QWidget" name="serviceWidget" native="true">
+        <layout class="QHBoxLayout" name="serviceWidgetLayout">
+         <property name="leftMargin">
+          <number>0</number>
+         </property>
+         <property name="topMargin">
+          <number>0</number>
+         </property>
+         <property name="rightMargin">
+          <number>0</number>
+         </property>
+         <property name="bottomMargin">
+          <number>0</number>
+         </property>
+         <item>
+          <widget class="QComboBox" name="service"/>
+         </item>
+         <item>
+          <widget class="UrlPushButton" name="moreInfoButton">
+           <property name="text">
+            <string>Basic.AutoConfig.StreamPage.MoreInfo</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
       </item>
       <item row="2" column="1">
        <spacer name="verticalSpacer">

+ 35 - 4
UI/forms/OBSBasicSettings.ui

@@ -824,10 +824,41 @@
              </widget>
             </item>
             <item row="3" column="1">
-             <widget class="QComboBox" name="service">
-              <property name="maxVisibleItems">
-               <number>20</number>
-              </property>
+             <widget class="QWidget" name="serviceWidget" native="true">
+              <layout class="QHBoxLayout" name="serviceWidgetLayout" stretch="0,0">
+               <property name="leftMargin">
+                <number>0</number>
+               </property>
+               <property name="topMargin">
+                <number>0</number>
+               </property>
+               <property name="rightMargin">
+                <number>0</number>
+               </property>
+               <property name="bottomMargin">
+                <number>0</number>
+               </property>
+               <item>
+                <widget class="QComboBox" name="service">
+                 <property name="maxVisibleItems">
+                  <number>20</number>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="UrlPushButton" name="moreInfoButton">
+                 <property name="sizePolicy">
+                  <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+                   <horstretch>0</horstretch>
+                   <verstretch>0</verstretch>
+                  </sizepolicy>
+                 </property>
+                 <property name="text">
+                  <string>Basic.AutoConfig.StreamPage.MoreInfo</string>
+                 </property>
+                </widget>
+               </item>
+              </layout>
              </widget>
             </item>
             <item row="1" column="0">

+ 32 - 0
UI/window-basic-auto-config.cpp

@@ -285,6 +285,8 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent)
 
 	connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
 		SLOT(UpdateKeyLink()));
+	connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
+		SLOT(UpdateMoreInfoLink()));
 
 	connect(ui->key, SIGNAL(textChanged(const QString &)), this,
 		SLOT(UpdateCompleted()));
@@ -575,6 +577,35 @@ void AutoConfigStreamPage::ServiceChanged()
 	UpdateCompleted();
 }
 
+void AutoConfigStreamPage::UpdateMoreInfoLink()
+{
+	if (IsCustomService()) {
+		ui->moreInfoButton->hide();
+		return;
+	}
+
+	QString serviceName = ui->service->currentText();
+	obs_properties_t *props = obs_get_service_properties("rtmp_common");
+	obs_property_t *services = obs_properties_get(props, "service");
+
+	OBSData settings = obs_data_create();
+	obs_data_release(settings);
+
+	obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName));
+	obs_property_modified(services, settings);
+
+	const char *more_info_link =
+		obs_data_get_string(settings, "more_info_link");
+
+	if (!more_info_link || (*more_info_link == '\0')) {
+		ui->moreInfoButton->hide();
+	} else {
+		ui->moreInfoButton->setTargetUrl(QUrl(more_info_link));
+		ui->moreInfoButton->show();
+	}
+	obs_properties_destroy(props);
+}
+
 void AutoConfigStreamPage::UpdateKeyLink()
 {
 	QString serviceName = ui->service->currentText();
@@ -814,6 +845,7 @@ AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent)
 
 	streamPage->UpdateServerList();
 	streamPage->UpdateKeyLink();
+	streamPage->UpdateMoreInfoLink();
 	streamPage->lastService.clear();
 
 	if (!customServer) {

+ 1 - 0
UI/window-basic-auto-config.hpp

@@ -195,6 +195,7 @@ public slots:
 	void on_useStreamKey_clicked();
 	void ServiceChanged();
 	void UpdateKeyLink();
+	void UpdateMoreInfoLink();
 	void UpdateServerList();
 	void UpdateCompleted();
 };

+ 32 - 0
UI/window-basic-settings-stream.cpp

@@ -75,6 +75,8 @@ void OBSBasicSettings::InitStreamPage()
 		SLOT(UpdateKeyLink()));
 	connect(ui->customServer, SIGNAL(editingFinished(const QString &)),
 		this, SLOT(UpdateKeyLink()));
+	connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
+		SLOT(UpdateMoreInfoLink()));
 }
 
 void OBSBasicSettings::LoadStream1Settings()
@@ -138,6 +140,7 @@ void OBSBasicSettings::LoadStream1Settings()
 	obs_data_release(settings);
 
 	UpdateKeyLink();
+	UpdateMoreInfoLink();
 
 	bool streamActive = obs_frontend_streaming_active();
 	ui->streamPage->setEnabled(!streamActive);
@@ -212,6 +215,35 @@ void OBSBasicSettings::SaveStream1Settings()
 		main->auth->LoadUI();
 }
 
+void OBSBasicSettings::UpdateMoreInfoLink()
+{
+	if (IsCustomService()) {
+		ui->moreInfoButton->hide();
+		return;
+	}
+
+	QString serviceName = ui->service->currentText();
+	obs_properties_t *props = obs_get_service_properties("rtmp_common");
+	obs_property_t *services = obs_properties_get(props, "service");
+
+	OBSData settings = obs_data_create();
+	obs_data_release(settings);
+
+	obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName));
+	obs_property_modified(services, settings);
+
+	const char *more_info_link =
+		obs_data_get_string(settings, "more_info_link");
+
+	if (!more_info_link || (*more_info_link == '\0')) {
+		ui->moreInfoButton->hide();
+	} else {
+		ui->moreInfoButton->setTargetUrl(QUrl(more_info_link));
+		ui->moreInfoButton->show();
+	}
+	obs_properties_destroy(props);
+}
+
 void OBSBasicSettings::UpdateKeyLink()
 {
 	QString serviceName = ui->service->currentText();

+ 1 - 0
UI/window-basic-settings.hpp

@@ -239,6 +239,7 @@ private:
 private slots:
 	void UpdateServerList();
 	void UpdateKeyLink();
+	void UpdateMoreInfoLink();
 	void on_show_clicked();
 	void on_authPwShow_clicked();
 	void on_connectAccount_clicked();

+ 10 - 1
plugins/rtmp-services/rtmp-common.c

@@ -370,6 +370,15 @@ static void fill_servers(obs_property_t *servers_prop, json_t *service,
 	}
 }
 
+static void fill_more_info_link(json_t *service, obs_data_t *settings)
+{
+	const char *more_info_link;
+
+	more_info_link = get_string_val(service, "more_info_link");
+	if (more_info_link)
+		obs_data_set_string(settings, "more_info_link", more_info_link);
+}
+
 static inline json_t *find_service(json_t *root, const char *name,
 				   const char **p_new_name)
 {
@@ -432,7 +441,7 @@ static bool service_selected(obs_properties_t *props, obs_property_t *p,
 	}
 
 	fill_servers(obs_properties_get(props, "server"), service, name);
-
+	fill_more_info_link(service, settings);
 	return true;
 }