all repos — mgba @ 82a0088e1ec4a1fe13f9eff96c9c72d22995013e

mGBA Game Boy Advance Emulator

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
 8extern "C" {
 9#include "core/version.h"
10}
11
12#include <QFile>
13#include <QPixmap>
14
15using namespace QGBA;
16
17AboutScreen::AboutScreen(QWidget* parent)
18	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
19{
20	m_ui.setupUi(this);
21
22	QPixmap logo(":/res/mgba-1024.png");
23	logo = logo.scaled(m_ui.logo->minimumSize() * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
24	logo.setDevicePixelRatio(devicePixelRatio());
25	m_ui.logo->setPixmap(logo);
26
27	QLatin1String tree(gitBranch);
28	if (tree == QLatin1String("(unknown)")) {
29		tree = QLatin1String(projectVersion);
30	}
31
32	QFile patronFile(":/res/patrons.txt");
33	QStringList patronList;
34	patronFile.open(QIODevice::ReadOnly | QIODevice::Text);
35	while (true) {
36		QByteArray line = patronFile.readLine();
37		if (line.isEmpty()) {
38			break;
39		}
40		patronList.append(QString::fromUtf8(line).trimmed());
41	}
42
43	m_ui.projectName->setText(QLatin1String(projectName));
44	m_ui.projectVersion->setText(QLatin1String(projectVersion));
45
46	{
47		QString gitInfo = m_ui.gitInfo->text();
48		gitInfo.replace("{gitBranch}", QLatin1String(gitBranch));
49		gitInfo.replace("{gitCommit}", QLatin1String(gitCommit));
50		m_ui.gitInfo->setText(gitInfo);
51	}
52
53	{
54		QString description = m_ui.description->text();
55		description.replace("{projectName}", QLatin1String(projectName));
56		m_ui.description->setText(description);
57	}
58
59	{
60		QString extraLinks = m_ui.extraLinks->text();
61		extraLinks.replace("{gitBranch}", tree);
62		m_ui.extraLinks->setText(extraLinks);
63	}
64
65	{
66		QString patronsHeader = m_ui.patronsHeader->text();
67		patronsHeader.replace("{projectName}", QLatin1String(projectName));
68		m_ui.patronsHeader->setText(patronsHeader);
69	}
70
71	{
72		QString patrons = m_ui.patrons->text();
73		patrons.replace("{patrons}", patronList.join(""));
74		m_ui.patrons->setText(patrons);
75	}
76}