#include "contributorsdialog.h"
#include "ui_htmldialog.h"
#include "helpers.h"
ContributorsDialog::ContributorsDialog(QWidget * parent):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::HtmlDialog)
{
ui->setupUi(this);
setWindowTitle(tr("OpenTX Contributors"));
setWindowIcon(CompanionIcon("contributors.png"));
QString str = "" \
"
" \
" " \
""
"";
QFile credits(":/CREDITS.txt");
if (credits.open(QIODevice::ReadOnly | QIODevice::Text)) {
QStringList names;
while (!credits.atEnd()) {
QByteArray line = credits.readLine();
if (line.trimmed() == "")
break;
names.append(line.trimmed());
}
str.append(formatTable(tr("Main Developers"), names, 3));
names.clear();
while (!credits.atEnd()) {
QByteArray line = credits.readLine();
names.append(line.trimmed());
}
str.append(formatTable(tr("Other contributors"), names, 3));
}
QFile donations(":/DONATIONS.txt");
if (donations.open(QIODevice::ReadOnly | QIODevice::Text)) {
QStringList names;
while (!donations.atEnd()) {
QByteArray line = donations.readLine();
if (line.trimmed() == "")
break;
names.append(line.trimmed());
}
str.append(formatTable(tr("Companies and projects who have donated to OpenTX"), names, 3));
names.clear();
while (!donations.atEnd()) {
QByteArray line = donations.readLine();
names.append(line);
}
str.append(formatTable(tr("People who have donated to OpenTX"), names, 6));
}
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);
}
ContributorsDialog::~ContributorsDialog()
{
delete ui;
}
QString ContributorsDialog::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("%3 | ").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("
");
return str;
}