/* * Copyright (C) OpenTX * * Based on code named * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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 for more details. */ #include "creditsdialog.h" #include "ui_htmldialog.h" #include "helpers.h" #include CreditsDialog::CreditsDialog(QWidget * parent): QDialog(parent), ui(new Ui::HtmlDialog) { ui->setupUi(this); setWindowTitle(tr("OpenTX Contributors")); setWindowIcon(CompanionIcon("contributors.png")); QString str = "" \ "" \ " " \ "" ""; foreach(CreditsSection section, readCredits()) { str.append(formatTable(sectionTitle(section.title), section.names, 3)); } str.append("" \ " " \ "
 
" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "
"); #if 0 QFile blacklist(":/BLACKLIST.txt"); if (blacklist.open(QIODevice::ReadOnly | QIODevice::Text)) { QStringList names; names << blacklist.readAll(); str.append(formatTable(tr("OpenTX Blacklist"), names, 1)); } #endif str.append(""); ui->textEditor->setHtml(str); ui->textEditor->scroll(0, 0); ui->textEditor->setOpenExternalLinks(true); } CreditsDialog::~CreditsDialog() { delete ui; } QList CreditsDialog::readCredits() { QFile credits(":/CREDITS.txt"); QList result; if (credits.open(QIODevice::ReadOnly | QIODevice::Text)) { while (!credits.atEnd()) { QByteArray line = credits.readLine().trimmed(); if (line.size() >= 2) { if (line.startsWith("[") && line.endsWith("]")) { result.push_back(CreditsSection(line.mid(1, line.size() - 2))); } else { result.back().addName(line); } } } } return result; } QString CreditsDialog::sectionTitle(const QString & title) { if (title == "Main developers") return tr("Main developers"); else if (title == "Translators") return tr("Translators"); else if (title == "Companies and projects who have donated to OpenTX") return tr("Companies and projects who have donated to OpenTX"); else if (title == "People who have donated to OpenTX") return tr("People who have donated to OpenTX"); else return tr("Other contributors"); } QString CreditsDialog::formatTable(const QString & title, const QStringList & names, int columns) { const float cwidth = 100.0 / columns; QString str = "" \ " " \ " " \ "
 
" + title + "
"; str.append(""); int column = 0; foreach(QString name, names) { if (column == 0) { str.append(""); } QString trclass = name.contains("monthly") ? "bold" : "normal"; str.append(QString("").arg(cwidth).arg(trclass).arg(name.trimmed().replace("monthly", tr("monthly")))); if (++column == columns) { str.append(""); column = 0; } } if (column != 0) { str.append(""); } str.append("
%3
"); return str; }