diff --git a/companion/src/burnconfigdialog.cpp b/companion/src/burnconfigdialog.cpp
index d7ce28e6d..e0ea4a63e 100644
--- a/companion/src/burnconfigdialog.cpp
+++ b/companion/src/burnconfigdialog.cpp
@@ -83,7 +83,7 @@ burnConfigDialog::~burnConfigDialog()
void burnConfigDialog::getSettings()
{
- QSettings settings("companion", "companion");
+ QSettings settings;
#if defined WIN32 || !defined __GNUC__
avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString();
sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString();
@@ -137,7 +137,7 @@ void burnConfigDialog::getSettings()
void burnConfigDialog::putSettings()
{
- QSettings settings("companion", "companion");
+ QSettings settings;
settings.setValue("avrdude_location", avrLoc);
settings.setValue("programmer", avrProgrammer);
settings.setValue("mcu", avrMCU);
@@ -279,10 +279,9 @@ void burnConfigDialog::listProgrammers()
QStringList arguments;
arguments << "-c?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE);
- QIcon Icon;
- populate_icon(&Icon,"list.png");
- ad->setWindowIcon(Icon);
+ ad->setWindowIcon(CompanionIcon("list.png"));
ad->show();
+ delete ad;
}
void burnConfigDialog::on_pushButton_3_clicked()
@@ -298,10 +297,9 @@ void burnConfigDialog::on_pushButton_4_clicked()
arguments << "-?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE);
- QIcon Icon;
- populate_icon(&Icon,"configure.png");
- ad->setWindowIcon(Icon);
+ ad->setWindowIcon(CompanionIcon("configure.png"));
ad->show();
+ delete ad;
}
@@ -317,10 +315,9 @@ void burnConfigDialog::readFuses()
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str;
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
- QIcon Icon;
- populate_icon(&Icon,"fuses.png");
- ad->setWindowIcon(Icon);
+ ad->setWindowIcon(CompanionIcon("fuses.png"));
ad->show();
+ delete ad;
}
void burnConfigDialog::restFuses(bool eeProtect)
@@ -344,7 +341,8 @@ void burnConfigDialog::restFuses(bool eeProtect)
QString erStr = eeProtect ? "hfuse:w:0x11:m" : "hfuse:w:0x19:m";
str << "-U" << "lfuse:w:0xD7:m" << "-U" << erStr << "-U" << "efuse:w:0xFC:m";
//use hfuse = 0x81 to prevent eeprom being erased with every flashing
- } else {
+ }
+ else {
QString tempDir = QDir::tempPath();
QString tempFile;
QString lfuses;
@@ -352,10 +350,9 @@ void burnConfigDialog::restFuses(bool eeProtect)
QStringList argread;
argread << "-c" << avrProgrammer << "-p" << avrMCU << args <<"-U" << "lfuse:r:"+tempFile+":r" ;
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, argread, "Reset Fuses",AVR_DIALOG_CLOSE_IF_SUCCESSFUL,FALSE);
- QIcon Icon;
- populate_icon(&Icon,"fuses.png");
- ad->setWindowIcon(Icon);
+ ad->setWindowIcon(CompanionIcon("fuses.png"));
ad->exec();
+ delete ad;
QFile file(tempFile);
if (file.exists() && file.size()==1) {
file.open(QIODevice::ReadOnly);
@@ -363,12 +360,14 @@ void burnConfigDialog::restFuses(bool eeProtect)
file.read(bin_flash, 1);
if (bin_flash[0]==0x0E) {
lfuses="lfuse:w:0x0E:m";
- } else {
+ }
+ else {
lfuses="lfuse:w:0x3F:m";
}
file.close();
unlink(tempFile.toAscii());
- } else {
+ }
+ else {
lfuses="lfuse:w:0x3F:m";
}
@@ -379,14 +378,14 @@ void burnConfigDialog::restFuses(bool eeProtect)
QStringList arguments;
if (avrMCU=="m2560") {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-u" << str;
- } else {
+ }
+ else {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str;
}
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
- QIcon Icon;
- populate_icon(&Icon,"fuses.png");
- ad->setWindowIcon(Icon);
+ ad->setWindowIcon(CompanionIcon("fuses.png"));
ad->show();
+ delete ad;
}
}
@@ -398,24 +397,29 @@ void burnConfigDialog::on_advCtrChkB_toggled(bool checked)
if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->show();
ui->dfuArgs->show();
- } else if (eepromInterface->getBoard()==BOARD_SKY9X) {
+ }
+ else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->show();
ui->arm_mcu->show();
- } else {
+ }
+ else {
ui->label_av3->show();
ui->avrdude_mcu->show();
QMessageBox::warning(this, tr("Companion"),
tr("WARNING!
Normally CPU type is automatically selected according to the chosen firmware.
If you change the CPU type the resulting eeprom could be inconsistent."),
QMessageBox::Ok);
}
- } else {
+ }
+ else {
if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->hide();
ui->dfuArgs->hide();
- } else if (eepromInterface->getBoard()==BOARD_SKY9X) {
+ }
+ else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->hide();
ui->arm_mcu->hide();
- } else {
+ }
+ else {
ui->label_av3->hide();
ui->avrdude_mcu->hide();
}
diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp
index 167bba702..f1d7f5482 100644
--- a/companion/src/burndialog.cpp
+++ b/companion/src/burndialog.cpp
@@ -16,9 +16,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexType(Type)
{
ui->setupUi(this);
- QIcon LibraryIcon;
- populate_icon(&LibraryIcon,"library.png");
- ui->libraryButton->setIcon(LibraryIcon);
+ ui->libraryButton->setIcon(CompanionIcon("library.png"));
ui->SplashFrame->hide();
ui->FramFWInfo->hide();
ui->EEbackupCB->hide();
@@ -29,11 +27,12 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->patchcalib_CB->hide();
ui->patchhw_CB->hide();
ui->InvertColorButton->setDisabled(true);
- this->setWindowTitle(tr("Write firmware to TX"));
+ setWindowTitle(tr("Write firmware to TX"));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->hide();
}
- } else {
+ }
+ else {
ui->FlashLoadButton->setText(tr("Browse for file"));
ui->profile_label->hide();
ui->patchcalib_CB->hide();
@@ -54,11 +53,12 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->BurnFlashButton->setDisabled(true);
ui->EEbackupCB->hide();
if (DocName.isEmpty()) {
- this->setWindowTitle(tr("Write Models and Settings to TX"));
- } else {
- this->setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
+ setWindowTitle(tr("Write Models and Settings to TX"));
}
- QSettings settings("companion", "companion");
+ else {
+ setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
+ }
+ QSettings settings;
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
@@ -72,10 +72,11 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->FWFileName->setText(*hexfileName);
if (Type==2) {
checkFw(*hexfileName);
- } else {
+ }
+ else {
burnraw=false;
if (checkeEprom(*hexfileName)) {
- QSettings settings("companion", "companion");
+ QSettings settings;
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
@@ -100,12 +101,14 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
if (!((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6))) {
ui->patchhw_CB->setDisabled(true);
}
- } else {
+ }
+ else {
ui->profile_label->hide();
}
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show();
- } else {
+ }
+ else {
ui->EEpromCB->setChecked(false);
}
ui->BurnFlashButton->setEnabled(true);
@@ -116,7 +119,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexfileName->clear();
}
else if (Type==2) {
- QSettings settings("companion", "companion");
+ QSettings settings;
QString FileName;
FileName = settings.value("lastFw").toString();
QFile file(FileName);
@@ -127,14 +130,15 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
resize(0, 0);
}
-burnDialog::~burnDialog() {
+burnDialog::~burnDialog()
+{
delete ui;
}
void burnDialog::on_FlashLoadButton_clicked()
{
QString fileName;
- QSettings settings("companion", "companion");
+ QSettings settings;
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->InvertColorButton->setDisabled(true);
@@ -153,7 +157,8 @@ void burnDialog::on_FlashLoadButton_clicked()
if (hexType==2) {
fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
checkFw(fileName);
- } else {
+ }
+ else {
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (checkeEprom(fileName)) {
if (burnraw==false) {
@@ -163,10 +168,12 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->patchhw_CB->show();
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show();
- } else {
+ }
+ else {
ui->EEpromCB->setChecked(false);
}
- } else {
+ }
+ else {
ui->BurnFlashButton->setEnabled(true);
ui->profile_label->hide();
ui->patchcalib_CB->setChecked(false);
@@ -184,10 +191,11 @@ void burnDialog::checkFw(QString fileName)
if (fileName.isEmpty()) {
return;
}
- QSettings settings("companion", "companion");
+ QSettings settings;
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->show();
- } else {
+ }
+ else {
ui->EEbackupCB->setChecked(false);
*backup=false;
}
@@ -226,23 +234,27 @@ void burnDialog::checkFw(QString fileName)
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(flash.getSplashFormat())));
ui->PatchFWCB->setEnabled(true);
ui->PatchFWCB->setChecked(PatchFwCB);
- } else {
+ }
+ else {
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true);
}
- } else {
+ }
+ else {
ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true);
}
}
- } else {
+ }
+ else {
ui->FwImage->hide();
ui->ImageFileName->setText("");
ui->SplashFrame->hide();
}
- } else {
+ }
+ else {
QMessageBox::warning(this, tr("Warning"), tr("%1 is not a known firmware").arg(fileName));
ui->BurnFlashButton->setText(tr("Burn anyway !"));
ui->BurnFlashButton->setEnabled(true);
@@ -270,7 +282,8 @@ bool burnDialog::checkeEprom(QString fileName)
}
QTextStream inputStream(&file);
XmlInterface(inputStream).load(radioData);
- } else if (fileType==FILE_TYPE_HEX || fileType==FILE_TYPE_EEPE) { //read HEX file
+ }
+ else if (fileType==FILE_TYPE_HEX || fileType==FILE_TYPE_EEPE) { //read HEX file
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false;
@@ -313,7 +326,8 @@ bool burnDialog::checkeEprom(QString fileName)
ui->FWFileName->setText(fileName);
return true;
}
- } else if (fileType==FILE_TYPE_BIN) { //read binary
+ }
+ else if (fileType==FILE_TYPE_BIN) { //read binary
int eeprom_size = file.size();
if (!file.open(QFile::ReadOnly)) { //reading binary file - TODO HEX support
QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
@@ -346,7 +360,7 @@ void burnDialog::on_ImageLoadButton_clicked()
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
- QSettings settings("companion", "companion");
+ QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
@@ -368,17 +382,16 @@ void burnDialog::on_ImageLoadButton_clicked()
int gray;
int width = image.width();
int height = image.height();
- for (int i = 0; i < width; ++i)
- {
- for (int j = 0; j < height; ++j)
- {
- col = image.pixel(i, j);
- gray = qGray(col);
- image.setPixel(i, j, qRgb(gray, gray, gray));
- }
+ for (int i = 0; i < width; ++i) {
+ for (int j = 0; j < height; ++j) {
+ col = image.pixel(i, j);
+ gray = qGray(col);
+ image.setPixel(i, j, qRgb(gray, gray, gray));
+ }
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
- } else {
+ }
+ else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
}
ui->PatchFWCB->setEnabled(true);
@@ -429,7 +442,7 @@ void burnDialog::on_BurnFlashButton_clicked()
if (hexType==2) {
QString fileName=ui->FWFileName->text();
if (!fileName.isEmpty()) {
- QSettings settings("companion", "companion");
+ QSettings settings;
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
settings.setValue("lastFw", fileName);
if (ui->PatchFWCB->isChecked()) {
@@ -466,7 +479,7 @@ void burnDialog::on_BurnFlashButton_clicked()
}
}
if (hexType==1) {
- QSettings settings("companion", "companion");
+ QSettings settings;
int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
@@ -643,7 +656,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked)
{
QString tmpFileName;
if (checked) {
- QSettings settings("companion", "companion");
+ QSettings settings;
QString ImageStr = settings.value("SplashImage", "").toString();
if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr);
diff --git a/companion/src/contributorsdialog.cpp b/companion/src/contributorsdialog.cpp
index a13e15b45..8f3066b79 100644
--- a/companion/src/contributorsdialog.cpp
+++ b/companion/src/contributorsdialog.cpp
@@ -66,7 +66,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
}
}
str.append("