diff --git a/README.md b/README.md new file mode 100644 index 000000000..1b9c5331e --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +##OpenTX Next Branch + +You have found your way to the GitHub repository site for the OpenTX Next Branch. This code branch holds the source code for the ongoing development. + +The stable release code is not here, it is in the master branch. +Under no circumstances build and use software from this branch for real world application. At times you will be more or less guaranteed to crash your plane and destroy all your model settings. + +Refer to the opentx.wiki for information about setting up the tool chains for building OpenTX and OpenTX Companion as well as other development related issues. diff --git a/README.txt b/README.txt deleted file mode 100644 index 8f6415cbd..000000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -[to be written] 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..54d32f9f7 100644 --- a/companion/src/contributorsdialog.cpp +++ b/companion/src/contributorsdialog.cpp @@ -8,7 +8,8 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu { ui->setupUi(this); switch (contest) { - case 0: { + case 0: + { QFile file(":/DONATIONS.txt"); QString str; str.append(""); @@ -20,7 +21,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu str.append(""+tr("People who have contributed to this project")+""); str.append(""); str.append(""); - if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { int columns=6; float cwidth=100.0/columns; while (!file.atEnd()) { @@ -66,26 +67,29 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu } } str.append(""); - str.append(""); - str.append(""); + str.append(""); + str.append(""); str.append("
 
