src/platform/qt/AboutScreen.cpp (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "AboutScreen.h"
7
8#include <mgba/core/version.h>
9
10#include <QFile>
11#include <QPixmap>
12
13using namespace QGBA;
14
15AboutScreen::AboutScreen(QWidget* parent)
16 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
17{
18 m_ui.setupUi(this);
19
20 QPixmap logo(":/res/mgba-1024.png");
21 logo = logo.scaled(m_ui.logo->minimumSize() * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
22 logo.setDevicePixelRatio(devicePixelRatio());
23 m_ui.logo->setPixmap(logo);
24
25 QLatin1String tree(gitBranch);
26 if (tree == QLatin1String("(unknown)")) {
27 tree = QLatin1String(projectVersion);
28 }
29
30 QFile patronFile(":/res/patrons.txt");
31 QStringList patronList;
32 patronFile.open(QIODevice::ReadOnly | QIODevice::Text);
33 while (true) {
34 QByteArray line = patronFile.readLine();
35 if (line.isEmpty()) {
36 break;
37 }
38 patronList.append(QString::fromUtf8(line).trimmed());
39 }
40
41 m_ui.projectName->setText(QLatin1String(projectName));
42 m_ui.projectVersion->setText(QLatin1String(projectVersion));
43
44 {
45 QString gitInfo = m_ui.gitInfo->text();
46 gitInfo.replace("{gitBranch}", QLatin1String(gitBranch));
47 gitInfo.replace("{gitCommit}", QLatin1String(gitCommit));
48 m_ui.gitInfo->setText(gitInfo);
49 }
50
51 {
52 QString description = m_ui.description->text();
53 description.replace("{projectName}", QLatin1String(projectName));
54 m_ui.description->setText(description);
55 }
56
57 {
58 QString extraLinks = m_ui.extraLinks->text();
59 extraLinks.replace("{gitBranch}", tree);
60 m_ui.extraLinks->setText(extraLinks);
61 }
62
63 {
64 QString patronsHeader = m_ui.patronsHeader->text();
65 patronsHeader.replace("{projectName}", QLatin1String(projectName));
66 m_ui.patronsHeader->setText(patronsHeader);
67 }
68
69 {
70 QString patrons = m_ui.patrons->text();
71 patrons.replace("{patrons}", patronList.join(" • "));
72 m_ui.patrons->setText(patrons);
73 }
74
75 {
76 QString copyright = m_ui.copyright->text();
77 copyright.replace("{year}", tr("2021"));
78 m_ui.copyright->setText(copyright);
79 }
80}