Skip to content

Commit

Permalink
Qt: Add third-party license statements
Browse files Browse the repository at this point in the history
stenzek committed Jan 7, 2024
1 parent 34a7e00 commit 476cb2d
Showing 3 changed files with 2,647 additions and 4 deletions.
2,572 changes: 2,572 additions & 0 deletions bin/docs/ThirdPartyLicenses.html

Large diffs are not rendered by default.

73 changes: 69 additions & 4 deletions pcsx2-qt/AboutDialog.cpp
Original file line number Diff line number Diff line change
@@ -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,18 +30,20 @@ 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())
.arg(tr("Support Forums"))
.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();
}
6 changes: 6 additions & 0 deletions pcsx2-qt/AboutDialog.h
Original file line number Diff line number Diff line change
@@ -18,8 +18,14 @@ class AboutDialog final : public QDialog
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;
};

0 comments on commit 476cb2d

Please sign in to comment.