2023-12-22 11:57:49 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2024-01-07 09:36:40 +00:00
|
|
|
#include "pcsx2/SupportURLs.h"
|
2022-05-15 08:20:21 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
#include "AboutDialog.h"
|
2022-05-11 08:24:56 +00:00
|
|
|
#include "QtHost.h"
|
2021-12-13 12:12:54 +00:00
|
|
|
#include "QtUtils.h"
|
2024-01-07 09:30:55 +00:00
|
|
|
|
|
|
|
#include "common/FileSystem.h"
|
|
|
|
#include "common/Path.h"
|
2024-01-08 10:34:35 +00:00
|
|
|
#include "common/SmallString.h"
|
2024-01-07 09:30:55 +00:00
|
|
|
|
|
|
|
#include <QtCore/QFile>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtCore/QString>
|
2024-01-07 09:30:55 +00:00
|
|
|
#include <QtGui/QDesktopServices>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtWidgets/QDialog>
|
2024-01-07 09:30:55 +00:00
|
|
|
#include <QtWidgets/QDialogButtonBox>
|
|
|
|
#include <QtWidgets/QPushButton>
|
|
|
|
#include <QtWidgets/QTextBrowser>
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2024-01-08 10:34:35 +00:00
|
|
|
static QString GetDocFileUrl(std::string_view name)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
// Windows uses the docs directory in bin.
|
|
|
|
const std::string path = Path::Combine(EmuFolders::AppRoot,
|
|
|
|
TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
|
|
|
|
#else
|
|
|
|
// Linux/Mac has this in the Resources directory.
|
|
|
|
const std::string path = Path::Combine(EmuFolders::Resources,
|
|
|
|
TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name));
|
|
|
|
#endif
|
|
|
|
return QUrl::fromLocalFile(QString::fromStdString(path)).toString();
|
|
|
|
}
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
AboutDialog::AboutDialog(QWidget* parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
setFixedSize(geometry().width(), geometry().height());
|
|
|
|
|
|
|
|
m_ui.scmversion->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
2022-05-11 08:24:56 +00:00
|
|
|
m_ui.scmversion->setText(QtHost::GetAppNameAndVersion());
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
m_ui.links->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
|
|
|
m_ui.links->setText(QStringLiteral(
|
2024-01-07 09:30:55 +00:00
|
|
|
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>)")
|
2021-12-13 12:12:54 +00:00
|
|
|
.arg(getWebsiteUrl())
|
|
|
|
.arg(tr("Website"))
|
|
|
|
.arg(getSupportForumsUrl())
|
|
|
|
.arg(tr("Support Forums"))
|
|
|
|
.arg(getGitHubRepositoryUrl())
|
|
|
|
.arg(tr("GitHub Repository"))
|
|
|
|
.arg(getLicenseUrl())
|
2024-01-07 09:30:55 +00:00
|
|
|
.arg(tr("License"))
|
|
|
|
.arg(getThirdPartyLicensesUrl())
|
|
|
|
.arg(tr("Third-Party Licenses")));
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2024-01-07 09:30:55 +00:00
|
|
|
connect(m_ui.links, &QLabel::linkActivated, this, &AboutDialog::linksLinkActivated);
|
2021-12-13 12:12:54 +00:00
|
|
|
connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
|
|
|
|
}
|
|
|
|
|
|
|
|
AboutDialog::~AboutDialog() = default;
|
|
|
|
|
|
|
|
QString AboutDialog::getWebsiteUrl()
|
|
|
|
{
|
2022-05-15 08:20:21 +00:00
|
|
|
return QString::fromUtf8(PCSX2_WEBSITE_URL);
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AboutDialog::getSupportForumsUrl()
|
|
|
|
{
|
2022-05-15 08:20:21 +00:00
|
|
|
return QString::fromUtf8(PCSX2_FORUMS_URL);
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AboutDialog::getGitHubRepositoryUrl()
|
|
|
|
{
|
2022-05-15 08:20:21 +00:00
|
|
|
return QString::fromUtf8(PCSX2_GITHUB_URL);
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AboutDialog::getLicenseUrl()
|
|
|
|
{
|
2024-01-08 10:34:35 +00:00
|
|
|
return GetDocFileUrl("GPL.html");
|
2024-01-07 09:30:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AboutDialog::getThirdPartyLicensesUrl()
|
|
|
|
{
|
2024-01-08 10:34:35 +00:00
|
|
|
return GetDocFileUrl("ThirdPartyLicenses.html");
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AboutDialog::getDiscordServerUrl()
|
|
|
|
{
|
2022-05-15 08:20:21 +00:00
|
|
|
return QString::fromUtf8(PCSX2_DISCORD_URL);
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
2024-01-07 09:30:55 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|