فهرست منبع

UI: Add about dialog

cg2121 7 سال پیش
والد
کامیت
36b0ef5b7e

+ 7 - 2
UI/CMakeLists.txt

@@ -151,6 +151,7 @@ set(obs_SOURCES
 	window-basic-adv-audio.cpp
 	window-basic-transform.cpp
 	window-basic-preview.cpp
+	window-basic-about.cpp
 	window-namedialog.cpp
 	window-log-reply.cpp
 	window-projector.cpp
@@ -194,6 +195,7 @@ set(obs_HEADERS
 	window-basic-auto-config.hpp
 	window-basic-main-outputs.hpp
 	window-basic-source-select.hpp
+	window-basic-about.hpp
 	window-license-agreement.hpp
 	window-basic-status-bar.hpp
 	window-basic-adv-audio.hpp
@@ -228,7 +230,8 @@ set(obs_HEADERS
 	source-label.hpp
 	remote-text.hpp
 	audio-encoders.hpp
-	qt-wrappers.hpp)
+	qt-wrappers.hpp
+	clickable-label.hpp)
 
 set(obs_UI
 	forms/NameDialog.ui
@@ -246,7 +249,8 @@ set(obs_UI
 	forms/OBSBasicSourceSelect.ui
 	forms/OBSBasicInteraction.ui
 	forms/OBSUpdate.ui
-	forms/OBSRemux.ui)
+	forms/OBSRemux.ui
+	forms/OBSAbout.ui)
 
 set(obs_QRC
 	forms/obs.qrc)
@@ -298,6 +302,7 @@ define_graphic_modules(obs)
 
 install_obs_core(obs)
 install_obs_data(obs data obs-studio)
+install_obs_data_file(obs ../AUTHORS obs-studio/authors)
 
 if (UNIX AND UNIX_STRUCTURE AND NOT APPLE)
 	install(FILES dist/obs.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications)

+ 21 - 0
UI/clickable-label.hpp

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <QLabel>
+#include <QMouseEvent>
+
+class ClickableLabel : public QLabel {
+    Q_OBJECT
+
+public:
+	inline ClickableLabel(QWidget *parent = 0) : QLabel(parent) {}
+
+signals:
+	void clicked();
+
+protected:
+	void mousePressEvent(QMouseEvent *event)
+	{
+		emit clicked();
+		event->accept();
+	}
+};

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

@@ -544,6 +544,7 @@ Basic.MainMenu.Help.CheckForUpdates="Check For Updates"
 Basic.MainMenu.Help.CrashLogs="Crash &Reports"
 Basic.MainMenu.Help.CrashLogs.ShowLogs="&Show Crash Reports"
 Basic.MainMenu.Help.CrashLogs.UploadLastLog="Upload &Last Crash Report"
+Basic.MainMenu.Help.About="&About"
 
 # basic mode settings dialog
 Basic.Settings.ProgramRestart="The program must be restarted for these settings to take effect."
@@ -857,3 +858,12 @@ CustomColor="Custom Color"
 
 # Global settings for the browser source
 BrowserSource.EnableHardwareAcceleration="Enable Browser Source Hardware Acceleration"
+
+# about dialog
+About="About"
+About.Info="OBS Studio is a free and open source video recording and live streaming software."
+About.Donate="Make a Donation"
+About.GetInvolved="Get Involved"
+About.Authors="Authors"
+About.License="License"
+About.Contribute="Want to contribute?"

+ 20 - 0
UI/data/themes/Acri.qss

@@ -860,3 +860,23 @@ FocusList::item {
 	background: transparent;
 	min-height: 26px;
 }
+
+/* About dialog */
+
+* [themeID="aboutName"] {
+	font-size: 36px;
+	font-weight: bold;
+}
+
+* [themeID="aboutVersion"] {
+	font-size: 16px;
+	margin-bottom: 20px;
+}
+
+* [themeID="aboutInfo"] {
+	margin-bottom: 20px;
+}
+
+* [themeID="aboutHLayout"] {
+	background-color: rgb(8, 8, 11);
+}

+ 20 - 0
UI/data/themes/Dark.qss

@@ -636,3 +636,23 @@ QLabel#errorLabel {
     color: rgb(0, 192, 0);
     font-weight: bold;
 }
