/
about_dialog.cpp
202 lines (180 loc) · 6.48 KB
/
about_dialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Copyright 2012, 2013, 2014 Thomas Schöps
* Copyright 2012-2019 Kai Pastor
*
* This file is part of OpenOrienteering.
*
* OpenOrienteering is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenOrienteering is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
*/
#include "about_dialog.h"
#include <cmath>
#include <QApplication>
#include <QTextBrowser>
#include "mapper_config.h"
namespace OpenOrienteering {
namespace {
/**
* @brief An URL identifying the main "about" page.
*
* The main page's text will be set directly, thus not having a valid URL.
* But an empty URL will be ignored by QTextBrowser's history, leading to
* unexpected behaviour of backward navigation.
*/
const QUrl& aboutPageUrl()
{
static auto url = QUrl(QString::fromLatin1("#ABOUT"));
return url;
}
/**
* Puts the items of a QStringList into an HTML block or a sequence of blocks.
*/
QString formatBlock(const QStringList& items)
{
#if defined(Q_OS_ANDROID) // or any other small-screen device
QString block = QLatin1String("<p>")
+ items.join(QString::fromLatin1(", "))
+ QLatin1String("</p>");
#else
QString block;
block.reserve(100 + 30 * items.size());
block.append(QLatin1String("<table><tr><td>"));
constexpr int columns = 3;
const int rows = (int)ceil((double)items.size() / columns);
for (int i = 0, row = 1; i < items.size(); ++i)
{
block.append(items[i]);
if (rows != row)
{
block.append(QString::fromLatin1("<br/>"));
++row;
}
else if (i < items.size())
{
block.append(QString::fromLatin1("</td><td> </td><td>"));
row = 1;
}
}
block.append(QString::fromLatin1("</td></tr></table>"));
#endif
return block;
}
} // namespace
AboutDialog::AboutDialog(QWidget* parent)
: TextBrowserDialog(aboutPageUrl(), parent)
{
text_browser->setHtml(about());
text_browser->document()->adjustSize();
updateWindowTitle();
}
void AboutDialog::sourceChanged(const QUrl& url)
{
if (url == aboutPageUrl())
text_browser->setHtml(about());
}
void AboutDialog::updateWindowTitle()
{
QString title = text_browser->documentTitle();
if (title.isEmpty())
title = tr("About %1").arg(APP_NAME);
setWindowTitle(title);
}
QString AboutDialog::about()
{
static QStringList developers_list( QStringList()
<< QString::fromLatin1("Peter Curtis (2012-2013)")
<< QString::fromLatin1("<b>Kai Pastor</b>")
<< QString::fromUtf8("<b>Libor Pecháček</b>")
<< QString::fromUtf8("Thomas Schöps (2012-2014, %1)")
);
static QStringList contributors_list( QStringList()
<< QString::fromLatin1("Arrizal Amin")
<< QString::fromLatin1("Javier Arufe")
<< QString::fromLatin1("Jonathan Bakker")
<< QString::fromLatin1("Eric Boulet")
<< QString::fromLatin1("Jon Cundill")
<< QString::fromUtf8("Sławomir Cygler")
<< QString::fromLatin1("Jan Dalheimer")
<< QString::fromLatin1("Davide De Nardis")
<< QString::fromLatin1("Eugeniy Fedirets")
<< QString::fromLatin1("Joao Franco")
<< QString::fromLatin1("Pavel Fric")
<< QString::fromLatin1("Naofumi Fukue")
<< QString::fromLatin1("Anders Gressli")
<< QString::fromLatin1("Peter Hoban")
<< QString::fromLatin1("Henrik Johansson")
<< QString::fromLatin1("Panu Karhu")
<< QString::fromLatin1("Oskar Karlin")
<< QString::fromLatin1("Nikolay Korotkiy")
<< QString::fromLatin1("Mitchell Krome")
<< QString::fromUtf8("Matthias Kühlewein")
<< QString::fromLatin1("Albin Larsson")
<< QString::fromUtf8("István Marczis")
<< QString::fromLatin1("Tojo Masaya")
<< QString::fromLatin1("Yevhen Mazur")
<< QString::fromLatin1("Fraser Mills")
<< QString::fromLatin1("Vincent Poinsignon")
<< QString::fromLatin1("Russell Porter")
<< QString::fromLatin1("Adhika Setya Pramudita")
<< QString::fromLatin1("Christopher Schive")
<< QString::fromLatin1("Arif Suryawan")
<< QString::fromLatin1("Jan-Gerard van der Toorn")
<< QString::fromLatin1("Scott Turner")
<< QString::fromLatin1("Semyon Yakimov")
<< QString::fromLatin1("Aivars Zogla")
);
QString mapper_about = QString::fromLatin1(
"<html><head>"
"<title>%0</title>"
"</head><body>"
"<table><tr>"
"<td><img src=\":/images/mapper-icon/Mapper-128.png\"/></td>"
"<td><img src=\":/images/open-orienteering.png\"/></td>"
"</tr></table>"
"<h1>%1</h1>"
"<p>"
"<em>%3</em><br/>"
"<a href=\"%4\">%4</a></p>"
"<p>Copyright %2</p>"
"<p>%5</p>"
"<p>%6</p>"
"<p>%7</p>"
"<p>%8</p>%9"
"<p> <br/>%10</p>%11"
"</body></html>"
).arg(
tr("About %1").arg(APP_NAME), // %0
qApp->applicationDisplayName(), // %1
QString::fromLatin1(APP_COPYRIGHT), // %2
tr("A free software for drawing orienteering maps"), // %3
QString::fromLatin1("https://www.openorienteering.org/apps/mapper/"), // %4
tr("This program is free software: you can redistribute it "
"and/or modify it under the terms of the "
"<a %1>GNU General Public License (GPL), version 3</a>, "
"as published by the Free Software Foundation.").arg(QString::fromLatin1("href=\"file:doc:/common-licenses/GPL-3.txt\"")), // %5
// %6
tr("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License (GPL), version 3, for "
"<a %1>more details</a>.").arg(QString::fromLatin1("href=\"file:doc:/common-licenses/GPL-3.txt#L589\"")), // %6
tr("<a %1>All about licenses, copyright notices, conditions and disclaimers.</a>").arg(QString::fromLatin1("href=\"file:doc:/licensing.html\"")) // %7
).arg(
tr("The OpenOrienteering developers in alphabetical order:"), // %8
formatBlock(developers_list).arg(tr("(project initiator)").replace(QLatin1Char('('), QString{}).replace(QLatin1Char(')'), QString{})), // %9
tr("For contributions, thanks to:"), // %10
formatBlock(contributors_list) // %11
);
return mapper_about;
}
} // namespace OpenOrienteering