5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "creditsdialog.h"
22 #include "ui_htmldialog.h"
26 CreditsDialog::CreditsDialog(QWidget
* parent
):
28 ui(new Ui::HtmlDialog
)
32 setWindowTitle(tr("OpenTX Contributors"));
33 setWindowIcon(CompanionIcon("contributors.png"));
35 QString str
= "<html>" \
37 " <style type=\"text/css\">" \
38 " .normal { font-weight:normal;color:#000000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
39 " .bold { font-weight:bold;color:#C00000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
40 " .title { font-weight:bold;color:#000000;font-size:14px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
43 "<body class=\"normal\">";
45 foreach(CreditsSection section
, readCredits()) {
46 str
.append(formatTable(sectionTitle(section
.title
), section
.names
, 3));
49 str
.append("<table><tr><td class=\"normal\"> </td></tr>" \
50 " <tr><td class=\"normal\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>" \
54 QFile
blacklist(":/BLACKLIST.txt");
55 if (blacklist
.open(QIODevice::ReadOnly
| QIODevice::Text
)) {
57 names
<< blacklist
.readAll();
58 str
.append(formatTable(tr("OpenTX Blacklist"), names
, 1));
62 str
.append("</body></html>");
63 ui
->textEditor
->setHtml(str
);
64 ui
->textEditor
->scroll(0, 0);
65 ui
->textEditor
->setOpenExternalLinks(true);
68 CreditsDialog::~CreditsDialog()
73 QList
<CreditsDialog::CreditsSection
> CreditsDialog::readCredits()
75 QFile
credits(":/CREDITS.txt");
76 QList
<CreditsSection
> result
;
77 if (credits
.open(QIODevice::ReadOnly
| QIODevice::Text
)) {
78 while (!credits
.atEnd()) {
79 QByteArray line
= credits
.readLine().trimmed();
80 if (line
.size() >= 2) {
81 if (line
.startsWith("[") && line
.endsWith("]")) {
82 result
.push_back(CreditsSection(line
.mid(1, line
.size() - 2)));
84 result
.back().addName(line
);
92 QString
CreditsDialog::sectionTitle(const QString
& title
)
94 if (title
== "Main developers")
95 return tr("Main developers");
96 else if (title
== "Translators")
97 return tr("Translators");
98 else if (title
== "Companies and projects who have donated to OpenTX")
99 return tr("Companies and projects who have donated to OpenTX");
100 else if (title
== "People who have donated to OpenTX")
101 return tr("People who have donated to OpenTX");
103 return tr("Other contributors");
106 QString
CreditsDialog::formatTable(const QString
& title
, const QStringList
& names
, int columns
)
108 const float cwidth
= 100.0 / columns
;
109 QString str
= "<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>" \
110 " <tr><td class=\"normal\"> </td></tr>" \
111 " <tr><td class=\"title\">" + title
+ "</td></tr>" \
114 str
.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
117 foreach(QString name
, names
) {
121 QString trclass
= name
.contains("monthly") ? "bold" : "normal";
122 str
.append(QString("<td width=\"%1%\" class=\"%2\">%3</td>").arg(cwidth
).arg(trclass
).arg(name
.trimmed().replace("monthly", tr("monthly"))));
123 if (++column
== columns
) {
133 str
.append("</table>");