Qt: Add third-party license statements

This commit is contained in:
Stenzek 2024-01-07 19:30:55 +10:00 committed by Connor McLaughlin
parent 34a7e00413
commit 476cb2db34
3 changed files with 2647 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,17 @@
#include "AboutDialog.h"
#include "QtHost.h"
#include "QtUtils.h"
#include "common/FileSystem.h"
#include "common/Path.h"
#include <QtCore/QFile>
#include <QtCore/QString>
#include <QtGui/QDesktopServices>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QTextBrowser>
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent)
@ -21,9 +30,8 @@ AboutDialog::AboutDialog(QWidget* parent)
m_ui.scmversion->setText(QtHost::GetAppNameAndVersion());
m_ui.links->setTextInteractionFlags(Qt::TextBrowserInteraction);
m_ui.links->setOpenExternalLinks(true);
m_ui.links->setText(QStringLiteral(
R"(<a href="%1">%2</a> | <a href="%3">%4</a> | <a href="%5">%6</a> | <a href="%7">%8</a>)")
R"(<a href="%1">%2</a> | <a href="%3">%4</a> | <a href="%5">%6</a> | <a href="%7">%8</a> | <a href="%9">%10</a>)")
.arg(getWebsiteUrl())
.arg(tr("Website"))
.arg(getSupportForumsUrl())
@ -31,8 +39,11 @@ AboutDialog::AboutDialog(QWidget* parent)
.arg(getGitHubRepositoryUrl())
.arg(tr("GitHub Repository"))
.arg(getLicenseUrl())
.arg(tr("License")));
.arg(tr("License"))
.arg(getThirdPartyLicensesUrl())
.arg(tr("Third-Party Licenses")));
connect(m_ui.links, &QLabel::linkActivated, this, &AboutDialog::linksLinkActivated);
connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
}
@ -55,10 +66,64 @@ QString AboutDialog::getGitHubRepositoryUrl()
QString AboutDialog::getLicenseUrl()
{
return QString::fromUtf8(PCSX2_LICENSE_URL);
return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot,
"docs" FS_OSPATH_SEPARATOR_STR "GPL.html")))
.toString();
}
QString AboutDialog::getThirdPartyLicensesUrl()
{
return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot,
"docs" FS_OSPATH_SEPARATOR_STR "ThirdPartyLicenses.html")))
.toString();
}
QString AboutDialog::getDiscordServerUrl()
{
return QString::fromUtf8(PCSX2_DISCORD_URL);
}
void AboutDialog::linksLinkActivated(const QString& link)
{
const QUrl url(link);
if (!url.isValid())
return;
if (!url.isLocalFile())
{
QDesktopServices::openUrl(url);
return;
}
showHTMLDialog(this, tr("View Document"), url.toLocalFile());
}
void AboutDialog::showHTMLDialog(QWidget* parent, const QString& title, const QString& path)
{
QDialog dialog(parent);
dialog.setMinimumSize(700, 400);
dialog.setWindowTitle(title);
dialog.setWindowIcon(QtHost::GetAppIcon());
QVBoxLayout* layout = new QVBoxLayout(&dialog);
QTextBrowser* tb = new QTextBrowser(&dialog);
tb->setAcceptRichText(true);
tb->setReadOnly(true);
tb->setOpenExternalLinks(true);
QFile file(path);
file.open(QIODevice::ReadOnly);
if (const QByteArray data = file.readAll(); !data.isEmpty())
tb->setText(QString::fromUtf8(data));
else
tb->setText(tr("File not found: %1").arg(path));
layout->addWidget(tb, 1);
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Close, &dialog);
connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked, &dialog, &QDialog::done);
layout->addWidget(bb, 0);
dialog.exec();
}

View File

@ -18,8 +18,14 @@ public:
static QString getSupportForumsUrl();
static QString getGitHubRepositoryUrl();
static QString getLicenseUrl();
static QString getThirdPartyLicensesUrl();
static QString getDiscordServerUrl();
static void showHTMLDialog(QWidget* parent, const QString& title, const QString& url);
private Q_SLOTS:
void linksLinkActivated(const QString& link);
private:
Ui::AboutDialog m_ui;
};