"+tr("Honors go to Rafal Tomczak (RadioClone) and Thomas Husterer (th9x) \nof course. Also to Erez Raviv (er9x) and it's fantastic eePe, from which\ncompanion9x was forked out.")+"
"+tr("Thank you all !!!")+"
" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "
" + tr("Thank you all !!!") + "
"); str.append(""); ui->textEditor->setHtml(str); - ui->textEditor->scroll(0,0); - this->setWindowTitle(tr("Contributors")); - } + ui->textEditor->scroll(0, 0); + setWindowTitle(tr("Contributors")); break; + } - case 1:{ + case 1: + { QFile file(":/releasenotes.txt"); if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { ui->textEditor->setHtml(file.readAll()); } ui->textEditor->scroll(0,0); - this->setWindowTitle(tr("Companion Release Notes")); - } + setWindowTitle(tr("Companion Release Notes")); break; - case 2:{ + } + + case 2: + { if (!rnurl.isEmpty()) { this->setWindowTitle(tr("OpenTX Release Notes")); manager = new QNetworkAccessManager(this); @@ -94,7 +98,8 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu QNetworkRequest request(url); request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); manager->get(request); - } else { + } + else { QTimer::singleShot(0, this, SLOT(forceClose())); } break; @@ -104,7 +109,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu void contributorsDialog::showEvent ( QShowEvent * ) { - ui->textEditor->scroll(0,0); + ui->textEditor->scroll(0, 0); } contributorsDialog::~contributorsDialog() @@ -117,6 +122,7 @@ void contributorsDialog::replyFinished(QNetworkReply * reply) ui->textEditor->setHtml(reply->readAll()); } -void contributorsDialog::forceClose() { +void contributorsDialog::forceClose() +{ accept();; } diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 5fa478291..30762142f 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -8,23 +8,23 @@ #include "flashinterface.h" customizeSplashDialog::customizeSplashDialog(QWidget *parent) : -QDialog(parent), -ui(new Ui::customizeSplashDialog) { + QDialog(parent), + ui(new Ui::customizeSplashDialog) +{ ui->setupUi(this); - QIcon LibraryIcon; - populate_icon(&LibraryIcon,"library.png"); - ui->libraryButton->setIcon(LibraryIcon); + ui->libraryButton->setIcon(CompanionIcon("library.png")); ui->HowToLabel->clear(); ui->HowToLabel->append("
" + tr("Select an original firmware file") + "
"); } -customizeSplashDialog::~customizeSplashDialog() { +customizeSplashDialog::~customizeSplashDialog() +{ delete ui; } void customizeSplashDialog::on_FlashLoadButton_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); if (!fileName.isEmpty()) { ui->ImageLoadButton->setDisabled(true); @@ -70,7 +70,7 @@ void customizeSplashDialog::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)); @@ -147,7 +147,7 @@ void customizeSplashDialog::on_libraryButton_clicked() { void customizeSplashDialog::on_SaveFlashButton_clicked() { QString fileName; - QSettings settings("companion", "companion"); + QSettings settings; ui->HowToLabel->clear(); fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER, 0, QFileDialog::DontConfirmOverwrite); if (fileName.isEmpty()) { @@ -180,7 +180,7 @@ void customizeSplashDialog::on_InvertColorButton_clicked() void customizeSplashDialog::on_SaveImageButton_clicked() { QString fileName; - QSettings settings("companion", "companion"); + QSettings settings; fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastImagesDir").toString(), tr("PNG images (*.png);;"), 0, QFileDialog::DontConfirmOverwrite); if (!fileName.isEmpty()) { diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 5aeee8220..c52b8f058 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -287,7 +287,12 @@ QString RawSource::toString() if (index<0) { return QObject::tr("----"); } - switch(type) { + switch (type) { + case SOURCE_TYPE_VIRTUAL_INPUT: + if (model && strlen(model->inputNames[index]) > 0) + return QString(model->inputNames[index]); + else + return QObject::tr("Virtual Input %1").arg(index+1); case SOURCE_TYPE_STICK: return AnalogString(index); case SOURCE_TYPE_TRIM: @@ -438,7 +443,7 @@ GeneralSettings::GeneralSettings() calibSpanNeg[i] = 0x180; calibSpanPos[i] = 0x180; } - QSettings settings("companion", "companion"); + QSettings settings; templateSetup = settings.value("default_channel_order", 0).toInt(); stickMode = settings.value("default_mode", 1).toInt(); int profile_id = settings.value("ActiveProfile", 0).toInt(); @@ -659,7 +664,7 @@ ModelData ModelData::removeGlobalVars() QList eepromInterfaces; void RegisterEepromInterfaces() { - QSettings settings("companion", "companion"); + QSettings settings; int rev4a = settings.value("rev4asupport",0).toInt(); eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new Open9xInterface(BOARD_M128)); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index e01e89bd9..1b8ec876f 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -286,19 +286,22 @@ class RawSource { public: RawSource(): type(SOURCE_TYPE_NONE), - index(0) + index(0), + model(NULL) { } - RawSource(int value): + RawSource(int value, const ModelData * model=NULL): type(RawSourceType(abs(value)/65536)), - index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)) + index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)), + model(model) { } - RawSource(RawSourceType type, int index=0): + RawSource(RawSourceType type, int index=0, const ModelData * model=NULL): type(type), - index(index) + index(index), + model(model) { } @@ -322,6 +325,7 @@ class RawSource { RawSourceType type; int index; + const ModelData * model; }; enum RawSwitchType { diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index 9d413654d..72b5acab9 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -44,7 +44,7 @@ const char * Er9xInterface::getName() const int Er9xInterface::getEEpromSize() { - QSettings settings("companion", "companion"); + QSettings settings; QString avrMCU = settings.value("mcu", QString("m64")).toString(); if (avrMCU==QString("m128")) { return 2*EESIZE_STOCK; diff --git a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp index 1115f46f1..3e60d61be 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp @@ -47,7 +47,7 @@ const char * Gruvin9xInterface::getName() const int Gruvin9xInterface::getEEpromSize() { if (board == BOARD_STOCK) { - QSettings settings("companion", "companion"); + QSettings settings; QString avrMCU = settings.value("mcu", QString("m64")).toString(); if (avrMCU==QString("m128")) { return EESIZE_STOCK*2; diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 0fc602e04..8529f78f8 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -593,7 +593,7 @@ enum Functions { #endif FUNC_BACKLIGHT, #if defined(DEBUG) - FUNC_TEST, // should remain the last before MAX as not added in companion9x + FUNC_TEST, // should remain the last before MAX as not added in companion #endif FUNC_MAX }; diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp index 393eff229..b9f5f294e 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp @@ -135,7 +135,7 @@ using namespace Open9xSky9x; Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface): open9xInterface(open9xInterface) { - QSettings settings("companion", "companion"); + QSettings settings; QString path=settings.value("sdPath", ".").toString()+"/"; int i=0; for (i=0; i< std::min(path.length(),1022); i++) { diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 3af9d4a86..f278cbd5b 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -145,7 +145,7 @@ OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface open9xInterface(open9xInterface) { taranisSimulatorBoard = GetEepromInterface()->getBoard(); - QSettings settings("companion", "companion"); + QSettings settings; QString path=settings.value("sdPath", ".").toString()+"/"; int i=0; for (i=0; i< std::min(path.length(),1022); i++) { diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index b4a0294f3..a2bcc4df4 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -42,14 +42,10 @@ size_t SizeOfArray( T(&)[ N ] ) return N; } -QStringList o9xservers; - Open9xInterface::Open9xInterface(BoardEnum board): EEPROMInterface(board), efile(new EFile()) { - o9xservers.clear(); - o9xservers << "93.51.182.154" << "open9x.9xforums.com"; } Open9xInterface::~Open9xInterface() @@ -309,7 +305,7 @@ bool Open9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size) std::cout << " wrong size (" << size << ")\n"; return false; } else { - QMessageBox::warning(NULL,"companion", QObject::tr("Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used")); + QMessageBox::warning(NULL, "companion", QObject::tr("Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used")); size=2048; } } else { @@ -944,14 +940,9 @@ bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esiz QString geturl( int board) { - QString url="http://"; - QSettings settings("companion", "companion"); - int server = settings.value("fwserver", 0).toInt(); - if (server >= o9xservers.count()) { - server = 0; - settings.setValue("fwserver",server); - } - url.append(o9xservers.at(server)); + QSettings settings; + QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); + switch(board) { case BOARD_STOCK: case BOARD_M128: @@ -972,27 +963,21 @@ QString geturl( int board) QString getstamp( int board) { - QString url="http://"; - QSettings settings("companion", "companion"); - int server = settings.value("fwserver",0).toInt(); - if (server >=o9xservers.count()) { - server=0; - settings.setValue("fwserver",server); - } - url.append(o9xservers.at(server)); - url.append("/binaries/stamp-opentx-"); + QSettings settings; + QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); + url.append("/stamp-opentx-"); switch(board) { case BOARD_STOCK: - url.append("stock.txt"); + url.append("9x.txt"); break; case BOARD_M128: - url.append("stock128.txt"); + url.append("9x128.txt"); break; case BOARD_GRUVIN9X: - url.append("v4.txt"); + url.append("gruvin9x.txt"); break; case BOARD_SKY9X: - url.append("arm.txt"); + url.append("sky9x.txt"); break; case BOARD_TARANIS: case BOARD_TARANIS_REV4a: @@ -1007,16 +992,10 @@ QString getstamp( int board) QString getrnurl( int board) { - QString url="http://"; - QSettings settings("companion", "companion"); - int server = settings.value("fwserver",0).toInt(); - if (server >=o9xservers.count()) { - server=0; - settings.setValue("fwserver",server); - } - url.append(o9xservers.at(server)); - url.append("/docs/releasenotes-"); - switch(board) { + QSettings settings; + QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); + url.append("/releasenotes-"); + switch(board) { case BOARD_STOCK: case BOARD_M128: case BOARD_GRUVIN9X: @@ -1043,7 +1022,7 @@ void RegisterOpen9xFirmwares() Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } }; /* 9x board */ - open9x = new Open9xFirmware("opentx-stock", QObject::tr("openTx for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); + open9x = new Open9xFirmware("opentx-9x", QObject::tr("openTx for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1079,7 +1058,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9x board with M128 chip */ - open9x = new Open9xFirmware("opentx-stock128", QObject::tr("openTx for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); + open9x = new Open9xFirmware("opentx-9x128", QObject::tr("openTx for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1175,7 +1154,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* Gruvin9x board */ - open9x = new Open9xFirmware("opentx-v4", QObject::tr("openTx for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); + open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("openTx for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); open9x->setVariantBase(FRSKY_VARIANT); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1239,7 +1218,7 @@ void RegisterOpen9xFirmwares() open9x->addOptions(fai_options); firmwares.push_back(open9x); - QSettings settings("companion", "companion"); + QSettings settings; int rev4a = settings.value("rev4asupport",0).toInt(); if (rev4a) { open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("openTx for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index 82e8c7671..fb7f3df5c 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -18,6 +18,9 @@ #include "eeprominterface.h" +#define OPENTX_COMPANION_DOWNLOADS "http://downloads.open-tx.org/companion" +#define OPENTX_FIRMWARE_DOWNLOADS "http://downloads.open-tx.org/firmware" + class EFile; class Open9xInterface : public EEPROMInterface @@ -91,6 +94,7 @@ class Open9xFirmware: public FirmwareInfo { addLanguage("se"); addLanguage("cz"); addLanguage("es"); + addLanguage("pl"); addLanguage("pt"); addTTSLanguage("en"); @@ -100,6 +104,7 @@ class Open9xFirmware: public FirmwareInfo { addTTSLanguage("se"); addTTSLanguage("cz"); addTTSLanguage("sk"); + addTTSLanguage("pl"); addTTSLanguage("pt"); addTTSLanguage("es"); } diff --git a/companion/src/firmwares/th9x/th9xinterface.cpp b/companion/src/firmwares/th9x/th9xinterface.cpp index bf49284ce..9bd0cbc4a 100644 --- a/companion/src/firmwares/th9x/th9xinterface.cpp +++ b/companion/src/firmwares/th9x/th9xinterface.cpp @@ -44,7 +44,7 @@ const char * Th9xInterface::getName() const int Th9xInterface::getEEpromSize() { - QSettings settings("companion", "companion"); + QSettings settings; QString avrMCU = settings.value("mcu", QString("m64")).toString(); if (avrMCU==QString("m128")) { return 2*EESIZE_STOCK; diff --git a/companion/src/generaledit.cpp b/companion/src/generaledit.cpp index 250fc6b0e..fdff37ae9 100644 --- a/companion/src/generaledit.cpp +++ b/companion/src/generaledit.cpp @@ -20,7 +20,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) : ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); - QSettings settings("companion", "companion"); + QSettings settings; QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); int profile_id=settings.value("profileId", 0).toInt(); @@ -946,7 +946,7 @@ void GeneralEdit::on_PPM4_editingFinished() void GeneralEdit::on_tabWidget_currentChanged(int index) { // TODO why er9x here - QSettings settings("companion", "companion"); + QSettings settings; settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex()); } @@ -1195,7 +1195,7 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int ) void GeneralEdit::on_calretrieve_PB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profile_id); @@ -1312,7 +1312,7 @@ void GeneralEdit::on_calretrieve_PB_clicked() void GeneralEdit::on_calstore_PB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profile_id); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 89eb9961f..d5904a77e 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -399,7 +399,7 @@ void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QS } } -void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode) +void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode) { QStringList qs; b->clear(); @@ -423,18 +423,18 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign b->setCurrentIndex(value); } else if (function==FuncVolume) { - populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS); + populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS); } else if (function==FuncPlayValue) { - populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT); + populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT); } else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) { switch (adjustmode) { case 1: - populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES); + populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES); break; case 2: - populateSourceCB(b, RawSource(value), POPULATE_GVARS); + populateSourceCB(b, RawSource(value), model, POPULATE_GVARS); break; case 3: b->clear(); @@ -998,8 +998,7 @@ void populateGVCB(QComboBox *b, int value) b->setCurrentIndex(nullitem); } - -void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags) +void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & model, unsigned int flags) { RawSource item; @@ -1009,7 +1008,18 @@ void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags) item = RawSource(SOURCE_TYPE_NONE); b->addItem(item.toString(), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); + } + if (flags & POPULATE_VIRTUAL_INPUTS) { + int virtualInputs = GetEepromInterface()->getCapability(VirtualInputs); + for (int i=0; iaddItem(item.toString(), item.toValue()); + if (item == source) b->setCurrentIndex(b->count()-1); + } + } + + if (flags & POPULATE_SOURCES) { for (int i=0; i<4+GetEepromInterface()->getCapability(Pots); i++) { item = RawSource(SOURCE_TYPE_STICK, i); b->addItem(item.toString(), item.toValue()); @@ -1485,19 +1495,10 @@ QString getCenterBeep(ModelData * g_model) return strl.join(", "); } -void populate_icon(QIcon *Icon, QString baseimage) -{ - static QString usedtheme=getTheme(); - Icon->addFile(":/themes/"+usedtheme+"/16/"+baseimage,QSize(16,16)); - Icon->addFile(":/themes/"+usedtheme+"/24/"+baseimage,QSize(24,24)); - Icon->addFile(":/themes/"+usedtheme+"/32/"+baseimage,QSize(32,32)); - Icon->addFile(":/themes/"+usedtheme+"/48/"+baseimage,QSize(48,48)); -} - QString getTheme() { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); + QSettings settings; + int theme_set = settings.value("theme", 1).toInt(); QString Theme; switch(theme_set) { case 0: @@ -1515,3 +1516,13 @@ QString getTheme() } return Theme; } + +CompanionIcon::CompanionIcon(QString baseimage) +{ + static QString theme = getTheme(); + addFile(":/themes/"+theme+"/16/"+baseimage, QSize(16,16)); + addFile(":/themes/"+theme+"/24/"+baseimage, QSize(24,24)); + addFile(":/themes/"+theme+"/32/"+baseimage, QSize(32,32)); + addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48)); +} + diff --git a/companion/src/helpers.h b/companion/src/helpers.h index f2dcbc51e..f62e9b39e 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -28,9 +28,14 @@ void populateVoiceLangCB(QComboBox *b, QString language); void populateTTraceCB(QComboBox *b, int value); void populateRotEncCB(QComboBox *b, int value, int renumber); void populateBacklightCB(QComboBox *b, const uint8_t value); -void populate_icon(QIcon *Icon, QString baseimage); + QString getTheme(); +class CompanionIcon: public QIcon { + public: + CompanionIcon(QString baseimage); +}; + class GVarGroup : public QObject { Q_OBJECT @@ -82,7 +87,7 @@ void populateFuncCB(QComboBox *b, unsigned int value); void populateRepeatCB(QComboBox *b, unsigned int value); void populateGVmodeCB(QComboBox *b, unsigned int value); QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0); -void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0); +void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0); void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList); void populatePhasesCB(QComboBox *b, int value); void populateTrimUseCB(QComboBox *b, unsigned int phase); @@ -93,19 +98,20 @@ QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model); QString getProtocolStr(const int proto); QString getPhasesStr(unsigned int phases, ModelData & model); -#define POPULATE_SOURCES 1 -#define POPULATE_TRIMS 2 -#define POPULATE_SWITCHES 4 -#define POPULATE_GVARS 8 -#define POPULATE_TELEMETRY 16 -#define POPULATE_TELEMETRYEXT 32 +#define POPULATE_SOURCES 1 +#define POPULATE_TRIMS 2 +#define POPULATE_SWITCHES 4 +#define POPULATE_GVARS 8 +#define POPULATE_TELEMETRY 16 +#define POPULATE_TELEMETRYEXT 32 +#define POPULATE_VIRTUAL_INPUTS 64 #define GVARS_VARIANT 0x0001 #define FRSKY_VARIANT 0x0002 // void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up void populateGVCB(QComboBox *b, int value); -void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags); +void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags); void populateCSWCB(QComboBox *b, int value); QString getTimerMode(int tm); QString getTimerModeB(int tm); diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_1.svg b/companion/src/images/originals/logotypes/opentx_logo_red_1.svg new file mode 100644 index 000000000..b2c2df8e4 --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_1.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_2.svg b/companion/src/images/originals/logotypes/opentx_logo_red_2.svg new file mode 100644 index 000000000..265bc774f --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_2.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_3.svg b/companion/src/images/originals/logotypes/opentx_logo_red_3.svg new file mode 100644 index 000000000..ee4af4951 --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_3.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_4.svg b/companion/src/images/originals/logotypes/opentx_logo_red_4.svg new file mode 100644 index 000000000..7f0fed3bb --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_4.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_5.svg b/companion/src/images/originals/logotypes/opentx_logo_red_5.svg new file mode 100644 index 000000000..e54248c71 --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_5.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_6.svg b/companion/src/images/originals/logotypes/opentx_logo_red_6.svg new file mode 100644 index 000000000..ba99f8839 --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_6.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/images/originals/logotypes/opentx_logo_red_7.svg b/companion/src/images/originals/logotypes/opentx_logo_red_7.svg new file mode 100644 index 000000000..ff2880892 --- /dev/null +++ b/companion/src/images/originals/logotypes/opentx_logo_red_7.svg @@ -0,0 +1,239 @@ + +image/svg+xml +O +P +E +N + \ No newline at end of file diff --git a/companion/src/joystickdialog.cpp b/companion/src/joystickdialog.cpp index efec50a56..2c77359a8 100644 --- a/companion/src/joystickdialog.cpp +++ b/companion/src/joystickdialog.cpp @@ -130,7 +130,7 @@ void joystickDialog::on_okButton_clicked() { return; } joystick->close(); - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("JsCalibration"); for (int i=0; i<8;i++) { settings.remove(QString("stick%1_axe").arg(i)); diff --git a/companion/src/lcdwidget.h b/companion/src/lcdwidget.h index 073ba8726..9f01a0b17 100644 --- a/companion/src/lcdwidget.h +++ b/companion/src/lcdwidget.h @@ -58,7 +58,7 @@ class lcdWidget : public QWidget { QPixmap buffer(2*lcdWidth, 2*lcdHeight); QPainter p(&buffer); doPaint(p); - QSettings settings("companion", "companion"); + QSettings settings; bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); QApplication::clipboard()->setPixmap( buffer ); if (!toclipboard) { diff --git a/companion/src/logsdialog.cpp b/companion/src/logsdialog.cpp index d86b2efb3..0c9702239 100644 --- a/companion/src/logsdialog.cpp +++ b/companion/src/logsdialog.cpp @@ -38,7 +38,7 @@ logsDialog::logsDialog(QWidget *parent) : ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setVisible(false); - QSettings settings("companion", "companion"); + QSettings settings; QString Path=settings.value("gePath", "").toString(); if (Path.isEmpty() || !QFile(Path).exists()) { ui->mapsButton->hide(); @@ -202,7 +202,7 @@ void logsDialog::on_mapsButton_clicked() { ,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\ ,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F}; - QSettings settings("companion", "companion"); + QSettings settings; QString gePath=settings.value("gePath", "").toString(); if (gePath.isEmpty() || !QFile(gePath).exists()) { ui->FieldsTW->setDisabled(false); @@ -262,8 +262,8 @@ void logsDialog::on_mapsButton_clicked() { QTextStream outputStream(&geFile); outputStream << "\n\n"; outputStream << "\t\n\t\t" << logFilename << "\n"; - outputStream << "\t\t\n"; - outputStream << "\t\t\n"; + outputStream << "\t\t\n"; + outputStream << "\t\t\n"; outputStream << "\t\t\n\t\t\t\n\t\t\t\tnormal\n\t\t\t\t#multiTrack_n\n\t\t\t\n\t\t\t\n\t\t\t\thighlight\n\t\t\t\t#multiTrack_h\n\t\t\t\n\t\t\n"; outputStream << "\t\t\n"; outputStream << "\t\t\n"; @@ -295,10 +295,13 @@ void logsDialog::on_mapsButton_clicked() { } else { planeName=logFilename; } - outputStream << "\t\t\n\t\t\tLog Data\n\t\t\t\n\t\t\t\t" << planeName << "\n\t\t\t\t#multiTrack\n\t\t\t\t\n"; + outputStream << "\t\t\n\t\t\tLog Data\n\t\t\t\n\t\t\t\t" << planeName << ""; + outputStream << "\n\t\t\t\t#multiTrack"; + outputStream << "\n\t\t\t\t\n"; + outputStream << "\n\t\t\t\t\tabsolute\n"; for (int i=1; ilogTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) { - QString tstamp=csvlog.at(i).at(0)+QString("T")+csvlog.at(i).at(1); + QString tstamp=csvlog.at(i).at(0)+QString("T")+csvlog.at(i).at(1)+QString("Z"); outputStream << "\t\t\t\t\t"<< tstamp <<"\n"; } } @@ -319,7 +322,7 @@ void logsDialog::on_mapsButton_clicked() { } latitude.sprintf("%3.8f", flatitude); longitude.sprintf("%3.8f", flongitude); - outputStream << "\t\t\t\t\t" << longitude << " " << latitude << " " << csvlog.at(i).at(altcol) << "\n" ; + outputStream << "\t\t\t\t\t" << longitude << " " << latitude << " " << csvlog.at(i).at(altcol).toFloat() << " \n" ; } } outputStream << "\t\t\t\t\t\n\t\t\t\t\t\t\n"; @@ -341,10 +344,14 @@ void logsDialog::on_mapsButton_clicked() { outputStream << "\t\t\t\t\t\t\t\n"; } } - outputStream << "\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n"; + outputStream << "\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n"; geFile.close(); - - QStringList parameters; + QStringList parameters; +#ifdef __APPLE__ + gePath = "/usr/bin/open"; + parameters << "-a"; + parameters << "Google\ Earth"; +#endif parameters << geFilename; QProcess *process = new QProcess(this); process->start(gePath, parameters); @@ -578,7 +585,7 @@ void logsDialog::moveLegend() void logsDialog::on_fileOpen_BT_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), settings.value("lastLogDir").toString()); if (!fileName.isEmpty()) { settings.setValue("lastLogDir", fileName); diff --git a/companion/src/main.cpp b/companion/src/main.cpp index 08d738c80..ab2ac2429 100644 --- a/companion/src/main.cpp +++ b/companion/src/main.cpp @@ -76,66 +76,69 @@ class MyProxyStyle : public QProxyStyle int main(int argc, char *argv[]) { - // Start by borrowing any left over settings from companion9x - QSettings c9x_settings("companion9x", "companion9x"); - QSettings com_settings("companion", "companion"); - if (!com_settings.contains("pos")) { - QStringList keys = c9x_settings.allKeys(); - for( QStringList::iterator i = keys.begin(); i != keys.end(); i++ ) - { - com_settings.setValue( *i, c9x_settings.value( *i ) ); - } - } + QCoreApplication::setOrganizationName("OpenTX"); + QCoreApplication::setOrganizationDomain("open-tx.org"); + QCoreApplication::setApplicationName("Companion"); - Q_INIT_RESOURCE(companion); - QApplication app(argc, argv); - app.setApplicationName("OpenTX Companion"); + // Start by borrowing any left over settings from companion9x + QSettings c9x_settings("companion9x", "companion9x"); + QSettings settings; + + if (!settings.contains("pos")) { + QStringList keys = c9x_settings.allKeys(); + for (QStringList::iterator i=keys.begin(); i!=keys.end(); i++) { + settings.setValue(*i, c9x_settings.value(*i)); + } + } + + Q_INIT_RESOURCE(companion); + QApplication app(argc, argv); + app.setApplicationName("OpenTX Companion"); #ifdef __APPLE__ - app.setStyle(new MyProxyStyle); + app.setStyle(new MyProxyStyle); #endif - QString dir; - if(argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang"; - QSettings settings("companion", "companion"); - QString locale = settings.value("locale",QLocale::system().name()).toString(); - bool showSplash = settings.value("show_splash", true).toBool(); + QString dir; + if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang"; - QTranslator companionTranslator; - companionTranslator.load(":/companion_" + locale); - QTranslator qtTranslator; - qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); -// qDebug() << locale; -// qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&companionTranslator); - app.installTranslator(&qtTranslator); + QString locale = settings.value("locale",QLocale::system().name()).toString(); + bool showSplash = settings.value("show_splash", true).toBool(); - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QTranslator companionTranslator; + companionTranslator.load(":/companion_" + locale); + QTranslator qtTranslator; + qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&companionTranslator); + app.installTranslator(&qtTranslator); - QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); - firmware_id.replace("open9x", "opentx"); - firmware_id.replace("x9da", "taranis"); - QPixmap pixmap; - if (firmware_id.contains("taranis")) - pixmap = QPixmap(":/images/splasht.png"); - else - pixmap = QPixmap(":/images/splash.png"); - QSplashScreen *splash = new QSplashScreen(pixmap); + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - RegisterFirmwares(); + QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); + firmware_id.replace("open9x", "opentx"); + firmware_id.replace("x9da", "taranis"); - settings.setValue("firmware", firmware_id); - current_firmware_variant = GetFirmwareVariant(firmware_id); - // qDebug() << current_firmware_variant; + QPixmap pixmap = QPixmap(firmware_id.contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png"); + QSplashScreen *splash = new QSplashScreen(pixmap); - MainWindow mainWin; - - if (showSplash) { - splash->show(); - QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); - QTimer::singleShot(1000*SPLASH_TIME, &mainWin, SLOT(show())); - } - else { - mainWin.show(); - } - return app.exec(); + RegisterFirmwares(); + + settings.setValue("firmware", firmware_id); + current_firmware_variant = GetFirmwareVariant(firmware_id); + + MainWindow *mainWin = new MainWindow(); + if (showSplash) { + splash->show(); + QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); + QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); + } + else { + mainWin->show(); + } + + int result = app.exec(); + + delete splash; + delete mainWin; + + return result; } diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 1268265f1..b26829384 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -62,28 +62,26 @@ #include "helpers.h" #include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include -#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" +#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" + #ifdef __APPLE__ -#define C9X_STAMP "http://companion9x.googlecode.com/svn/trunk/companion9x-macosx.stamp" -#define C9X_INSTALLER "/Companion9xMacUpdate.%1.pkg.zip" -#define C9X_URL "http://companion9x.googlecode.com/files/Companion9xMacUpdate.%1.pkg.zip" + #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-macosx.stamp" + #define C9X_INSTALLER "/CompanionMacUpdate.%1.pkg.zip" #else -#define C9X_STAMP "http://companion9x.googlecode.com/svn/trunk/companion9x.stamp" -#define C9X_INSTALLER "/companion9xInstall_v%1.exe" -#define C9X_URL "http://companion9x.googlecode.com/files/companion9xInstall_v%1.exe" + #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-windows.stamp" + #define C9X_INSTALLER "/companionInstall_%1.exe" #endif #if defined WIN32 || !defined __GNUC__ -#include -#define sleep(x) Sleep(x*1000) + #include + #define sleep(x) Sleep(x*1000) #else -#include -#include "mountlist.h" + #include + #include "mountlist.h" #endif - MainWindow::MainWindow(): -downloadDialog_forWait(NULL) + downloadDialog_forWait(NULL) { mdiArea = new QMdiArea; mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -96,7 +94,7 @@ downloadDialog_forWait(NULL) this, SLOT(setActiveSubWindow(QWidget*))); MaxRecentFiles=MAX_RECENT; - QSettings settings("companion", "companion"); + QSettings settings; int icon_size=settings.value("icon_size", 1).toInt(); switch (icon_size) { case 0: @@ -138,8 +136,9 @@ downloadDialog_forWait(NULL) // give time to the splash to disappear and main window to open before starting updates int updateDelay = 1000; bool showSplash = settings.value("show_splash", true).toBool(); - if (showSplash) - updateDelay += (SPLASH_TIME*1000); + if (showSplash) { + updateDelay += (SPLASH_TIME*1000); + } QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates())); QTimer::singleShot(updateDelay, this, SLOT(displayWarnings())); @@ -189,7 +188,7 @@ downloadDialog_forWait(NULL) void MainWindow::displayWarnings() { - QSettings settings("companion", "companion"); + QSettings settings; int warnId=settings.value("warningId", 0 ).toInt(); if (warnIdstamp; @@ -289,7 +288,7 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply) "Would you like to download it?").arg(version) , QMessageBox::Yes | QMessageBox::No); - QSettings settings("companion", "companion"); + QSettings settings; if (ret == QMessageBox::Yes) { #if defined __APPLE__ @@ -299,14 +298,14 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply) #endif if (!fileName.isEmpty()) { settings.setValue("lastUpdatesDir", QFileInfo(fileName).dir().absolutePath()); - downloadDialog * dd = new downloadDialog(this, QString(C9X_URL).arg(version), fileName); + downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName); installer_fileName = fileName; connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); dd->show(); } } #else - QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available please check the repository")); + QMessageBox::warning(this, tr("New release available"), tr("A new release of Companion is available please check the OpenTX website!")); #endif } else { if (showcheckForUpdatesResult && check1done && check2done) @@ -331,7 +330,7 @@ void MainWindow::updateDownloaded() void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId) { QString url, ext, cpuid; - QSettings settings("companion", "companion"); + QSettings settings; url = firmware->getUrl(firmwareId); cpuid=settings.value("cpuid","").toString(); ext = url.mid(url.lastIndexOf(".")); @@ -354,7 +353,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw void MainWindow::reply1Accepted() { QString errormsg; - QSettings settings("companion", "companion"); + QSettings settings; bool autoflash=settings.value("burnFirmware", true).toBool(); bool addversion=settings.value("rename_firmware_files", false).toBool(); settings.beginGroup("FwRevisions"); @@ -478,7 +477,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply) // TODO delete downloadDialog_forWait? } - QSettings settings("companion", "companion"); + QSettings settings; cpuid=settings.value("cpuid","").toString(); QByteArray qba = reply->readAll(); int i = qba.indexOf("SVN_VERS"); @@ -630,13 +629,14 @@ void MainWindow::reply1Finished(QNetworkReply * reply) void MainWindow::closeEvent(QCloseEvent *event) { - QSettings settings("companion", "companion"); + QSettings settings; settings.setValue("mainWindowGeometry", saveGeometry()); settings.setValue("mainWindowState", saveState()); mdiArea->closeAllSubWindows(); if (mdiArea->currentSubWindow()) { event->ignore(); - } else { + } + else { event->accept(); } } @@ -650,7 +650,7 @@ void MainWindow::newFile() void MainWindow::openFile() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); if (!fileName.isEmpty()) { settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); @@ -683,7 +683,7 @@ void MainWindow::saveAs() void MainWindow::openRecentFile() { - QSettings settings("companion", "companion"); + QSettings settings; QAction *action = qobject_cast(sender()); if (action) { QString fileName=action->data().toString(); @@ -705,14 +705,14 @@ void MainWindow::openRecentFile() void MainWindow::loadProfile() { - QSettings settings("companion", "companion"); + QSettings settings; QAction *action = qobject_cast(sender()); int chord,defmod, burnfw; bool renfw; if (action) { int profnum=action->data().toInt(); - QSettings settings("companion", "companion"); + QSettings settings; settings.setValue("ActiveProfile",profnum); settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profnum); @@ -757,8 +757,8 @@ void MainWindow::unloadProfile() { ActiveProfile=0; ActiveProfileName=""; - QSettings settings("companion", "companion"); - settings.setValue("ActiveProfile",0); + QSettings settings; + settings.setValue("ActiveProfile", 0); FirmwareInfo *firmware = GetCurrentFirmware(); setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); } @@ -770,7 +770,8 @@ void MainWindow::preferences() FirmwareInfo *firmware = GetCurrentFirmware(); if (ActiveProfile) { setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } else { + } + else { setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); } @@ -1080,21 +1081,17 @@ void MainWindow::burnFrom() QStringList str; str << path << tempFile; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); res = ad->exec(); sleep(1); } } else { QStringList str = GetReceiveEEpromCommand(tempFile); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); res = ad->exec(); } - if(QFileInfo(tempFile).exists() && res) { + if (QFileInfo(tempFile).exists() && res) { MdiChild *child = createMdiChild(); child->newFile(); child->loadFile(tempFile, false); @@ -1104,7 +1101,7 @@ void MainWindow::burnFrom() void MainWindow::burnExtenalToEEPROM() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName; bool backup = false; burnDialog *cd = new burnDialog(this, 1, &fileName, &backup); @@ -1141,18 +1138,14 @@ void MainWindow::burnExtenalToEEPROM() QStringList str; str << path << backupFile; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); sleep(1); } } else { QStringList str = GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); sleep(1); } @@ -1162,9 +1155,7 @@ void MainWindow::burnExtenalToEEPROM() QString tempFlash = tempDir + "/flash.bin"; QStringList str = GetReceiveFlashCommand(tempFlash); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); - QIcon icon; - populate_icon(&icon,"read_flash.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_flash.png")); ad->exec(); sleep(1); QString restoreFile = tempDir + "/compat.bin"; @@ -1177,7 +1168,8 @@ void MainWindow::burnExtenalToEEPROM() int rev = getEpromVersion(restoreFile); if ((rev / 100) != (oldrev / 100)) { QMessageBox::warning(this, tr("Warning"), tr("The transmitter firmware belongs to another product family, check file and preferences!")); - } else if (rev < oldrev) { + } + else if (rev < oldrev) { QMessageBox::warning(this, tr("Warning"), tr("The transmitter firmware is outdated, please upgrade!")); } fileName = restoreFile; @@ -1197,19 +1189,18 @@ void MainWindow::burnExtenalToEEPROM() QStringList str; str << path << backupFile; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } - } else { + } + else { QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } } @@ -1219,23 +1210,23 @@ void MainWindow::burnExtenalToEEPROM() if (path.isEmpty()) { QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected.")); return; - } else { + } + else { QStringList str; str << fileName << path; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write Models and Settings To Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } - } else { + } + else { QStringList str = GetSendEEpromCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Write Models and Settings To Tx", AVR_DIALOG_SHOW_DONE); - QIcon icon; - populate_icon(&icon,"write_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("write_eeprom.png")); ad->exec(); + delete ad; } } } @@ -1327,7 +1318,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString } else { version = fwBuild.toInt(); // TODO changer le nom de la variable } - } else { + } + else { version = ((Open9xFirmware *)firmware)->getEepromVersion(revision); } } @@ -1344,11 +1336,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString long result = file.read((char*)eeprom, eeprom_size); file.close(); - RadioData radioData; - if (!LoadEeprom(radioData, eeprom, eeprom_size)) - return false; - - if (!firmware->saveEEPROM(eeprom, radioData, variant, version)) + QSharedPointer radioData = QSharedPointer(new RadioData()); + if (!LoadEeprom(*radioData, eeprom, eeprom_size) || !firmware->saveEEPROM(eeprom, *radioData, variant, version)) return false; QFile file2(restoreFile); @@ -1366,7 +1355,7 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString void MainWindow::burnToFlash(QString fileToFlash) { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName; bool backup = settings.value("backupOnFlash", false).toBool(); if(!fileToFlash.isEmpty()) @@ -1399,18 +1388,17 @@ void MainWindow::burnToFlash(QString fileToFlash) } QStringList str = GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); int res = ad->exec(); + delete ad; if (QFileInfo(backupFile).exists() && res) { sleep(1); QStringList str = GetSendFlashCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); - QIcon iconw; - populate_icon(&iconw,"write_eeprom.png"); + CompanionIcon iconw("write_eeprom.png"); ad->setWindowIcon(iconw); int res = ad->exec(); + delete ad; if (res) { QString restoreFile = tempDir + "/restore.bin"; if (!convertEEPROM(backupFile, restoreFile, fileName)) { @@ -1421,17 +1409,21 @@ void MainWindow::burnToFlash(QString fileToFlash) QStringList str = GetSendEEpromCommand(restoreFile); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Restore Models and Settings To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); ad->setWindowIcon(iconw); - res=ad->exec(); + res = ad->exec(); + delete ad; if (!res) { QMessageBox::warning(this, tr("Restore failed"), tr("Could not restore Models and Settings to TX. The models and settings data file can be found at: %1").arg(backupFile)); } - } else { + } + else { QMessageBox::warning(this, tr("Firmware write failed"), tr("Could not write firmware to to transmitter. The models and settings data file can be found at: %1").arg(backupFile)); } - } else { + } + else { QMessageBox::warning(this, tr("Backup failed"), tr("Cannot backup existing Models and Settings from TX. Firmware write process aborted")); } - } else { + } + else { bool backupEnable=settings.value("backupEnable", true).toBool(); QString backupPath=settings.value("backupPath", "").toString(); if (!QDir(backupPath).exists()) { @@ -1445,26 +1437,24 @@ void MainWindow::burnToFlash(QString fileToFlash) QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin"; QStringList str = GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } QStringList str = GetSendFlashCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_SHOW_DONE); - QIcon iconw; - populate_icon(&iconw,"write_flash.png"); - ad->setWindowIcon(iconw); + ad->setWindowIcon(CompanionIcon("write_flash.png")); ad->exec(); + delete ad; } } } void MainWindow::burnExtenalFromEEPROM() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER)); if (!fileName.isEmpty()) { EEPROMInterface *eepromInterface = GetEepromInterface(); @@ -1473,30 +1463,30 @@ void MainWindow::burnExtenalFromEEPROM() if (path.isEmpty()) { QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify that the eeprom disk is connected.")); return; - } else { + } + else { QStringList str; str << path << fileName; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; } - } else { + } + else { settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); QStringList str = GetReceiveEEpromCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); - QIcon icon; - populate_icon(&icon,"read_eeprom.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; } } } void MainWindow::burnFromFlash() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), settings.value("lastFlashDir").toString(),tr(FLASH_FILES_FILTER)); if (!fileName.isEmpty()) { QFile file(fileName); @@ -1506,12 +1496,10 @@ void MainWindow::burnFromFlash() settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath()); QStringList str = GetReceiveFlashCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); - QIcon icon; - populate_icon(&icon,"read_flash.png"); - ad->setWindowIcon(icon); + ad->setWindowIcon(CompanionIcon("read_flash.png")); ad->exec(); + delete ad; } - } void MainWindow::burnConfig() @@ -1546,16 +1534,17 @@ void MainWindow::logFile() void MainWindow::about() { - QString aboutStr = "

"; - aboutStr.append("OpenTX Home Page: http://open-tx.org

"); - aboutStr.append(tr("The Companion project was originally forked from eePe")+QString(" http://code.google.com/p/eepe

")); - aboutStr.append(tr("If you've found this program useful, please support by")); - aboutStr.append(" "); - aboutStr.append(tr("donating") + "

"); - aboutStr.append(tr("Version %1 (revision %2), %3").arg(C9X_VERSION).arg(C9X_REVISION).arg(__DATE__)+QString("

")); - aboutStr.append(tr("Copyright") +" Bertrand Songis & Romolo Manfredini © 2011- 2014
"); - - QMessageBox::about(this, tr("About Companion"),aboutStr); + QString aboutStr = "

"; + aboutStr.append(tr("OpenTX Home Page: %1").arg("http://www.open-tx.org")); + aboutStr.append("

"); + aboutStr.append(tr("The OpenTX Companion project was originally forked from eePe").arg("http://code.google.com/p/eepe")); + aboutStr.append("

"); + aboutStr.append(tr("If you've found this program useful, please support by donating").arg(DONATE_STR)); + aboutStr.append("

"); + aboutStr.append(tr("Version %1, %3").arg(C9X_VERSION).arg(__DATE__)); + aboutStr.append("

"); + aboutStr.append(tr("Copyright") + " Bertrand Songis & Romolo Manfredini
© 2011-2014
"); + QMessageBox::about(this, tr("About Companion"), aboutStr); } void MainWindow::updateMenus() @@ -1584,7 +1573,7 @@ void MainWindow::updateMenus() updateRecentFileActions(); updateProfilesActions(); bool notfound=true; - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("Profiles"); for (int i=0; isetShortcuts(QKeySequence::New); newAct->setStatusTip(tr("Create a new file")); connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); - QIcon openActIcon; - populate_icon(&openActIcon,"open.png"); - openAct = new QAction(openActIcon, tr("&Open..."), this); + openAct = new QAction(CompanionIcon("open.png"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); connect(openAct, SIGNAL(triggered()), this, SLOT(openFile())); - loadbackupAct = new QAction(openActIcon, tr("&loadBackup..."), this); + loadbackupAct = new QAction(CompanionIcon("open.png"), tr("&loadBackup..."), this); loadbackupAct->setStatusTip(tr("Load backup from file")); connect(loadbackupAct, SIGNAL(triggered()), this, SLOT(loadBackup())); - QIcon saveActIcon; - populate_icon(&saveActIcon,"save.png"); - saveAct = new QAction(saveActIcon, tr("&Save"), this); + saveAct = new QAction(CompanionIcon("save.png"), tr("&Save"), this); saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the document to disk")); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); - QIcon saveAsActIcon; - populate_icon(&saveAsActIcon,"saveas.png"); - saveAsAct = new QAction(saveAsActIcon, tr("Save &As..."), this); + saveAsAct = new QAction(CompanionIcon("saveas.png"), tr("Save &As..."), this); saveAsAct->setShortcuts(QKeySequence::SaveAs); saveAsAct->setStatusTip(tr("Save the document under a new name")); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); - QIcon logsActIcon; - populate_icon(&logsActIcon,"logs.png"); - logsAct = new QAction(logsActIcon, tr("Lo&gs"), this); + logsAct = new QAction(CompanionIcon("logs.png"), tr("Lo&gs"), this); logsAct->setShortcut(tr("Ctrl+G")); logsAct->setStatusTip(tr("Open log file")); connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile())); - QIcon preferencesActIcon; - populate_icon(&preferencesActIcon,"preferences.png"); - preferencesAct = new QAction(preferencesActIcon, tr("&Preferences..."), this); + preferencesAct = new QAction(CompanionIcon("preferences.png"), tr("&Preferences..."), this); preferencesAct->setStatusTip(tr("Edit general preferences")); connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences())); - QIcon checkForUpdatesActIcon; - populate_icon(&checkForUpdatesActIcon,"update.png"); - checkForUpdatesAct = new QAction(checkForUpdatesActIcon, tr("&Check for updates..."), this); + checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this); checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion")); connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates())); - QIcon contributorsActIcon; - populate_icon(&contributorsActIcon,"contributors.png"); - contributorsAct = new QAction(contributorsActIcon, tr("Contributors &List..."), this); + contributorsAct = new QAction(CompanionIcon("contributors.png"), tr("Contributors &List..."), this); contributorsAct->setStatusTip(tr("Show Companion contributors list")); connect(contributorsAct, SIGNAL(triggered()), this, SLOT(contributors())); - QIcon changelogActIcon; - populate_icon(&changelogActIcon,"changelog.png"); - changelogAct = new QAction(changelogActIcon, tr("ChangeLog..."), this); + changelogAct = new QAction(CompanionIcon("changelog.png"), tr("ChangeLog..."), this); changelogAct->setStatusTip(tr("Show Companion changelog")); connect(changelogAct, SIGNAL(triggered()), this, SLOT(changelog())); - QIcon fwchangelogActIcon; - populate_icon(&fwchangelogActIcon,"changelog.png"); - fwchangelogAct = new QAction(fwchangelogActIcon, tr("Firmware ChangeLog..."), this); + fwchangelogAct = new QAction(CompanionIcon("changelog.png"), tr("Firmware ChangeLog..."), this); fwchangelogAct->setStatusTip(tr("Show firmware changelog")); connect(fwchangelogAct, SIGNAL(triggered()), this, SLOT(fwchangelog())); - QIcon compareActIcon; - populate_icon(&compareActIcon,"compare.png"); - compareAct = new QAction(compareActIcon, tr("Compare..."), this); + compareAct = new QAction(CompanionIcon("customize.png"), tr("Compare..."), this); compareAct->setStatusTip(tr("Compare models")); compareAct->setEnabled(false); connect(compareAct, SIGNAL(triggered()), this, SLOT(compare())); - QIcon customizeSplashActIcon; - populate_icon(&customizeSplashActIcon,"customize.png"); - customizeSplashAct = new QAction(customizeSplashActIcon, tr("Customize your &TX..."), this); + customizeSplashAct = new QAction(CompanionIcon("customize.png"), tr("Customize your &TX..."), this); customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX")); connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash())); - -//! [0] - QIcon exitActIcon; - populate_icon(&exitActIcon,"exit.png"); - exitAct = new QAction(exitActIcon, tr("E&xit"), this); + exitAct = new QAction(CompanionIcon("exit.png"), tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); -//! [0] - QIcon cutActIcon; - populate_icon(&cutActIcon,"cut.png"); - cutAct = new QAction(cutActIcon, tr("Cu&t"), this); + cutAct = new QAction(CompanionIcon("cut.png"), tr("Cu&t"), this); cutAct->setShortcuts(QKeySequence::Cut); cutAct->setStatusTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), this, SLOT(cut())); - QIcon copyActIcon; - populate_icon(©ActIcon,"copy.png"); - copyAct = new QAction(copyActIcon, tr("&Copy"), this); + copyAct = new QAction(CompanionIcon("copy.png"), tr("&Copy"), this); copyAct->setShortcuts(QKeySequence::Copy); copyAct->setStatusTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), this, SLOT(copy())); - QIcon pasteActIcon; - populate_icon(&pasteActIcon,"paste.png"); - pasteAct = new QAction(pasteActIcon, tr("&Paste"), this); + pasteAct = new QAction(CompanionIcon("paste.png"), tr("&Paste"), this); pasteAct->setShortcuts(QKeySequence::Paste); pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste())); - QIcon burnToActIcon; - populate_icon(&burnToActIcon,"write_eeprom.png"); - burnToAct = new QAction(burnToActIcon, tr("&Write Models and Settings To Tx"), this); + burnToAct = new QAction(CompanionIcon("write_eeprom.png"), tr("&Write Models and Settings To Tx"), this); burnToAct->setShortcut(tr("Ctrl+Alt+W")); burnToAct->setStatusTip(tr("Write Models and Settings to transmitter")); connect(burnToAct,SIGNAL(triggered()),this,SLOT(burnTo())); - QIcon burnFromActIcon; - populate_icon(&burnFromActIcon,"read_eeprom.png"); - burnFromAct = new QAction(burnFromActIcon, tr("&Read Models and Settings From Tx"), this); + burnFromAct = new QAction(CompanionIcon("read_eeprom.png"), tr("&Read Models and Settings From Tx"), this); burnFromAct->setShortcut(tr("Ctrl+Alt+R")); burnFromAct->setStatusTip(tr("Read Models and Settings from transmitter")); connect(burnFromAct,SIGNAL(triggered()),this,SLOT(burnFrom())); - QIcon burnToFlashActIcon; - populate_icon(&burnToFlashActIcon,"write_flash.png"); - burnToFlashAct = new QAction(burnToFlashActIcon, tr("Write Firmware"), this); + burnToFlashAct = new QAction(CompanionIcon("write_flash.png"), tr("Write Firmware"), this); burnToFlashAct->setStatusTip(tr("Write firmware to transmitter")); connect(burnToFlashAct,SIGNAL(triggered()),this,SLOT(burnToFlash())); - QIcon burnExtenalToEEPROMActIcon; - populate_icon(&burnExtenalToEEPROMActIcon,"write_eeprom_file.png"); - burnExtenalToEEPROMAct = new QAction(burnExtenalToEEPROMActIcon, tr("Write Models and Settings from file to Tx"), this); + burnExtenalToEEPROMAct = new QAction(CompanionIcon("write_eeprom_file.png"), tr("Write Models and Settings from file to Tx"), this); burnExtenalToEEPROMAct->setStatusTip(tr("Write Models and Settings from file to transmitter")); connect(burnExtenalToEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalToEEPROM())); - QIcon burnExtenalFromEEPROMActIcon; - populate_icon(&burnExtenalFromEEPROMActIcon,"read_eeprom_file.png"); - burnExtenalFromEEPROMAct = new QAction(burnExtenalFromEEPROMActIcon, tr("Save transmitter Models and Settings to file"), this); + burnExtenalFromEEPROMAct = new QAction(CompanionIcon("read_eeprom_file.png"), tr("Save transmitter Models and Settings to file"), this); burnExtenalFromEEPROMAct->setStatusTip(tr("Save the Models and Settings from the transmitter to a file")); connect(burnExtenalFromEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalFromEEPROM())); - QIcon burnFromFlashActIcon; - populate_icon(&burnFromFlashActIcon,"read_flash.png"); - burnFromFlashAct = new QAction(burnFromFlashActIcon, tr("Read Firmware"), this); + burnFromFlashAct = new QAction(CompanionIcon("read_flash.png"), tr("Read Firmware"), this); burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter")); connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash())); - QIcon burnConfigActIcon; - populate_icon(&burnConfigActIcon,"configure.png"); - burnConfigAct = new QAction(burnConfigActIcon, tr("&Configure..."), this); + burnConfigAct = new QAction(CompanionIcon("configure.png"), tr("&Configure..."), this); burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter")); connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig())); EEPROMInterface *eepromInterface = GetEepromInterface(); if (!IS_ARM(eepromInterface->getBoard())) { - QIcon burnListActIcon; - populate_icon(&burnListActIcon,"list.png"); - burnListAct = new QAction(burnListActIcon, tr("&List programmers"), this); + burnListAct = new QAction(CompanionIcon("list.png"), tr("&List programmers"), this); burnListAct->setStatusTip(tr("List available programmers")); connect(burnListAct,SIGNAL(triggered()),this,SLOT(burnList())); - QIcon burnFusesActIcon; - populate_icon(&burnFusesActIcon,"fuses.png"); - burnFusesAct = new QAction(burnFusesActIcon, tr("&Fuses..."), this); + burnFusesAct = new QAction(CompanionIcon("fuses.png"), tr("&Fuses..."), this); burnFusesAct->setStatusTip(tr("Show fuses dialog")); connect(burnFusesAct,SIGNAL(triggered()),this,SLOT(burnFuses())); } - QIcon simulateActIcon; - populate_icon(&simulateActIcon,"simulate.png"); - simulateAct = new QAction(simulateActIcon, tr("&Simulate"), this); + + simulateAct = new QAction(CompanionIcon("simulate.png"), tr("&Simulate"), this); simulateAct->setShortcut(tr("Alt+S")); simulateAct->setStatusTip(tr("Simulate selected model.")); simulateAct->setEnabled(false); connect(simulateAct,SIGNAL(triggered()),this,SLOT(simulate())); - QIcon printActIcon; - populate_icon(&printActIcon,"print.png"); - printAct = new QAction(printActIcon, tr("&Print"), this); + printAct = new QAction(CompanionIcon("print.png"), tr("&Print"), this); printAct->setShortcut(tr("Ctrl+P")); printAct->setStatusTip(tr("Print current model.")); printAct->setEnabled(false); @@ -1872,15 +1804,11 @@ void MainWindow::createActions() separatorAct = new QAction(this); separatorAct->setSeparator(true); - QIcon aboutActIcon; - populate_icon(&aboutActIcon,"information.png"); - aboutAct = new QAction(aboutActIcon, tr("&About"), this); + aboutAct = new QAction(CompanionIcon("information.png"), tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - QIcon switchLayoutDirectionActIcon; - populate_icon(&switchLayoutDirectionActIcon,"switch_dir.png"); - switchLayoutDirectionAct = new QAction(switchLayoutDirectionActIcon, tr("Switch layout direction"), this); + switchLayoutDirectionAct = new QAction(CompanionIcon("switch_dir.png"), tr("Switch layout direction"), this); switchLayoutDirectionAct->setStatusTip(tr("Switch layout Left/Right")); connect(switchLayoutDirectionAct, SIGNAL(triggered()), this, SLOT(switchLayoutDirection())); for (int i = 0; i < MaxRecentFiles; ++i) { @@ -1910,10 +1838,8 @@ void MainWindow::createMenus() fileMenu->addAction(saveAct); fileMenu->addAction(saveAsAct); fileMenu->addMenu(recentFileMenu); - QIcon recentFileMenuIcon; - populate_icon(&recentFileMenuIcon,"recentdocument.png"); - recentFileMenu->setIcon(recentFileMenuIcon); - for ( int i = 0; i < MaxRecentFiles; ++i) + recentFileMenu->setIcon(CompanionIcon("recentdocument.png")); + for (int i=0; iaddAction(recentFileActs[i]); fileMenu->addSeparator(); fileMenu->addAction(logsAct); @@ -1925,10 +1851,8 @@ void MainWindow::createMenus() fileMenu->addAction(preferencesAct); fileMenu->addMenu(profilesMenu); - QIcon profilesMenuIcon; - populate_icon(&profilesMenuIcon,"profiles.png"); - profilesMenu->setIcon(profilesMenuIcon); - for ( int i = 0; i < MAX_PROFILES; ++i) + profilesMenu->setIcon(CompanionIcon("profiles.png")); + for (int i=0; iaddAction(profileActs[i]); fileMenu->addAction(switchLayoutDirectionAct); fileMenu->addAction(exitAct); @@ -1992,7 +1916,7 @@ QMenu *MainWindow::createProfilesMenu() void MainWindow::createToolBars() { - QSettings settings("companion", "companion"); + QSettings settings; int icon_size=settings.value("icon_size",2 ).toInt(); QSize size; switch(icon_size) { @@ -2017,9 +1941,7 @@ void MainWindow::createToolBars() QToolButton * recentToolButton = new QToolButton; recentToolButton->setPopupMode(QToolButton::InstantPopup); recentToolButton->setMenu(createRecentFileMenu()); - QIcon recentToolButtonIcon; - populate_icon(&recentToolButtonIcon,"recentdocument.png"); - recentToolButton->setIcon(recentToolButtonIcon); + recentToolButton->setIcon(CompanionIcon("recentdocument.png")); recentToolButton->setToolTip(tr("Recent Files")); fileToolBar->addWidget(recentToolButton); fileToolBar->addAction(saveAct); @@ -2029,9 +1951,7 @@ void MainWindow::createToolBars() profileButton = new QToolButton; profileButton->setPopupMode(QToolButton::InstantPopup); profileButton->setMenu(createProfilesMenu()); - QIcon profileButtonIcon; - populate_icon(&profileButtonIcon,"profiles.png"); - profileButton->setIcon(profileButtonIcon); + profileButton->setIcon(CompanionIcon("profiles.png")); profileButton->setToolTip(tr("Firmware Profiles")); fileToolBar->addWidget(profileButton); bool notfound=true; @@ -2088,7 +2008,7 @@ void MainWindow::createStatusBar() void MainWindow::readSettings() { - QSettings settings("companion", "companion"); + QSettings settings; restoreState(settings.value("mainWindowState").toByteArray()); checkCompanion9x = settings.value("startup_check_companion", true).toBool(); checkFW = settings.value("startup_check_fw", true).toBool(); @@ -2141,7 +2061,7 @@ void MainWindow::setActiveSubWindow(QWidget *window) void MainWindow::updateRecentFileActions() { int i,j, numRecentFiles; - QSettings settings("companion", "companion"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); @@ -2161,7 +2081,7 @@ void MainWindow::updateRecentFileActions() void MainWindow::updateProfilesActions() { int i; - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("Profiles"); for (i=0; isetupUi(this); - ui->SimulateTxButton->setIcon(SimulateIcon); + ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png")); setAttribute(Qt::WA_DeleteOnClose); eepromInterfaceChanged(); @@ -182,7 +179,7 @@ void MdiChild::OpenEditWindow(bool wizard=false) } if (isNew && !wizard) { int ret; - QSettings settings("companion", "companion"); + QSettings settings; bool wizardEnable=settings.value("wizardEnable", true).toBool(); if (wizardEnable) { ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); @@ -349,7 +346,7 @@ bool MdiChild::save() bool MdiChild::saveAs(bool isNew) { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName; if (GetEepromInterface()->getBoard() == BOARD_SKY9X) { curFile.replace(".eepe", ".bin"); @@ -493,7 +490,7 @@ void MdiChild::setCurrentFile(const QString &fileName) fileChanged = false; setWindowModified(false); updateTitle(); - QSettings settings("companion", "companion"); + QSettings settings; int MaxRecentFiles =settings.value("history_size",10).toInt(); QStringList files = settings.value("recentFileList").toStringList(); files.removeAll(fileName); @@ -511,7 +508,7 @@ QString MdiChild::strippedName(const QString &fullFileName) void MdiChild::burnTo() // write to Tx { - QSettings settings("companion", "companion"); + QSettings settings; bool backupEnable=settings.value("backupEnable", true).toBool(); QString backupPath=settings.value("backupPath", "").toString(); if (!backupPath.isEmpty()) { @@ -556,19 +553,17 @@ void MdiChild::burnTo() // write to Tx QStringList str; str << path << backupFile; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup EEPROM From Tx")); //, AVR_DIALOG_KEEP_OPEN); - QIcon Icon; - populate_icon(&Icon,"read_eeprom.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); sleep(1); } - } else { + } + else { QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx")); - QIcon Icon; - populate_icon(&Icon,"read_eeprom.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } } @@ -576,10 +571,9 @@ void MdiChild::burnTo() // write to Tx QString tempFlash=tempDir + "/flash.bin"; QStringList str = ((MainWindow *)this->parent())->GetReceiveFlashCommand(tempFlash); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, "Read Flash From Tx"); - QIcon Icon; - populate_icon(&Icon,"read_flash.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("read_flash.png")); ad->exec(); + delete ad; sleep(1); QString restoreFile = tempDir + "/compat.bin"; if (!((MainWindow *)this->parent())->convertEEPROM(tempFile, restoreFile, tempFlash)) { @@ -587,7 +581,8 @@ void MdiChild::burnTo() // write to Tx QMessageBox::Yes | QMessageBox::No); if (ret==QMessageBox::No) return; - } else { + } + else { int rev=((MainWindow *)this->parent())->getEpromVersion(restoreFile); if ((rev/100)!=(oldrev/100)) { QMessageBox::warning(this,tr("Warning"), tr("Firmware in radio is of a different family of eeprom written, check file and preferences!")); @@ -600,7 +595,8 @@ void MdiChild::burnTo() // write to Tx QByteArray ba = tempFlash.toLatin1(); char *name = ba.data(); unlink(name); - } else { + } + else { if (backupEnable) { QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin"; if (IS_TARANIS(eepromInterface->getBoard())) { @@ -608,16 +604,17 @@ void MdiChild::burnTo() // write to Tx if (path.isEmpty()) { QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected.")); return; - } else { + } + else { QFile::copy(path,backupFile); } - } else { + } + else { QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx")); - QIcon Icon; - populate_icon(&Icon,"read_eeprom.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->exec(); + delete ad; sleep(1); } } @@ -627,23 +624,23 @@ void MdiChild::burnTo() // write to Tx if (path.isEmpty()) { QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected.")); return; - } else { + } + else { QStringList str; str << tempFile << path; avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write EEPROM To Tx"), AVR_DIALOG_SHOW_DONE); //, AVR_DIALOG_KEEP_OPEN); - QIcon Icon; - populate_icon(&Icon,"read_eeprom.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->show(); + delete ad; sleep(1); } - } else { + } + else { QStringList str = ((MainWindow *)this->parent())->GetSendEEpromCommand(tempFile); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, "Write EEPROM To Tx", AVR_DIALOG_SHOW_DONE); - QIcon Icon; - populate_icon(&Icon,"write_eeprom.png"); - ad->setWindowIcon(Icon); + ad->setWindowIcon(CompanionIcon("write_eeprom.png")); ad->show(); + delete ad; } } } @@ -693,7 +690,7 @@ void MdiChild::setEEpromAvail(int eavail) bool MdiChild::loadBackup() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); if (fileName.isEmpty()) return false; diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index 5f90ebfdb..612ca60d9 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -84,8 +84,6 @@ Curves::Curves(QWidget * parent, ModelData & model): QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview); scene->setItemIndexMethod(QGraphicsScene::NoIndex); ui->curvePreview->setScene(scene); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); for (int i=0; igetCapability(NumCurves); i++) { visibleCurves[i] = false; @@ -94,7 +92,7 @@ Curves::Curves(QWidget * parent, ModelData & model): QPushButton * reset = new QPushButton(this); reset->setProperty("index", i); reset->setMinimumSize(QSize(0, 0)); - reset->setIcon(ClearIcon); + reset->setIcon(CompanionIcon("clear.png")); reset->setIconSize(QSize(14, 14)); connect(reset, SIGNAL(clicked()), this, SLOT(resetCurve())); ui->curvesLayout->addWidget(reset, i, 0, 1, 1); @@ -600,9 +598,9 @@ void ModelEdit::on_ca_apply_PB_clicked() void ModelEdit::clearCurves(bool ask) { - if(ask) { - int res = QMessageBox::question(this,tr("Clear Curves?"),tr("Really clear all the curves?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; + if (ask) { + int res = QMessageBox::question(this, tr("Clear Curves?"), tr("Really clear all the curves?"), QMessageBox::Yes | QMessageBox::No); + if (res!=QMessageBox::Yes) return; } curvesLock=true; for (int j=0; j<16; j++) { diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 8345f4306..0dc818581 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -36,7 +36,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, } } - QSettings settings("companion", "companion"); + QSettings settings; QString path = settings.value("sdPath", ".").toString(); path.append("/SOUNDS/"); QString lang = generalSettings.ttsLanguage; @@ -110,7 +110,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, fswtchParamT[i] = new QComboBox(this); fswtchParamT[i]->setProperty("index", i); paramLayout->addWidget(fswtchParamT[i]); - populateFuncParamCB(fswtchParamT[i], func, model.funcSw[i].param, model.funcSw[i].adjustMode); + populateFuncParamCB(fswtchParamT[i], model, func, model.funcSw[i].param, model.funcSw[i].adjustMode); connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); fswtchParamArmT[i] = new QComboBox(this); @@ -123,11 +123,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); #ifdef PHONON - QIcon PlayIcon; - populate_icon(&PlayIcon,"play.png"); playBT[i] = new QPushButton(this); playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(PlayIcon); + playBT[i]->setIcon(CompanionIcon("play.png")); paramLayout->addWidget(playBT[i]); connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic())); #endif @@ -162,8 +160,6 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta { if (phononLock) return; - QIcon PlayIcon; - populate_icon(&PlayIcon,"play.png"); phononLock=true; if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) { @@ -172,7 +168,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta clickObject->clear(); for (int i=0; igetCapability(CustomFunctions); i++) { playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(PlayIcon); + playBT[i]->setIcon(CompanionIcon("play.png")); } } if (newState==Phonon::ErrorState) { @@ -181,7 +177,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta clickObject->clear(); for (int i=0; igetCapability(CustomFunctions); i++) { playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(PlayIcon); + playBT[i]->setIcon(CompanionIcon("play.png")); } } @@ -194,19 +190,15 @@ void CustomFunctionsPanel::playMusic() QPushButton *playButton = qobject_cast(sender()); int index=playButton->objectName().mid(5,2).toInt(); QString function=playButton->objectName().left(4); - QSettings settings("companion", "companion"); - QIcon PlayIcon; - populate_icon(&PlayIcon,"play.png"); - QIcon StopIcon; - populate_icon(&StopIcon,"stop.png"); - - QString path=settings.value("sdPath", ".").toString(); + QSettings settings; + QString path = settings.value("sdPath", ".").toString(); QDir qd(path); QString track; if (qd.exists()) { if (GetEepromInterface()->getCapability(VoicesAsNumbers)) { track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0'); - } else { + } + else { path.append("/SOUNDS/"); QString lang = generalSettings.ttsLanguage; if (lang.isEmpty()) @@ -227,12 +219,12 @@ void CustomFunctionsPanel::playMusic() clickObject->setCurrentSource(Phonon::MediaSource(track)); clickObject->play(); playBT[index]->setObjectName(QString("stop_%1").arg(index)); - playBT[index]->setIcon(StopIcon); + playBT[index]->setIcon(CompanionIcon("stop.png")); } else { clickObject->stop(); clickObject->clear(); playBT[index]->setObjectName(QString("play_%1").arg(index)); - playBT[index]->setIcon(PlayIcon); + playBT[index]->setIcon(CompanionIcon("play.png")); } #endif } @@ -266,7 +258,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) if (modified) { model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex(); - model.funcSw[i].enabled =fswtchEnable[i]->isChecked(); + model.funcSw[i].enabled = fswtchEnable[i]->isChecked(); model.funcSw[i].repeatParam = (AssignFunc)fswtchRepeat[i]->currentIndex(); model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } @@ -283,14 +275,15 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) } fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; - } else if (index==FuncLogs) { + } + else if (index==FuncLogs) { fswtchParam[i]->setDecimals(1); fswtchParam[i]->setMinimum(0); fswtchParam[i]->setMaximum(25.5); fswtchParam[i]->setSingleStep(0.1); if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0; fswtchParam[i]->setValue(model.funcSw[i].param/10.0); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) { if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex(); @@ -303,20 +296,24 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) fswtchParam[i]->setMaximum(125); fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; - } else { + } + else { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param, model.funcSw[i].adjustMode); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param, model.funcSw[i].adjustMode); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } - } else if (index==FuncReset) { + } + else if (index==FuncReset) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } else if (index==FuncVolume) { + } + else if (index==FuncVolume) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE; - } else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { + } + else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (modified) model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt(); if (index != FuncBackgroundMusic) { if (GetEepromInterface()->getCapability(HasFuncRepeat)) { @@ -325,16 +322,18 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) } if (index==FuncPlayValue) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; - } else if (index==FuncPlayPrompt || index==FuncPlayBoth) { + } + else if (index==FuncPlayPrompt || index==FuncPlayBoth) { if (GetEepromInterface()->getCapability(VoicesAsNumbers)) { fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(0); if (index==FuncPlayPrompt) { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE; - } else { + } + else { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT; fswtchParamGV[i]->setChecked(false); } @@ -343,7 +342,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) if (fswtchParamGV[i]->isChecked()) { fswtchParam[i]->setMinimum(1); model.funcSw[i].param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); - } else { + } + else { model.funcSw[i].param = fswtchParam[i]->value(); } } @@ -351,13 +351,15 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) fswtchParamGV[i]->setChecked(true); fswtchParam[i]->setValue(model.funcSw[i].param-250); fswtchParam[i]->setMaximum(5); - } else { + } + else { fswtchParamGV[i]->setChecked(false); fswtchParam[i]->setValue(model.funcSw[i].param); } if (model.funcSw[i].param < 251) widgetsMask |= CUSTOM_FUNCTION_PLAY; - } else { + } + else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); @@ -370,7 +372,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) } } } - } else if (index==FuncBackgroundMusic) { + } + else if (index==FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); @@ -382,21 +385,24 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) } } } - } else if (index==FuncPlaySound) { + } + else if (index==FuncPlaySound) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } else if (index==FuncPlayHaptic) { - if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } - } else if (model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { + else if (index==FuncPlayHaptic) { + if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); + populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + } + } + else { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setValue(model.funcSw[i].param); - if (index<=FuncInstantTrim) { + if (index <= FuncInstantTrim) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } } @@ -467,14 +473,6 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedFunction = label->property("index").toInt(); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - QIcon CopyIcon; - populate_icon(&CopyIcon,"copy.png"); - QIcon CutIcon; - populate_icon(&CutIcon,"cut.png"); - QIcon PasteIcon; - populate_icon(&PasteIcon,"paste.png"); QPoint globalPos = label->mapToGlobal(pos); @@ -483,10 +481,10 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) bool hasData = mimeData->hasFormat("application/x-companion-fsw"); QMenu contextMenu; - contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(fswDelete()),tr("Delete")); - contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C")); - contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X")); - contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete")); + contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C")); + contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X")); + contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.exec(globalPos); } diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index 883b9f60d..008f5cfe8 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -254,7 +254,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); cswitchOffset[i]->setVisible(true); - populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(source.getDecimals(model)); cswitchOffset[i]->setSingleStep(source.getStep(model)); if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcsetVisible(true); cswitchValue[i]->setVisible(false); cswitchOffset[i]->setVisible(false); - populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; case CS_FAMILY_TIMERS: cswitchSource1[i]->setVisible(false); @@ -382,14 +382,6 @@ void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedSwitch = label->property("index").toInt(); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - QIcon CopyIcon; - populate_icon(&CopyIcon,"copy.png"); - QIcon CutIcon; - populate_icon(&CutIcon,"cut.png"); - QIcon PasteIcon; - populate_icon(&PasteIcon,"paste.png"); QPoint globalPos = label->mapToGlobal(pos); @@ -398,10 +390,10 @@ void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) bool hasData = mimeData->hasFormat("application/x-companion-csw"); QMenu contextMenu; - contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(cswDelete()),tr("Delete")); - contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C")); - contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X")); - contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(cswDelete()),tr("Delete")); + contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C")); + contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X")); + contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.exec(globalPos); } diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 2dc60593b..00387720a 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -48,7 +48,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i ui->sideLabel->hide(); ui->sideCB->hide(); ui->inputName->setMaxLength(4); - populateSourceCB(ui->sourceCB, ed->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); + populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); ui->sourceCB->removeItem(0); } else { diff --git a/companion/src/modeledit/heli.cpp b/companion/src/modeledit/heli.cpp index 6c584658a..a6a97a1b9 100644 --- a/companion/src/modeledit/heli.cpp +++ b/companion/src/modeledit/heli.cpp @@ -26,7 +26,7 @@ void HeliPanel::update() lock = true; ui->swashTypeCB->setCurrentIndex(model.swashRingData.type); - populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS); ui->swashRingValSB->setValue(model.swashRingData.value); ui->swashInvertELE->setChecked(model.swashRingData.invertELE); ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL); diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 74e5f9745..2ffbcdd66 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -8,28 +8,21 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g generalSettings(generalSettings), expoInserted(false) { - QString Theme=getTheme(); - QGridLayout * exposLayout = new QGridLayout(this); ExposlistWidget = new MixersList(this, true); QPushButton * qbUp = new QPushButton(this); QPushButton * qbDown = new QPushButton(this); QPushButton * qbClear = new QPushButton(this); - QIcon qbUpIcon; - populate_icon(&qbUpIcon,"moveup.png"); + qbUp->setText(tr("Move Up")); - qbUp->setIcon(qbUpIcon); + qbUp->setIcon(CompanionIcon("moveup.png")); qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); - QIcon qbDownIcon; - populate_icon(&qbDownIcon,"movedown.png"); qbDown->setText(tr("Move Down")); - qbDown->setIcon(qbDownIcon); + qbDown->setIcon(CompanionIcon("movedown.png")); qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); - QIcon qbClearIcon; - populate_icon(&qbClearIcon,"clear.png"); qbClear->setText(tr("Clear Expo Settings")); - qbClear->setIcon(qbClearIcon); + qbClear->setIcon(CompanionIcon("clear.png")); exposLayout->addWidget(ExposlistWidget,1,1,1,3); exposLayout->addWidget(qbUp,2,1); @@ -348,24 +341,6 @@ void InputsPanel::expoAdd() void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos) { - QIcon AddIcon; - populate_icon(&AddIcon,"add.png"); - QIcon EditIcon; - populate_icon(&EditIcon,"edit.png"); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - QIcon CopyIcon; - populate_icon(&CopyIcon,"copy.png"); - QIcon CutIcon; - populate_icon(&CutIcon,"cut.png"); - QIcon PasteIcon; - populate_icon(&PasteIcon,"paste.png"); - QIcon DuplicateIcon; - populate_icon(&DuplicateIcon,"duplicate.png"); - QIcon MoveUpIcon; - populate_icon(&MoveUpIcon,"moveup.png"); - QIcon MoveDownIcon; - populate_icon(&MoveDownIcon,"movedown.png"); QPoint globalPos = ExposlistWidget->mapToGlobal(pos); const QClipboard *clipboard = QApplication::clipboard(); @@ -373,17 +348,17 @@ void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos) bool hasData = mimeData->hasFormat("application/x-companion-expo"); QMenu contextMenu; - contextMenu.addAction(AddIcon, tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A")); - contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(expoOpen()),tr("Enter")); + contextMenu.addAction(CompanionIcon("add.png"), tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A")); + contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(expoOpen()),tr("Enter")); contextMenu.addSeparator(); - contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(exposDelete()),tr("Delete")); - contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C")); - contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X")); - contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData); - contextMenu.addAction(DuplicateIcon, tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U")); + contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(exposDelete()),tr("Delete")); + contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C")); + contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X")); + contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(CompanionIcon("duplicate.png"), tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U")); contextMenu.addSeparator(); - contextMenu.addAction(MoveUpIcon, tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up")); - contextMenu.addAction(MoveDownIcon, tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down")); + contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up")); + contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down")); contextMenu.exec(globalPos); } diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 5b34c7406..85a9c4a90 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -3,9 +3,10 @@ #include "eeprominterface.h" #include "helpers.h" -MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) : +MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, int stickMode) : QDialog(parent), ui(new Ui::MixerDialog), + model(model), md(mixdata), lock(false) { @@ -19,7 +20,7 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) : else this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10)); - populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); + populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); ui->sourceCB->removeItem(0); int limit = GetEepromInterface()->getCapability(OffsetWeight); @@ -145,16 +146,18 @@ void MixerDialog::valuesChanged() if (!lock) { lock = true; QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()); + md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt(), &model); if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) { if (!GetEepromInterface()->getCapability(MixesWithoutExpo)) { ui->MixDR_CB->hide(); ui->label_MixDR->hide(); - } else { + } + else { ui->MixDR_CB->setVisible(true); ui->label_MixDR->setVisible(true); } - } else { + } + else { ui->MixDR_CB->setHidden(true); ui->label_MixDR->setHidden(true); } diff --git a/companion/src/modeledit/mixerdialog.h b/companion/src/modeledit/mixerdialog.h index df2046e0f..437d9ca21 100644 --- a/companion/src/modeledit/mixerdialog.h +++ b/companion/src/modeledit/mixerdialog.h @@ -14,7 +14,7 @@ namespace Ui { class MixerDialog : public QDialog { Q_OBJECT public: - MixerDialog(QWidget *parent, MixData *mixdata, int stickMode); + MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, int stickMode); ~MixerDialog(); protected: @@ -26,6 +26,7 @@ class MixerDialog : public QDialog { private: Ui::MixerDialog *ui; + ModelData & model; MixData *md; bool lock; GVarGroup * gvWeightGroup; diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 1b18cc50d..5e1fb7769 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -14,20 +14,14 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen QPushButton * qbUp = new QPushButton(this); QPushButton * qbDown = new QPushButton(this); QPushButton * qbClear = new QPushButton(this); - QIcon qbUpIcon; - populate_icon(&qbUpIcon,"moveup.png"); qbUp->setText(tr("Move Up")); - qbUp->setIcon(qbUpIcon); + qbUp->setIcon(CompanionIcon("moveup.png")); qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); - QIcon qbDownIcon; - populate_icon(&qbDownIcon,"movedown.png"); qbDown->setText(tr("Move Down")); - qbDown->setIcon(qbDownIcon); + qbDown->setIcon(CompanionIcon("movedown.png")); qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); - QIcon qbClearIcon; - populate_icon(&qbClearIcon,"clear.png"); qbClear->setText(tr("Clear Mixes")); - qbClear->setIcon(qbClearIcon); + qbClear->setIcon(CompanionIcon("clear.png")); mixesLayout->addWidget(MixerlistWidget,1,1,1,3); mixesLayout->addWidget(qbUp,2,1); @@ -210,7 +204,7 @@ void MixesPanel::gm_openMix(int index) emit modified(); update(); - MixerDialog *g = new MixerDialog(this, &mixd, generalSettings.stickMode); + MixerDialog *g = new MixerDialog(this, model, &mixd, generalSettings.stickMode); if(g->exec()) { model.mixData[index] = mixd; emit modified(); @@ -411,24 +405,6 @@ void MixesPanel::mixerAdd() void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos) { - QIcon AddIcon; - populate_icon(&AddIcon,"add.png"); - QIcon EditIcon; - populate_icon(&EditIcon,"edit.png"); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - QIcon CopyIcon; - populate_icon(&CopyIcon,"copy.png"); - QIcon CutIcon; - populate_icon(&CutIcon,"cut.png"); - QIcon PasteIcon; - populate_icon(&PasteIcon,"paste.png"); - QIcon DuplicateIcon; - populate_icon(&DuplicateIcon,"duplicate.png"); - QIcon MoveUpIcon; - populate_icon(&MoveUpIcon,"moveup.png"); - QIcon MoveDownIcon; - populate_icon(&MoveDownIcon,"movedown.png"); QPoint globalPos = MixerlistWidget->mapToGlobal(pos); const QClipboard *clipboard = QApplication::clipboard(); @@ -436,17 +412,17 @@ void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos) bool hasData = mimeData->hasFormat("application/x-companion-mix"); QMenu contextMenu; - contextMenu.addAction(AddIcon, tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A")); - contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter")); + contextMenu.addAction(CompanionIcon("add.png"), tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A")); + contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter")); contextMenu.addSeparator(); - contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete")); - contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C")); - contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X")); - contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData); - contextMenu.addAction(DuplicateIcon, tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U")); + contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete")); + contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C")); + contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X")); + contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(CompanionIcon("duplicate.png"), tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U")); contextMenu.addSeparator(); - contextMenu.addAction(MoveUpIcon, tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up")); - contextMenu.addAction(MoveDownIcon, tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down")); + contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up")); + contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down")); contextMenu.exec(globalPos); } diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 34016edf3..8a22cbc54 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -21,11 +21,9 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i generalSettings(radioData.generalSettings) { ui->setupUi(this); - QSettings settings("companion", "companion"); + QSettings settings; restoreGeometry(settings.value("modelEditGeometry").toByteArray()); - QIcon SimulateIcon; - populate_icon(&SimulateIcon,"simulate.png"); - ui->pushButton->setIcon(SimulateIcon); + ui->pushButton->setIcon(CompanionIcon("simulate.png")); addTab(new Setup(this, model), tr("Setup")); addTab(new HeliPanel(this, model), tr("Heli")); addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes")); @@ -47,7 +45,7 @@ ModelEdit::~ModelEdit() void ModelEdit::closeEvent(QCloseEvent *event) { - QSettings settings("companion", "companion"); + QSettings settings; settings.setValue("modelEditGeometry", saveGeometry()); } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 1d67137d1..b663f577a 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -353,7 +353,7 @@ Setup::Setup(QWidget *parent, ModelData & model): if (GetEepromInterface()->getCapability(ModelImage)) { QStringList items; items.append(""); - QSettings settings("companion", "companion"); + QSettings settings; QString path = settings.value("sdPath", ".").toString(); path.append("/BMP/"); QDir qd(path); @@ -497,7 +497,7 @@ void Setup::on_image_currentIndexChanged(int index) { if (!lock) { strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); - QSettings settings("companion", "companion"); + QSettings settings; QString path=settings.value("sdPath", ".").toString(); path.append("/BMP/"); QDir qd(path); diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index e0637f4df..3a2c63660 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -342,7 +342,7 @@ TelemetryPanel::~TelemetryPanel() void TelemetryPanel::setup() { - QSettings settings("companion", "companion"); + QSettings settings; QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); lock=true; diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index f2cb682f4..088945f12 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -83,47 +83,23 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos) const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); bool hasData = mimeData->hasFormat("application/x-companion"); - QIcon AddIcon; - populate_icon(&AddIcon,"add.png"); - QIcon EditIcon; - populate_icon(&EditIcon,"edit.png"); - QIcon OpenIcon; - populate_icon(&OpenIcon,"open.png"); - QIcon WizardIcon; - populate_icon(&WizardIcon,"wizard.png"); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - QIcon CopyIcon; - populate_icon(&CopyIcon,"copy.png"); - QIcon CutIcon; - populate_icon(&CutIcon,"cut.png"); - QIcon PasteIcon; - populate_icon(&PasteIcon,"paste.png"); - QIcon DuplicateIcon; - populate_icon(&DuplicateIcon,"duplicate.png"); - QIcon CurrentModelIcon; - populate_icon(&CurrentModelIcon,"currentmodel.png"); - QIcon PrintIcon; - populate_icon(&PrintIcon,"print.png"); - QIcon SimulateIcon; - populate_icon(&SimulateIcon,"simulate.png"); QMenu contextMenu; - contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(OpenEditWindow())); - contextMenu.addAction(OpenIcon, tr("&Restore from backup"),this,SLOT(LoadBackup())); - contextMenu.addAction(WizardIcon, tr("&Model Wizard"),this,SLOT(OpenWizard())); + contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(OpenEditWindow())); + contextMenu.addAction(CompanionIcon("open.png"), tr("&Restore from backup"),this,SLOT(LoadBackup())); + contextMenu.addAction(CompanionIcon("wizard.png"), tr("&Model Wizard"),this,SLOT(OpenWizard())); contextMenu.addSeparator(); - contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(confirmDelete()),tr("Delete")); - contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(copy()),tr("Ctrl+C")); - contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(cut()),tr("Ctrl+X")); - contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(paste()),tr("Ctrl+V"))->setEnabled(hasData); - contextMenu.addAction(DuplicateIcon, tr("D&uplicate"),this,SLOT(duplicate()),tr("Ctrl+U")); + contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(confirmDelete()),tr("Delete")); + contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(copy()),tr("Ctrl+C")); + contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(cut()),tr("Ctrl+X")); + contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(paste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(CompanionIcon("duplicate.png"), tr("D&uplicate"),this,SLOT(duplicate()),tr("Ctrl+U")); contextMenu.addSeparator(); - contextMenu.addAction(CurrentModelIcon, tr("&Use as default"),this,SLOT(setdefault())); + contextMenu.addAction(CompanionIcon("currentmodel.png"), tr("&Use as default"),this,SLOT(setdefault())); contextMenu.addSeparator(); - contextMenu.addAction(PrintIcon, tr("P&rint model"),this, SLOT(print()),tr("Alt+R")); + contextMenu.addAction(CompanionIcon("print.png"), tr("P&rint model"),this, SLOT(print()),tr("Alt+R")); contextMenu.addSeparator(); - contextMenu.addAction(SimulateIcon, tr("&Simulate model"),this, SLOT(simulate()),tr("Alt+S")); + contextMenu.addAction(CompanionIcon("simulate.png"), tr("&Simulate model"),this, SLOT(simulate()),tr("Alt+S")); contextMenu.exec(globalPos); } diff --git a/companion/src/preferencesdialog.cpp b/companion/src/preferencesdialog.cpp index 82ee49b40..a8c50452c 100644 --- a/companion/src/preferencesdialog.cpp +++ b/companion/src/preferencesdialog.cpp @@ -17,15 +17,9 @@ preferencesDialog::preferencesDialog(QWidget *parent) : updateLock(false) { ui->setupUi(this); - QIcon Icon; - populate_icon(&Icon,"preferences.png"); - this->setWindowIcon(Icon); - QIcon LibraryIcon; - populate_icon(&LibraryIcon,"library.png"); - ui->splashLibraryButton->setIcon(LibraryIcon); - QIcon ClearIcon; - populate_icon(&ClearIcon,"clear.png"); - ui->clearImageButton->setIcon(ClearIcon); + setWindowIcon(CompanionIcon("preferences.png")); + ui->splashLibraryButton->setIcon(CompanionIcon("library.png")); + ui->clearImageButton->setIcon(CompanionIcon("clear.png")); QCheckBox * OptionCheckBox[]= { ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7, @@ -233,7 +227,7 @@ void preferencesDialog::firmwareChanged() ui->CPU_ID_LE->hide(); ui->CPU_ID_LABEL->hide(); } - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("FwRevisions"); int fwrev = settings.value(variant.id, -1).toInt(); settings.endGroup(); @@ -259,7 +253,7 @@ void preferencesDialog::firmwareChanged() void preferencesDialog::writeValues() { - QSettings settings("companion", "companion"); + QSettings settings; if (ui->locale_QB->currentIndex() > 0) settings.setValue("locale", ui->locale_QB->itemData(ui->locale_QB->currentIndex())); else @@ -392,7 +386,7 @@ void preferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) void preferencesDialog::initSettings() { - QSettings settings("companion", "companion"); + QSettings settings; int i = ui->locale_QB->findData(settings.value("locale")); if (i < 0) i = 0; ui->locale_QB->setCurrentIndex(i); @@ -533,7 +527,7 @@ void preferencesDialog::on_fw_dnld_clicked() writeValues(); if (!variant.firmware->getUrl(variant.id).isNull()) { if (ui->burnFirmware->isChecked()) { - QSettings settings("companion", "companion"); + QSettings settings; current_firmware_variant = getFirmwareVariant(); settings.setValue("firmware", current_firmware_variant.id); } @@ -554,7 +548,7 @@ void preferencesDialog::on_voice_dnld_clicked() void preferencesDialog::on_libraryPathButton_clicked() { ui->ProfSave_PB->setEnabled(true); - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString()); if (!fileName.isEmpty()) { settings.setValue("libraryPath", fileName); @@ -564,7 +558,7 @@ void preferencesDialog::on_libraryPathButton_clicked() void preferencesDialog::on_snapshotPathButton_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString()); if (!fileName.isEmpty()) { settings.setValue("snapshotpath", fileName); @@ -575,7 +569,7 @@ void preferencesDialog::on_snapshotPathButton_clicked() void preferencesDialog::on_snapshotClipboardCKB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; if (ui->snapshotClipboardCKB->isChecked()) { ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); @@ -591,7 +585,7 @@ void preferencesDialog::on_snapshotClipboardCKB_clicked() void preferencesDialog::on_backupPathButton_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString()); if (!fileName.isEmpty()) { settings.setValue("backupPath", fileName); @@ -602,7 +596,7 @@ void preferencesDialog::on_backupPathButton_clicked() void preferencesDialog::on_ge_pathButton_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text()); if (!fileName.isEmpty()) { ui->ge_lineedit->setText(fileName); @@ -628,7 +622,7 @@ void preferencesDialog::on_splashLibraryButton_clicked() void preferencesDialog::on_sdPathButton_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString()); if (!fileName.isEmpty()) { ui->sdPath->setText(fileName); @@ -638,7 +632,7 @@ void preferencesDialog::on_sdPathButton_clicked() void preferencesDialog::on_ProfSlot_SB_valueChanged() { - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); settings.beginGroup(profile); @@ -667,7 +661,7 @@ void preferencesDialog::on_ProfSlot_SB_valueChanged() void preferencesDialog::on_ProfSave_PB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); QString name=ui->ProfName_LE->text(); @@ -706,7 +700,7 @@ void preferencesDialog::on_ProfSave_PB_clicked() void preferencesDialog::on_export_PB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); QString name=ui->ProfName_LE->text(); if (!name.isEmpty()) { @@ -727,7 +721,7 @@ void preferencesDialog::on_export_PB_clicked() void preferencesDialog::on_import_PB_clicked() { - QSettings settings("companion", "companion"); + QSettings settings; QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); QString name=ui->ProfName_LE->text(); if (!name.isEmpty()) { @@ -760,7 +754,7 @@ void preferencesDialog::on_SplashSelect_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)); @@ -837,7 +831,7 @@ void preferencesDialog::on_joystickChkB_clicked() { } void preferencesDialog::on_joystickcalButton_clicked() { - //QSettings settings("companion", "companion"); + //QSettings settings; //settings.setValue("joystick-name",ui->joystickCB->currentText()); joystickDialog * jd=new joystickDialog(this, ui->joystickCB->currentIndex()); jd->exec(); @@ -849,7 +843,7 @@ void preferencesDialog::on_checkFWUpdates_clicked() { FirmwareVariant variant = getFirmwareVariant(); if (ui->burnFirmware->isChecked()) { - QSettings settings("companion", "companion"); + QSettings settings; current_firmware_variant = variant; settings.setValue("firmware", variant.id); } diff --git a/companion/src/simulatordialog.cpp b/companion/src/simulatordialog.cpp index 4d913c4f7..1bbddf4ef 100644 --- a/companion/src/simulatordialog.cpp +++ b/companion/src/simulatordialog.cpp @@ -32,7 +32,7 @@ simulatorDialog::simulatorDialog(QWidget *parent) : beepVal = 0; beepShow = 0; - QSettings settings("companion", "companion"); + QSettings settings; backLight = settings.value("backLight",0).toInt(); bool simuSW=settings.value("simuSW",false).toBool(); switch (backLight) { @@ -211,7 +211,7 @@ void simulatorDialog::setupTimer() void simulatorDialog::onButtonPressed(int value) { if (value==Qt::Key_Print) { - QSettings settings("companion", "companion"); + QSettings settings; bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); QString fileName =""; if (!toclipboard) { diff --git a/companion/src/splashlibrary.cpp b/companion/src/splashlibrary.cpp index e8a1a4090..49aef10e4 100644 --- a/companion/src/splashlibrary.cpp +++ b/companion/src/splashlibrary.cpp @@ -9,12 +9,8 @@ splashLibrary::splashLibrary(QWidget *parent, QString * fileName) : QDialog(parent), ui(new Ui::splashLibrary) { splashFileName = fileName; ui->setupUi(this); - QIcon NextIcon; - populate_icon(&NextIcon,"arrow-right.png"); - QIcon PrevIcon; - populate_icon(&PrevIcon,"arrow-left.png"); - ui->nextPage->setIcon(NextIcon); - ui->prevPage->setIcon(PrevIcon); + ui->nextPage->setIcon(CompanionIcon("arrow-right.png")); + ui->prevPage->setIcon(CompanionIcon("arrow-left.png")); page = 0; getFileList(); if (imageList.size() > 20) { @@ -65,7 +61,7 @@ void splashLibrary::setupPage(int page) { } void splashLibrary::getFileList() { - QSettings settings("companion", "companion"); + QSettings settings; imageList.clear(); if (settings.value("embedded_splashes", 0).toInt() == 0) { QDir myRes(":/images/library"); diff --git a/companion/src/version.h.in b/companion/src/version.h.in index cbd6b87f2..e0770040e 100644 --- a/companion/src/version.h.in +++ b/companion/src/version.h.in @@ -1,3 +1,2 @@ #define C9X_VERSION "@C9X_VERSION@" -#define C9X_REVISION @C9X_WC_REVISION@ diff --git a/companion/src/xsimulatordialog.cpp b/companion/src/xsimulatordialog.cpp index be071b6af..488439715 100644 --- a/companion/src/xsimulatordialog.cpp +++ b/companion/src/xsimulatordialog.cpp @@ -30,7 +30,7 @@ xsimulatorDialog::xsimulatorDialog(QWidget *parent) : ui->setupUi(this); ui->lcd->setFocus(); - QSettings settings("companion", "companion"); + QSettings settings; ui->lcd->setBackgroundColor(47, 123, 227); setupSticks(); resize(0, 0); // to force min height, min width @@ -179,7 +179,7 @@ void xsimulatorDialog::setupTimer() void xsimulatorDialog::onButtonPressed(int value) { if (value==Qt::Key_Print) { - QSettings settings("companion", "companion"); + QSettings settings; bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); QString fileName =""; if (!toclipboard) {