+
+/* About dialog */
+
+* [themeID="aboutName"] {
+    font-size: 36px;
+    font-weight: bold;
+}
+
+* [themeID="aboutVersion"] {
+    font-size: 16px;
+    margin-bottom: 20px;
+}
+
+* [themeID="aboutInfo"] {
+    margin-bottom: 20px;
+}
+
+* [themeID="aboutHLayout"] {
+    background-color: rgb(31, 30, 31); /* veryDark */
+}

+ 20 - 0
UI/data/themes/Default.qss

@@ -115,3 +115,23 @@ QLabel#errorLabel {
     color: rgb(0, 128, 0);
     font-weight: bold;
 }
+
+/* About dialog */
+
+* [themeID="aboutName"] {
+    font-size: 36px;
+    font-weight: bold;
+}
+
+* [themeID="aboutVersion"] {
+    font-size: 16px;
+    margin-bottom: 20px;
+}
+
+* [themeID="aboutInfo"] {
+    margin-bottom: 20px;
+}
+
+* [themeID="aboutHLayout"] {
+	background-color: rgb(169, 169, 169);
+}

+ 20 - 0
UI/data/themes/Rachni.qss

@@ -1214,3 +1214,23 @@ QToolTip {
 	background-color: rgb(49, 54, 59); /* Blue-gray */
 	color: rgb(240, 98, 146); /* Pink (Secondary) */
 }
+
+/* About dialog */
+
+* [themeID="aboutName"] {
+	font-size: 36px;
+	font-weight: bold;
+}
+
+* [themeID="aboutVersion"] {
+	font-size: 16px;
+	margin-bottom: 20px;
+}
+
+* [themeID="aboutInfo"] {
+	margin-bottom: 20px;
+}
+
+* [themeID="aboutHLayout"] {
+	background-color: rgb(35, 38, 41); /* Dark Gray */
+}

+ 166 - 0
UI/forms/OBSAbout.ui

@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>OBSAbout</class>
+ <widget class="QDialog" name="OBSAbout">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>792</width>
+    <height>389</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>About</string>
+  </property>
+  <widget class="QLabel" name="icon">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>261</width>
+     <height>261</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string/>
+   </property>
+   <property name="pixmap">
+    <pixmap>:res/images/obs.png</pixmap>
+   </property>
+  </widget>
+  <widget class="QWidget" name="verticalLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>320</x>
+     <y>30</y>
+     <width>441</width>
+     <height>261</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <property name="spacing">
+     <number>0</number>
+    </property>
+    <item>
+     <widget class="QLabel" name="name">
+      <property name="text">
+       <string>OBS Studio</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="version">
+      <property name="text">
+       <string>Version</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="info">
+      <property name="text">
+       <string>About.Info</string>
+      </property>
+      <property name="wordWrap">
+       <bool>true</bool>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="contribute">
+      <property name="text">
+       <string>Contribute</string>
+      </property>
+      <property name="wordWrap">
+       <bool>true</bool>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="donate">
+      <property name="text">
+       <string>Donate</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="getInvolved">
+      <property name="text">
+       <string>Get Involved</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QTextBrowser" name="textBrowser"/>
+    </item>
+    <item>
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>40</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="horizontalLayoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>320</y>
+     <width>791</width>
+     <height>71</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <property name="spacing">
+     <number>0</number>
+    </property>
+    <item>
+     <widget class="ClickableLabel" name="about">
+      <property name="text">
+       <string>About</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignCenter</set>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="ClickableLabel" name="authors">
+      <property name="text">
+       <string>Authors</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignCenter</set>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="ClickableLabel" name="license">
+      <property name="text">
+       <string>License</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignCenter</set>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>ClickableLabel</class>
+   <extends>QLabel</extends>
+   <header>clickable-label.hpp</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 12 - 5
UI/forms/OBSBasic.ui

@@ -7,7 +7,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1079</width>
+    <width>1238</width>
     <height>730</height>
    </rect>
   </property>
