Contributors / Release notes dialogs refactoring

This commit is contained in:
bsongis
2015-07-08 19:42:18 +02:00
parent 46d7fb3ff6
commit df7f715dd3
13 changed files with 841 additions and 729 deletions
+5 -1
View File
@@ -144,6 +144,8 @@ set(companion_SRCS
burnconfigdialog.cpp
comparedialog.cpp
contributorsdialog.cpp
releasenotesdialog.cpp
releasenotesfirmwaredialog.cpp
customizesplashdialog.cpp
radiointerface.cpp
progresswidget.cpp
@@ -174,6 +176,8 @@ set(companion_MOC_HDRS
fusesdialog.h
logsdialog.h
contributorsdialog.h
releasenotesdialog.h
releasenotesfirmwaredialog.h
customizesplashdialog.h
splashlibrary.h
splashlabel.h
@@ -203,7 +207,7 @@ set(companion_UIS
burnconfigdialog.ui
downloaddialog.ui
printdialog.ui
contributorsdialog.ui
htmldialog.ui
customizesplashdialog.ui
splashlibrary.ui
progresswidget.ui
+92 -118
View File
@@ -1,134 +1,108 @@
#include "contributorsdialog.h"
#include "ui_contributorsdialog.h"
#include <QtGui>
#include "ui_htmldialog.h"
#include "helpers.h"
contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnurl) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::contributorsDialog)
ContributorsDialog::ContributorsDialog(QWidget * parent):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::HtmlDialog)
{
ui->setupUi(this);
switch (contest) {
case 0:
{
this->setWindowIcon(CompanionIcon("contributors.png"));
QFile file(":/DONATIONS.txt");
QString str;
str.append("<html><head>");
str.append("<style type=\"text/css\">\n");
str.append(".mycss\n{\nfont-weight:normal;\ncolor:#000000;vertical-align: top;font-size:10px;text-align:left;font-family:arial, helvetica, sans-serif;\n}\n");
str.append(".mycssb\n{\nfont-weight:bold;\ncolor:#C00000;vertical-align: top;font-size:10px;text-align:left;font-family:arial, helvetica, sans-serif;\n}\n");
str.append(".myhead\n{\nfont-weight:bold;\ncolor:#000000;font-size:14px;text-align:left;font-family:arial, helvetica, sans-serif;\n}\n");
str.append("</style>\n</head><body class=\"mycss\"><table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
str.append("<tr><td class=\"myhead\">"+tr("People who have contributed to this project")+"</td></tr>");
str.append("</table>");
str.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
int columns=6;
float cwidth=100.0/columns;
while (!file.atEnd()) {
str.append("<tr>");
for (int i=0; i<columns; i++) {
str.append(QString("<td width=\"%1%\" ").arg(cwidth));
if (!file.atEnd()) {
QByteArray line = file.readLine();
if (line.contains("monthly") || line.contains("mensual")) {
str.append("class=\"mycssb\">");
} else {
str.append("class=\"mycss\">");
}
str.append(line.trimmed()+"</td>");
} else {
str.append("class=\"mycss\">&nbsp;</td>");
}
}
str.append("</tr>");
}
}
str.append("</table>");
QFile file2(":/CREDITS.txt");
str.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
str.append("<tr><td class=\"mycss\">&nbsp;</td></tr>");
str.append("<tr><td class=\"myhead\">"+tr("Coders")+"</td></tr>");
str.append("</table>");
str.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
if(file2.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
while (!file2.atEnd()) {
str.append("<tr>");
for (int i=0; i<3; i++) {
str.append("<td width=\"33.33%\" class=\"mycss\">");
if (!file2.atEnd()) {
QByteArray line = file2.readLine();
str.append(line.trimmed());
} else {
str.append("&nbsp;");
}
str.append("</td>");
}
str.append("</tr>");
}
}
str.append("<tr><td class=\"mycss\">&nbsp;</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">" + tr("Thank you all !!!") + "</td></tr>");
str.append("</table>");
str.append("</body></html>");
ui->textEditor->setHtml(str);
ui->textEditor->scroll(0, 0);
setWindowTitle(tr("Contributors"));
break;
}
case 1:
{
this->setWindowIcon(CompanionIcon("changelog.png"));
QFile file(":/releasenotes.txt");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textEditor->setHtml(file.readAll());
ui->textEditor->setOpenExternalLinks(true);
}
ui->textEditor->scroll(0,0);
setWindowTitle(tr("Companion Release Notes"));
break;
}
ui->setupUi(this);
case 2:
{
if (!rnurl.isEmpty()) {
this->setWindowIcon(CompanionIcon("changelog.png"));
this->setWindowTitle(tr("OpenTX Release Notes"));
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
QUrl url(rnurl);
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
manager->get(request);
}
else {
QTimer::singleShot(0, this, SLOT(forceClose()));
}
setWindowTitle(tr("OpenTX Contributors"));
setWindowIcon(CompanionIcon("contributors.png"));
QString str = "<html>" \
"<head>" \
" <style type=\"text/css\">" \
" .normal { font-weight:normal;color:#000000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
" .bold { font-weight:bold;color:#C00000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
" .title { font-weight:bold;color:#000000;font-size:14px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
" </style>" \
"</head>"
"<body class=\"normal\">";
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><td class=\"normal\">&nbsp;</td></tr>" \
" <tr><td colspan=3 class=\"normal\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>" \
" <tr><td colspan=3 class=\"normal\">" + tr("Thank you all !!!") + "</td></tr>" \
"</table>");
str.append("</body></html>");
ui->textEditor->setHtml(str);
ui->textEditor->scroll(0, 0);
ui->textEditor->setOpenExternalLinks(true);
}
void contributorsDialog::showEvent ( QShowEvent * )
ContributorsDialog::~ContributorsDialog()
{
ui->textEditor->scroll(0, 0);
delete ui;
}
contributorsDialog::~contributorsDialog()
QString ContributorsDialog::formatTable(const QString & title, const QStringList & names, int columns)
{
delete ui;
}
const float cwidth = 100.0 / columns;
QString str = "<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>" \
" <tr><td class=\"normal\">&nbsp;</td></tr>" \
" <tr><td class=\"title\">" + title + "</td></tr>" \
"</table>";
void contributorsDialog::replyFinished(QNetworkReply * reply)
{
ui->textEditor->setHtml(reply->readAll());
ui->textEditor->setOpenExternalLinks(true);
}
str.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
void contributorsDialog::forceClose()
{
accept();;
int column = 0;
foreach(QString name, names) {
if (column == 0) {
str.append("<tr>");
}
QString trclass = name.contains("monthly") ? "bold" : "normal";
str.append(QString("<td width=\"%1%\" class=\"%2\">%3</td>").arg(cwidth).arg(trclass).arg(name.trimmed().replace("monthly", tr("monthly"))));
if (++column == columns) {
str.append("</tr>");
column = 0;
}
}
if (column != 0) {
str.append("</tr>");
}
str.append("</table>");
return str;
}
+9 -17
View File
@@ -2,30 +2,22 @@
#define CONTRIBUTORSDIALOG_H
#include <QDialog>
#include "eeprominterface.h"
#include "downloaddialog.h"
namespace Ui {
class contributorsDialog;
class HtmlDialog;
}
class contributorsDialog : public QDialog
class ContributorsDialog : public QDialog
{
Q_OBJECT
public:
explicit contributorsDialog(QWidget *parent = 0, int contest = 0, QString rnurl = QString() );
~contributorsDialog();
Q_OBJECT
private:
Ui::contributorsDialog *ui;
QNetworkAccessManager *manager;
public:
explicit ContributorsDialog(QWidget * parent = 0);
~ContributorsDialog();
void showEvent ( QShowEvent * );
private slots:
void forceClose();
void replyFinished(QNetworkReply * reply);
private:
Ui::HtmlDialog * ui;
QString formatTable(const QString & title, const QStringList & names, int colums);
};
#endif // CONTRIBUTORSDIALOG_H
@@ -1094,6 +1094,17 @@ void addOpenTxCommonOptions(OpenTxFirmware * firmware)
firmware->addOptions(fai_options);
}
void addOpenTxTaranisOptions(OpenTxFirmware * firmware)
{
firmware->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
firmware->addOption("nogvars", QObject::tr("Disable Global variables"));
firmware->addOption("lua", QObject::tr("Support for Lua model scripts"));
firmware->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
firmware->addOption("mixersmon", QObject::tr("Adds mixers output view to the CHANNELS MONITOR screen, pressing [ENT] switches between the views"));
firmware->addOption("eu", QObject::tr("Removes D8 and LR12 FrSky protocols that are not legal for use anymore on radios sold after Jan 1st, 2015"));
firmware->addOption("internalppm", QObject::tr("Support for PPM internal module hack"));
}
void addOpenTxLcdOptions(OpenTxFirmware * firmware)
{
Option lcd_options[] = {
@@ -1338,35 +1349,20 @@ void registerOpenTxFirmwares()
/* Taranis board */
openTx = new OpenTxFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), BOARD_TARANIS);
openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
openTx->addOption("haptic", QObject::tr("Haptic module installed"));
openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
openTx->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
openTx->addOption("mixersmon", QObject::tr("Adds mixers output view to the CHANNELS MONITOR screen, pressing [ENT] switches between the views"));
openTx->addOption("eu", QObject::tr("Removes D8 and LR12 FrSky protocols that are not legal for use anymore on radios sold after Jan 1st, 2015"));
addOpenTxTaranisOptions(openTx);
addOpenTxCommonOptions(openTx);
firmwares.push_back(openTx);
/* Taranis Plus board */
openTx = new OpenTxFirmware("opentx-taranisplus", QObject::tr("OpenTX for FrSky Taranis Plus"), BOARD_TARANIS_PLUS);
openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
openTx->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
openTx->addOption("mixersmon", QObject::tr("Adds mixers output view to the CHANNELS MONITOR screen, pressing [ENT] switches between the views"));
openTx->addOption("eu", QObject::tr("Removes D8 and LR12 FrSky protocols that are not legal for use anymore on radios sold after Jan 1st, 2015"));
addOpenTxTaranisOptions(openTx);
addOpenTxCommonOptions(openTx);
firmwares.push_back(openTx);
/* Taranis X9E board */
openTx = new OpenTxFirmware("opentx-taranisx9e", QObject::tr("OpenTX for FrSky Taranis X9E"), BOARD_TARANIS_X9E);
openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
openTx->addOption("nojoystick", QObject::tr("No Joystick emulation inside the FW (only Mass Storage as in the Bootloader)"));
openTx->addOption("mixersmon", QObject::tr("Adds mixers output view to the CHANNELS MONITOR screen, pressing [ENT] switches between the views"));
openTx->addOption("eu", QObject::tr("Removes D8 and LR12 FrSky protocols that are not legal for use anymore on radios sold after Jan 1st, 2015"));
addOpenTxTaranisOptions(openTx);
addOpenTxCommonOptions(openTx);
firmwares.push_back(openTx);
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>contributorsDialog</class>
<widget class="QDialog" name="contributorsDialog">
<class>HtmlDialog</class>
<widget class="QDialog" name="HtmlDialog">
<property name="geometry">
<rect>
<x>0</x>
+11 -9
View File
@@ -56,6 +56,8 @@
#include "printdialog.h"
#include "version.h"
#include "contributorsdialog.h"
#include "releasenotesdialog.h"
#include "releasenotesfirmwaredialog.h"
#include "customizesplashdialog.h"
#include "flasheepromdialog.h"
#include "flashfirmwaredialog.h"
@@ -422,8 +424,8 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
msgBox.resize(0, 0);
msgBox.exec();
if (msgBox.clickedButton() == rnButton) {
contributorsDialog *cd = new contributorsDialog(this,2,rn);
cd->exec();
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
dialog->exec();
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString), QMessageBox::Yes | QMessageBox::No);
if (ret2 == QMessageBox::Yes)
download = true;
@@ -451,7 +453,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
msgBox.resize(0,0);
msgBox.exec();
if( msgBox.clickedButton() == rnButton ) {
contributorsDialog *cd = new contributorsDialog(this, 2, rn);
ContributorsDialog *cd = new ContributorsDialog(this); // , 2, rn);
cd->exec();
int ret2 = QMessageBox::question(this, "Companion", tr("Do you want to download release %1 now ?").arg(versionString),
QMessageBox::Yes | QMessageBox::No);
@@ -666,8 +668,8 @@ void MainWindow::fwPrefs()
void MainWindow::contributors()
{
contributorsDialog *cd = new contributorsDialog(this,0);
cd->exec();
ContributorsDialog * dialog = new ContributorsDialog(this);
dialog->exec();
}
void MainWindow::sdsync()
@@ -686,8 +688,8 @@ void MainWindow::sdsync()
void MainWindow::changelog()
{
contributorsDialog *cd = new contributorsDialog(this,1);
cd->exec();
ReleaseNotesDialog * dialog = new ReleaseNotesDialog(this);
dialog->exec();
}
void MainWindow::fwchangelog()
@@ -698,8 +700,8 @@ void MainWindow::fwchangelog()
QMessageBox::information(this, tr("Firmware updates"), tr("Current firmware does not provide release notes informations."));
}
else {
contributorsDialog *cd = new contributorsDialog(this,2, rn);
cd->exec();
ReleaseNotesFirmwareDialog * dialog = new ReleaseNotesFirmwareDialog(this, rn);
dialog->exec();
}
}
+25
View File
@@ -0,0 +1,25 @@
#include "releasenotesdialog.h"
#include "ui_htmldialog.h"
ReleaseNotesDialog::ReleaseNotesDialog(QWidget * parent) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::HtmlDialog)
{
ui->setupUi(this);
setWindowTitle(tr("Companion Release Notes"));
setWindowIcon(CompanionIcon("changelog.png"));
QFile file(":/releasenotes.txt");
if (file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textEditor->setHtml(file.readAll());
ui->textEditor->setOpenExternalLinks(true);
}
ui->textEditor->scroll(0, 0);
ui->textEditor->setOpenExternalLinks(true);
}
ReleaseNotesDialog::~ReleaseNotesDialog()
{
delete ui;
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef RELEASENOTESDIALOG_H
#define RELEASENOTESDIALOG_H
#include <QDialog>
#include "helpers.h"
namespace Ui {
class HtmlDialog;
}
class ReleaseNotesDialog : public QDialog
{
Q_OBJECT
public:
explicit ReleaseNotesDialog(QWidget *parent = 0);
~ReleaseNotesDialog();
private:
Ui::HtmlDialog * ui;
};
#endif // RELEASENOTESDIALOG_H
+32
View File
@@ -0,0 +1,32 @@
#include "releasenotesfirmwaredialog.h"
#include "ui_htmldialog.h"
#include "helpers.h"
ReleaseNotesFirmwareDialog::ReleaseNotesFirmwareDialog(QWidget * parent, const QString & rnurl):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui(new Ui::HtmlDialog)
{
ui->setupUi(this);
setWindowTitle(tr("OpenTX Release Notes"));
setWindowIcon(CompanionIcon("changelog.png"));
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinished(QNetworkReply *)));
QUrl url(rnurl);
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
manager->get(request);
}
ReleaseNotesFirmwareDialog::~ReleaseNotesFirmwareDialog()
{
delete ui;
}
void ReleaseNotesFirmwareDialog::replyFinished(QNetworkReply * reply)
{
ui->textEditor->setHtml(reply->readAll());
ui->textEditor->setOpenExternalLinks(true);
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef RELEASENOTESFIRMWAREDIALOG_H
#define RELEASENOTESFIRMWAREDIALOG_H
#include <QDialog>
#include "eeprominterface.h"
#include "downloaddialog.h"
namespace Ui {
class HtmlDialog;
}
class ReleaseNotesFirmwareDialog : public QDialog
{
Q_OBJECT
public:
explicit ReleaseNotesFirmwareDialog(QWidget *parent, const QString & rnurl);
~ReleaseNotesFirmwareDialog();
private:
Ui::HtmlDialog *ui;
QNetworkAccessManager *manager;
private slots:
void replyFinished(QNetworkReply * reply);
};
#endif // RELEASENOTESFIRMWAREDIALOG_H
File diff suppressed because it is too large Load Diff