Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/duckstation-qt/aboutdialog.cpp
4242 views
1
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#include "aboutdialog.h"
5
#include "qtutils.h"
6
7
#include "core/settings.h"
8
9
#include "common/file_system.h"
10
#include "common/path.h"
11
12
#include "scmversion/scmversion.h"
13
14
#include <QtCore/QString>
15
#include <QtWidgets/QDialog>
16
#include <QtWidgets/QDialogButtonBox>
17
#include <QtWidgets/QPushButton>
18
#include <QtWidgets/QTextBrowser>
19
20
#include "moc_aboutdialog.cpp"
21
22
AboutDialog::AboutDialog(QWidget* parent /* = nullptr */) : QDialog(parent)
23
{
24
m_ui.setupUi(this);
25
26
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
27
setFixedSize(geometry().width(), geometry().height());
28
29
m_ui.scmversion->setTextInteractionFlags(Qt::TextSelectableByMouse);
30
m_ui.scmversion->setText(
31
tr("%1 (%2)").arg(QLatin1StringView(g_scm_tag_str)).arg(QLatin1StringView(g_scm_branch_str)));
32
33
m_ui.description->setTextInteractionFlags(Qt::TextBrowserInteraction);
34
m_ui.description->setOpenExternalLinks(true);
35
m_ui.description->setText(QStringLiteral(R"(
36
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
37
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
38
p, li { white-space: pre-wrap; }
39
</style></head><body style=" font-size:10pt; font-weight:400; font-style:normal;">
40
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%1</p>
41
<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">%2</span>:</p>
42
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Connor McLaughlin &lt;[email protected]&gt;</p>
43
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> and other <a href="https://github.com/stenzek/duckstation/blob/master/CONTRIBUTORS.md">contributors</a></p>
44
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%3 <a href="https://icons8.com/icon/74847/platforms.undefined.short-title"><span style=" text-decoration: underline; color:#0057ae;">icons8</span></a></p>
45
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/stenzek/duckstation/blob/master/LICENSE"><span style=" text-decoration: underline; color:#0057ae;">%4</span></a> | <a href="https://github.com/stenzek/duckstation"><span style=" text-decoration: underline; color:#0057ae;">GitHub</span></a> | <a href="https://www.duckstation.org/discord.html"><span style=" text-decoration: underline; color:#0057ae;">Discord</span></a></p></body></html>
46
)")
47
.arg(tr("DuckStation is a free simulator/emulator of the Sony PlayStation<span "
48
"style=\"vertical-align:super;\">TM</span> console, focusing on playability, "
49
"speed, and long-term maintainability."))
50
.arg(tr("Authors"))
51
.arg(tr("Icon by"))
52
.arg(tr("License")));
53
}
54
55
AboutDialog::~AboutDialog() = default;
56
57
void AboutDialog::showThirdPartyNotices(QWidget* parent)
58
{
59
QDialog dialog(parent);
60
dialog.setMinimumSize(700, 400);
61
dialog.setWindowTitle(tr("DuckStation Third-Party Notices"));
62
63
QIcon icon;
64
icon.addFile(QString::fromUtf8(":/icons/duck.png"), QSize(), QIcon::Normal, QIcon::Off);
65
dialog.setWindowIcon(icon);
66
67
QVBoxLayout* layout = new QVBoxLayout(&dialog);
68
69
QTextBrowser* tb = new QTextBrowser(&dialog);
70
tb->setAcceptRichText(true);
71
tb->setReadOnly(true);
72
tb->setOpenExternalLinks(true);
73
if (std::optional<std::string> notice =
74
FileSystem::ReadFileToString(Path::Combine(EmuFolders::Resources, "thirdparty.html").c_str());
75
notice.has_value())
76
{
77
tb->setText(QString::fromStdString(notice.value()));
78
}
79
else
80
{
81
tb->setText(tr("Missing thirdparty.html file. You should request it from where-ever you obtained DuckStation."));
82
}
83
layout->addWidget(tb, 1);
84
85
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Close, &dialog);
86
connect(bb, &QDialogButtonBox::rejected, &dialog, &QDialog::accept);
87
layout->addWidget(bb, 0);
88
89
dialog.exec();
90
}
91
92