@@ -105,8 +105,8 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>1079</width>
-     <height>21</height>
+     <width>1238</width>
+     <height>22</height>
     </rect>
    </property>
    <widget class="QMenu" name="menu_File">
@@ -152,6 +152,8 @@
     <addaction name="menuCrashLogs"/>
     <addaction name="separator"/>
     <addaction name="actionCheckForUpdates"/>
+    <addaction name="actionShowAbout"/>
+    <addaction name="separator"/>
    </widget>
    <widget class="QMenu" name="menuBasic_MainMenu_Edit">
     <property name="title">
@@ -642,7 +644,7 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>230</width>
+           <width>78</width>
            <height>16</height>
           </rect>
          </property>
@@ -696,7 +698,7 @@
            <x>0</x>
            <y>0</y>
            <width>16</width>
-           <height>230</height>
+           <height>28</height>
           </rect>
          </property>
          <property name="sizePolicy">
@@ -1683,6 +1685,11 @@
     <string>Basic.Stats</string>
    </property>
   </action>
+  <action name="actionShowAbout">
+   <property name="text">
+    <string>Basic.MainMenu.Help.About</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>

+ 120 - 0
UI/window-basic-about.cpp

@@ -0,0 +1,120 @@
+#include "window-basic-about.hpp"
+#include "window-basic-main.hpp"
+#include "qt-wrappers.hpp"
+#include <string>
+#include <util/util.hpp>
+#include <util/platform.h>
+#include <platform.hpp>
+
+OBSAbout::OBSAbout(QWidget *parent)
+	: QDialog(parent),
+	  ui(new Ui::OBSAbout)
+{
+	ui->setupUi(this);
+
+	QString bitness;
+
+	if(sizeof(void*) == 4)
+		bitness = " (32 bit)";
+	else if(sizeof(void*) == 8)
+		bitness = " (64 bit)";
+
+	ui->version->setText(
+			QString::number(LIBOBS_API_MAJOR_VER) + "." +
+			QString::number(LIBOBS_API_MINOR_VER) + "." +
+			QString::number(LIBOBS_API_PATCH_VER) +
+			bitness);
+
+	ui->contribute->setText(QTStr("About.Contribute"));
+	ui->donate->setText("<a href='https://obsproject.com/donate'>" +
+			QTStr("About.Donate") + "</a>");
+	ui->donate->setTextInteractionFlags(Qt::TextBrowserInteraction);
+	ui->donate->setOpenExternalLinks(true);
+
+	ui->getInvolved->setText("<a href='https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.rst'>" +
+			QTStr("About.GetInvolved") + "</a>");
+	ui->getInvolved->setTextInteractionFlags(Qt::TextBrowserInteraction);
+	ui->getInvolved->setOpenExternalLinks(true);
+
+	ui->about->setText("<a href='#'>" + QTStr("About") + "</a>");
+	ui->authors->setText("<a href='#'>" + QTStr("About.Authors") + "</a>");
+	ui->license->setText("<a href='#'>" + QTStr("About.License") + "</a>");
+
+	ui->textBrowser->hide();
+
+	ui->name->setProperty("themeID", "aboutName");
+	ui->version->setProperty("themeID", "aboutVersion");
+	ui->about->setProperty("themeID", "aboutHLayout");
+	ui->authors->setProperty("themeID", "aboutHLayout");
+	ui->license->setProperty("themeID", "aboutHLayout");
+	ui->info->setProperty("themeID", "aboutInfo");
+
+	connect(ui->about, SIGNAL(clicked()), this, SLOT(ShowAbout()));
+	connect(ui->authors, SIGNAL(clicked()), this, SLOT(ShowAuthors()));
+	connect(ui->license, SIGNAL(clicked()), this, SLOT(ShowLicense()));
+}
+
+void OBSAbout::ShowAbout()
+{
+	ui->textBrowser->hide();
+	ui->info->show();
+	ui->contribute->show();
+	ui->donate->show();
+	ui->getInvolved->show();
+}
+
+void OBSAbout::ShowAuthors()
+{
+	std::string path;
+	QString error = "Error! File could not be read.\n\n \
+		Go to: https://github.com/obsproject/obs-studio/blob/master/AUTHORS";
+
+	if (!GetDataFilePath("authors/AUTHORS", path)) {
+		ui->textBrowser->setPlainText(error);
+		return;
+	}
+
+	ui->textBrowser->setPlainText(QString::fromStdString(path));
+
+	BPtr<char> text = os_quick_read_utf8_file(path.c_str());
+
+	if (!text || !*text) {
+		ui->textBrowser->setPlainText(error);
+		return;
+	}
+
+	ui->textBrowser->setPlainText(QT_UTF8(text));
+
+	ui->info->hide();
+	ui->contribute->hide();
+	ui->donate->hide();
+	ui->getInvolved->hide();
+	ui->textBrowser->show();
+}
+
+void OBSAbout::ShowLicense()
+{
+	std::string path;
+	QString error = "Error! File could not be read.\n\n \
+		Go to: https://github.com/obsproject/obs-studio/blob/master/COPYING";
+
+	if (!GetDataFilePath("license/gplv2.txt", path)) {
+		ui->textBrowser->setPlainText(error);
+		return;
+	}
+
+	BPtr<char> text = os_quick_read_utf8_file(path.c_str());
+
+	if (!text || !*text) {
+		ui->textBrowser->setPlainText(error);
+		return;
+	}
+
+	ui->textBrowser->setPlainText(QT_UTF8(text));
+
+	ui->info->hide();
+	ui->contribute->hide();
+	ui->donate->hide();
+	ui->getInvolved->hide();
+	ui->textBrowser->show();
+}

