aboutdialog.cpp (4488B)
1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR 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 AboutDialog::AboutDialog(QWidget* parent /* = nullptr */) : QDialog(parent) 21 { 22 m_ui.setupUi(this); 23 24 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); 25 setFixedSize(geometry().width(), geometry().height()); 26 27 m_ui.scmversion->setTextInteractionFlags(Qt::TextSelectableByMouse); 28 m_ui.scmversion->setText( 29 tr("%1 (%2)").arg(QLatin1StringView(g_scm_tag_str)).arg(QLatin1StringView(g_scm_branch_str))); 30 31 m_ui.description->setTextInteractionFlags(Qt::TextBrowserInteraction); 32 m_ui.description->setOpenExternalLinks(true); 33 m_ui.description->setText(QStringLiteral(R"( 34 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 35 <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 36 p, li { white-space: pre-wrap; } 37 </style></head><body style=" font-size:10pt; font-weight:400; font-style:normal;"> 38 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%1</p> 39 <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> 40 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Connor McLaughlin <stenzek@gmail.com></p> 41 <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> 42 <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> 43 <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://discord.gg/Buktv3t"><span style=" text-decoration: underline; color:#0057ae;">Discord</span></a></p></body></html> 44 )") 45 .arg(tr("DuckStation is a free and open-source simulator/emulator of the Sony " 46 "PlayStation<span style=\"vertical-align:super;\">TM</span> console, focusing on " 47 "playability, speed, and long-term maintainability.")) 48 .arg(tr("Authors")) 49 .arg(tr("Icon by")) 50 .arg(tr("License"))); 51 } 52 53 AboutDialog::~AboutDialog() = default; 54 55 void AboutDialog::showThirdPartyNotices(QWidget* parent) 56 { 57 QDialog dialog(parent); 58 dialog.setMinimumSize(700, 400); 59 dialog.setWindowTitle(tr("DuckStation Third-Party Notices")); 60 61 QIcon icon; 62 icon.addFile(QString::fromUtf8(":/icons/duck.png"), QSize(), QIcon::Normal, QIcon::Off); 63 dialog.setWindowIcon(icon); 64 65 QVBoxLayout* layout = new QVBoxLayout(&dialog); 66 67 QTextBrowser* tb = new QTextBrowser(&dialog); 68 tb->setAcceptRichText(true); 69 tb->setReadOnly(true); 70 tb->setOpenExternalLinks(true); 71 if (std::optional<std::string> notice = 72 FileSystem::ReadFileToString(Path::Combine(EmuFolders::Resources, "thirdparty.html").c_str()); 73 notice.has_value()) 74 { 75 tb->setText(QString::fromStdString(notice.value())); 76 } 77 else 78 { 79 tb->setText(tr("Missing thirdparty.html file. You should request it from where-ever you obtained DuckStation.")); 80 } 81 layout->addWidget(tb, 1); 82 83 QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Close, &dialog); 84 connect(bb->button(QDialogButtonBox::Close), &QPushButton::clicked, &dialog, &QDialog::done); 85 layout->addWidget(bb, 0); 86 87 dialog.exec(); 88 }