Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/duckstation-qt/aboutdialog.cpp
4802 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;"> <a href="https://github.com/stenzek/duckstation/blob/master/CONTRIBUTORS.md"><span style=" text-decoration: none;">%3</span></a></p>
44
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%4 <a href="https://icons8.com/icon/74847/platforms.undefined.short-title"><span style=" text-decoration: none;">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: none;">%5</span></a> | <a href="https://github.com/stenzek/duckstation"><span style=" text-decoration: none;">GitHub</span></a> | <a href="https://www.duckstation.org/discord.html"><span style=" text-decoration: none;">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("and other contributors"))
52
.arg(tr("Icon by"))
53
.arg(tr("License")));
54
}
55
56
AboutDialog::~AboutDialog() = default;
57
58
void AboutDialog::showThirdPartyNotices(QWidget* parent)
59
{
60
QDialog dialog(parent);
61
dialog.setMinimumSize(700, 400);
62
dialog.setWindowTitle(tr("DuckStation Third-Party Notices"));
63
64
QIcon icon;
65
icon.addFile(QString::fromUtf8(":/icons/duck.png"), QSize(), QIcon::Normal, QIcon::Off);
66
dialog.setWindowIcon(icon);
67
68
QVBoxLayout* layout = new QVBoxLayout(&dialog);
69
70
QTextBrowser* tb = new QTextBrowser(&dialog);
71
tb->setAcceptRichText(true);
72
tb->setReadOnly(true);
73
tb->setOpenExternalLinks(true);
74
if (std::optional<std::string> notice =
75
FileSystem::ReadFileToString(Path::Combine(EmuFolders::Resources, "thirdparty.html").c_str());
76
notice.has_value())
77
{
78
tb->setText(QString::fromStdString(notice.value()));
79
}
80
else
81
{
82
tb->setText(tr("Missing thirdparty.html file. You should request it from where-ever you obtained DuckStation."));
83
}
84
layout->addWidget(tb, 1);
85
86
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Close, &dialog);
87
connect(bb, &QDialogButtonBox::rejected, &dialog, &QDialog::accept);
88
layout->addWidget(bb, 0);
89
90
dialog.exec();
91
}
92
93