+ 21 - 0
UI/window-basic-about.hpp

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <memory>
+#include <QDialog>
+
+#include "ui_OBSAbout.h"
+
+class OBSAbout : public QDialog {
+	Q_OBJECT
+
+public:
+	explicit OBSAbout(QWidget *parent = 0);
+
+private:
+	std::unique_ptr<Ui::OBSAbout> ui;
+
+private slots:
+	void ShowAbout();
+	void ShowAuthors();
+	void ShowLicense();
+};

+ 14 - 0
UI/window-basic-main.cpp

@@ -2119,6 +2119,9 @@ OBSBasic::~OBSBasic()
 	if (advAudioWindow)
 		delete advAudioWindow;
 
+	if (about)
+		delete about;
+
 	obs_display_remove_draw_callback(ui->preview->GetDisplay(),
 			OBSBasic::RenderMain, this);
 
@@ -6690,6 +6693,17 @@ void OBSBasic::on_stats_triggered()
 	stats = statsDlg;
 }
 
+void OBSBasic::on_actionShowAbout_triggered()
+{
+	if (about)
+		about->close();
+
+	about = new OBSAbout(this);
+	about->show();
+
+	about->setAttribute(Qt::WA_DeleteOnClose, true);
+}
+
 ColorSelect::ColorSelect(QWidget *parent)
 	: QWidget(parent),
 	  ui(new Ui::ColorSelect)

+ 4 - 0
UI/window-basic-main.hpp

@@ -30,6 +30,7 @@
 #include "window-basic-adv-audio.hpp"
 #include "window-basic-filters.hpp"
 #include "window-projector.hpp"
+#include "window-basic-about.hpp"
 
 #include <obs-frontend-internal.hpp>
 
@@ -147,6 +148,7 @@ private:
 	QPointer<OBSBasicTransform> transformWindow;
 	QPointer<OBSBasicAdvAudio> advAudioWindow;
 	QPointer<OBSBasicFilters> filters;
+	QPointer<OBSAbout> about;
 
 	QPointer<QTimer>    cpuUsageTimer;
 	os_cpu_usage_info_t *cpuUsageInfo = nullptr;
@@ -477,6 +479,8 @@ private slots:
 
 	SourceTreeItem *GetItemWidgetFromSceneItem(obs_sceneitem_t *sceneItem);
 
+	void on_actionShowAbout_triggered();
+
 private:
 	/* OBS Callbacks */
 	static void SceneReordered(void *data, calldata_t *params);