Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/duckstation-qt/aboutdialog.cpp
7468 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 "qthost.h"
6
#include "qtutils.h"
7
8
#include "core/settings.h"
9
10
#include "common/file_system.h"
11
#include "common/path.h"
12
13
#include "scmversion/scmversion.h"
14
15
#include <QtCore/QString>
16
#include <QtWidgets/QDialog>
17
#include <QtWidgets/QDialogButtonBox>
18
#include <QtWidgets/QPushButton>
19
#include <QtWidgets/QTextBrowser>
20
21
#include "moc_aboutdialog.cpp"
22
23
AboutDialog::AboutDialog(QWidget* parent /* = nullptr */) : QDialog(parent)
24
{
25
m_ui.setupUi(this);
26
m_ui.icon->setPixmap(QtHost::GetAppLogo());
27
28
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
29
setFixedSize(geometry().width(), geometry().height());
30
31
QFont title_font(m_ui.title->font());
32
title_font.setPixelSize(20);
33
m_ui.title->setFont(title_font);
34
35
m_ui.scmversion->setText(
36
tr("%1 (%2)").arg(QLatin1StringView(g_scm_tag_str)).arg(QLatin1StringView(g_scm_branch_str)));
37
38
m_ui.description->setText(QStringLiteral(R"(
39
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
40
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
41
p, li { white-space: pre-wrap; }
42
</style></head><body style=" font-size:10pt; font-weight:400; font-style:normal;">
43
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%1</p>
44
<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>
45
<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>
46
<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>
47
<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>
48
<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>
49
)")
50
.arg(tr("DuckStation is a free simulator/emulator of the Sony PlayStation<span "
51
"style=\"vertical-align:super;\">TM</span> console, focusing on playability, "
52
"speed, and long-term maintainability."))
53
.arg(tr("Authors"))
54
.arg(tr("and other contributors"))
55
.arg(tr("Icon by"))
56
.arg(tr("License")));
57
58
connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
59
}
60
61
AboutDialog::~AboutDialog() = default;
62
63
void AboutDialog::openThirdPartyNotices(QWidget* parent)
64
{
65
QDialog* const dialog = new QDialog(parent);
66
dialog->setAttribute(Qt::WA_DeleteOnClose);
67
dialog->setMinimumSize(700, 400);
68
dialog->setWindowTitle(tr("DuckStation Third-Party Notices"));
69
70
QVBoxLayout* const layout = new QVBoxLayout(dialog);
71
QTextBrowser* const tb = new QTextBrowser(dialog);
72
tb->setAcceptRichText(true);
73
tb->setReadOnly(true);
74
tb->setOpenExternalLinks(true);
75
if (std::optional<std::string> notice =
76
FileSystem::ReadFileToString(Path::Combine(EmuFolders::Resources, "thirdparty.html").c_str());
77
notice.has_value())
78
{
79
tb->setText(QString::fromStdString(notice.value()));
80
}
81
else
82
{
83
tb->setText(tr("Missing thirdparty.html file. You should request it from where-ever you obtained DuckStation."));
84
}
85
layout->addWidget(tb, 1);
86
87
QDialogButtonBox* const bb = new QDialogButtonBox(QDialogButtonBox::Ok, dialog);
88
connect(bb, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
89
layout->addWidget(bb, 0);
90
91
dialog->open();
92
}
93
94