UI: Add Patreon contributors to About dialog

master
jp9000 2019-05-05 20:00:06 -07:00
parent ce3abe52bf
commit acc8419295
5 changed files with 263 additions and 173 deletions

View File

@ -1,173 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OBSAbout</class>
<widget class="QDialog" name="OBSAbout">
<widget class="QWidget" name="OBSAbout">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>792</width>
<height>389</height>
<width>840</width>
<height>519</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>256</width>
<height>256</height>
</rect>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>256</height>
</size>
<property name="topMargin">
<number>0</number>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>256</height>
</size>
<property name="rightMargin">
<number>0</number>
</property>
<property name="text">
<string/>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="pixmap">
<pixmap>:res/images/obs.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</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>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>30</number>
</property>
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="icon">
<property name="minimumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:res/images/obs.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="name">
<property name="text">
<string notr="true">OBS Studio</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="version">
<property name="text">
<string notr="true">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 notr="true">Contribute</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="donate">
<property name="text">
<string notr="true">Donate</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="getInvolved">
<property name="text">
<string notr="true">Get Involved</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="version">
<property name="text">
<string>Version</string>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="info">
<property name="text">
<string>About.Info</string>
<property name="topMargin">
<number>0</number>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="rightMargin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="contribute">
<property name="text">
<string>Contribute</string>
<property name="bottomMargin">
<number>0</number>
</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>
<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>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>

View File

@ -1,9 +1,14 @@
#include "window-basic-about.hpp"
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "remote-text.hpp"
#include <util/util.hpp>
#include <util/platform.h>
#include <platform.hpp>
#include <json11.hpp>
#include <sstream>
using namespace json11;
OBSAbout::OBSAbout(QWidget *parent)
: QDialog(parent),
@ -11,8 +16,6 @@ OBSAbout::OBSAbout(QWidget *parent)
{
ui->setupUi(this);
setFixedSize(size());
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QString bitness;
@ -34,12 +37,12 @@ OBSAbout::OBSAbout(QWidget *parent)
ui->version->setText(ver + bitness);
ui->contribute->setText(QTStr("About.Contribute"));
ui->donate->setText("<a href='https://obsproject.com/donate'>" +
ui->donate->setText("&nbsp;&nbsp;<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'>" +
ui->getInvolved->setText("&nbsp;&nbsp;<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);
@ -48,8 +51,6 @@ OBSAbout::OBSAbout(QWidget *parent)
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");
@ -60,15 +61,65 @@ OBSAbout::OBSAbout(QWidget *parent)
connect(ui->about, SIGNAL(clicked()), this, SLOT(ShowAbout()));
connect(ui->authors, SIGNAL(clicked()), this, SLOT(ShowAuthors()));
connect(ui->license, SIGNAL(clicked()), this, SLOT(ShowLicense()));
QPointer<OBSAbout> about(this);
OBSBasic *main = OBSBasic::Get();
if (main->patronJson.empty() && !main->patronJsonThread) {
RemoteTextThread *thread = new RemoteTextThread(
"https://obsproject.com/patreon/about-box.json",
"application/json");
QObject::connect(thread, &RemoteTextThread::Result,
main, &OBSBasic::UpdatePatronJson);
QObject::connect(thread, SIGNAL(Result(const QString &, const QString &)),
this, SLOT(ShowAbout()));
main->patronJsonThread.reset(thread);
thread->start();
} else {
ShowAbout();
}
}
void OBSAbout::ShowAbout()
{
ui->textBrowser->hide();
ui->info->show();
ui->contribute->show();
ui->donate->show();
ui->getInvolved->show();
OBSBasic *main = OBSBasic::Get();
if (main->patronJson.empty())
return;
std::string error;
Json json = Json::parse(main->patronJson, error);
const Json::array &patrons = json.array_items();
std::stringstream text;
text << "<h1>Top Patreon contributors:</h1>";
text << "<p style=\"font-size:16px;\">";
bool first = true;
bool top = true;
for (const Json &patron : patrons) {
std::string name = patron["name"].string_value();
std::string link = patron["link"].string_value();
int amount = patron["amount"].int_value();
if (top && amount < 10000) {
text << "</p>";
top = false;
} else if (!first) {
text << "<br/>";
}
if (!link.empty())
text << "<a href=\"" << link << "\">";
text << name;
if (!link.empty())
text << "</a>";
if (first)
first = false;
}
ui->textBrowser->setHtml(QT_UTF8(text.str().c_str()));
}
void OBSAbout::ShowAuthors()
@ -92,12 +143,6 @@ void OBSAbout::ShowAuthors()
}
ui->textBrowser->setPlainText(QT_UTF8(text));
ui->info->hide();
ui->contribute->hide();
ui->donate->hide();
ui->getInvolved->hide();
ui->textBrowser->show();
}
void OBSAbout::ShowLicense()
@ -119,10 +164,4 @@ void OBSAbout::ShowLicense()
}
ui->textBrowser->setPlainText(QT_UTF8(text));
ui->info->hide();
ui->contribute->hide();
ui->donate->hide();
ui->getInvolved->hide();
ui->textBrowser->show();
}

View File

@ -11,7 +11,6 @@ class OBSAbout : public QDialog {
public:
explicit OBSAbout(QWidget *parent = 0);
private:
std::unique_ptr<Ui::OBSAbout> ui;
private slots:

View File

@ -7312,3 +7312,11 @@ bool SceneRenameDelegate::eventFilter(QObject *editor, QEvent *event)
return QStyledItemDelegate::eventFilter(editor, event);
}
void OBSBasic::UpdatePatronJson(const QString &text, const QString &error)
{
if (!error.isEmpty())
return;
patronJson = QT_TO_UTF8(text);
}

View File

@ -114,6 +114,7 @@ private:
class OBSBasic : public OBSMainWindow {
Q_OBJECT
friend class OBSAbout;
friend class OBSBasicPreview;
friend class OBSBasicStatusBar;
friend class OBSBasicSourceSelect;
@ -234,6 +235,9 @@ private:
QPointer<QVBoxLayout> programLayout;
QPointer<QLabel> programLabel;
QScopedPointer<QThread> patronJsonThread;
std::string patronJson;
void UpdateMultiviewProjectorMenu();
void DrawBackdrop(float cx, float cy);
@ -463,6 +467,8 @@ public slots:
bool create_new,
const QString &name = QString());
void UpdatePatronJson(const QString &text, const QString &error);
private slots:
void AddSceneItem(OBSSceneItem item);
void AddScene(OBSSource source);