1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Another code reduction. Settings are now stored in "OpenTX/Companion",

instead of "companion/companion"
This commit is contained in:
Bertrand Songis 2014-01-20 16:50:06 +01:00
parent 0d394ca7c6
commit 439cabe83c
35 changed files with 465 additions and 650 deletions

View file

@ -83,7 +83,7 @@ burnConfigDialog::~burnConfigDialog()
void burnConfigDialog::getSettings() void burnConfigDialog::getSettings()
{ {
QSettings settings("companion", "companion"); QSettings settings;
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString(); avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString();
sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString(); sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString();
@ -137,7 +137,7 @@ void burnConfigDialog::getSettings()
void burnConfigDialog::putSettings() void burnConfigDialog::putSettings()
{ {
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("avrdude_location", avrLoc); settings.setValue("avrdude_location", avrLoc);
settings.setValue("programmer", avrProgrammer); settings.setValue("programmer", avrProgrammer);
settings.setValue("mcu", avrMCU); settings.setValue("mcu", avrMCU);
@ -279,10 +279,9 @@ void burnConfigDialog::listProgrammers()
QStringList arguments; QStringList arguments;
arguments << "-c?"; arguments << "-c?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE); avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("list.png"));
populate_icon(&Icon,"list.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
} }
void burnConfigDialog::on_pushButton_3_clicked() void burnConfigDialog::on_pushButton_3_clicked()
@ -298,10 +297,9 @@ void burnConfigDialog::on_pushButton_4_clicked()
arguments << "-?"; arguments << "-?";
avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE); avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("configure.png"));
populate_icon(&Icon,"configure.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
} }
@ -317,10 +315,9 @@ void burnConfigDialog::readFuses()
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str; arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str;
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE); avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("fuses.png"));
populate_icon(&Icon,"fuses.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
} }
void burnConfigDialog::restFuses(bool eeProtect) 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"; QString erStr = eeProtect ? "hfuse:w:0x11:m" : "hfuse:w:0x19:m";
str << "-U" << "lfuse:w:0xD7:m" << "-U" << erStr << "-U" << "efuse:w:0xFC: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 //use hfuse = 0x81 to prevent eeprom being erased with every flashing
} else { }
else {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString tempFile; QString tempFile;
QString lfuses; QString lfuses;
@ -352,10 +350,9 @@ void burnConfigDialog::restFuses(bool eeProtect)
QStringList argread; QStringList argread;
argread << "-c" << avrProgrammer << "-p" << avrMCU << args <<"-U" << "lfuse:r:"+tempFile+":r" ; 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); avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, argread, "Reset Fuses",AVR_DIALOG_CLOSE_IF_SUCCESSFUL,FALSE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("fuses.png"));
populate_icon(&Icon,"fuses.png");
ad->setWindowIcon(Icon);
ad->exec(); ad->exec();
delete ad;
QFile file(tempFile); QFile file(tempFile);
if (file.exists() && file.size()==1) { if (file.exists() && file.size()==1) {
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
@ -363,12 +360,14 @@ void burnConfigDialog::restFuses(bool eeProtect)
file.read(bin_flash, 1); file.read(bin_flash, 1);
if (bin_flash[0]==0x0E) { if (bin_flash[0]==0x0E) {
lfuses="lfuse:w:0x0E:m"; lfuses="lfuse:w:0x0E:m";
} else { }
else {
lfuses="lfuse:w:0x3F:m"; lfuses="lfuse:w:0x3F:m";
} }
file.close(); file.close();
unlink(tempFile.toAscii()); unlink(tempFile.toAscii());
} else { }
else {
lfuses="lfuse:w:0x3F:m"; lfuses="lfuse:w:0x3F:m";
} }
@ -379,14 +378,14 @@ void burnConfigDialog::restFuses(bool eeProtect)
QStringList arguments; QStringList arguments;
if (avrMCU=="m2560") { if (avrMCU=="m2560") {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-u" << str; arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-u" << str;
} else { }
else {
arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str; arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str;
} }
avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE); avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("fuses.png"));
populate_icon(&Icon,"fuses.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
} }
} }
@ -398,24 +397,29 @@ void burnConfigDialog::on_advCtrChkB_toggled(bool checked)
if (IS_TARANIS(eepromInterface->getBoard())) { if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->show(); ui->label_dfu2->show();
ui->dfuArgs->show(); ui->dfuArgs->show();
} else if (eepromInterface->getBoard()==BOARD_SKY9X) { }
else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->show(); ui->label_sb2->show();
ui->arm_mcu->show(); ui->arm_mcu->show();
} else { }
else {
ui->label_av3->show(); ui->label_av3->show();
ui->avrdude_mcu->show(); ui->avrdude_mcu->show();
QMessageBox::warning(this, tr("Companion"), QMessageBox::warning(this, tr("Companion"),
tr("<b><u>WARNING!</u></b><br>Normally CPU type is automatically selected according to the chosen firmware.<br>If you change the CPU type the resulting eeprom could be inconsistent."), tr("<b><u>WARNING!</u></b><br>Normally CPU type is automatically selected according to the chosen firmware.<br>If you change the CPU type the resulting eeprom could be inconsistent."),
QMessageBox::Ok); QMessageBox::Ok);
} }
} else { }
else {
if (IS_TARANIS(eepromInterface->getBoard())) { if (IS_TARANIS(eepromInterface->getBoard())) {
ui->label_dfu2->hide(); ui->label_dfu2->hide();
ui->dfuArgs->hide(); ui->dfuArgs->hide();
} else if (eepromInterface->getBoard()==BOARD_SKY9X) { }
else if (eepromInterface->getBoard()==BOARD_SKY9X) {
ui->label_sb2->hide(); ui->label_sb2->hide();
ui->arm_mcu->hide(); ui->arm_mcu->hide();
} else { }
else {
ui->label_av3->hide(); ui->label_av3->hide();
ui->avrdude_mcu->hide(); ui->avrdude_mcu->hide();
} }

View file

@ -16,9 +16,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexType(Type) hexType(Type)
{ {
ui->setupUi(this); ui->setupUi(this);
QIcon LibraryIcon; ui->libraryButton->setIcon(CompanionIcon("library.png"));
populate_icon(&LibraryIcon,"library.png");
ui->libraryButton->setIcon(LibraryIcon);
ui->SplashFrame->hide(); ui->SplashFrame->hide();
ui->FramFWInfo->hide(); ui->FramFWInfo->hide();
ui->EEbackupCB->hide(); ui->EEbackupCB->hide();
@ -29,11 +27,12 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->patchcalib_CB->hide(); ui->patchcalib_CB->hide();
ui->patchhw_CB->hide(); ui->patchhw_CB->hide();
ui->InvertColorButton->setDisabled(true); ui->InvertColorButton->setDisabled(true);
this->setWindowTitle(tr("Write firmware to TX")); setWindowTitle(tr("Write firmware to TX"));
if (IS_TARANIS(GetEepromInterface()->getBoard())) { if (IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->hide(); ui->EEbackupCB->hide();
} }
} else { }
else {
ui->FlashLoadButton->setText(tr("Browse for file")); ui->FlashLoadButton->setText(tr("Browse for file"));
ui->profile_label->hide(); ui->profile_label->hide();
ui->patchcalib_CB->hide(); ui->patchcalib_CB->hide();
@ -54,11 +53,12 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->BurnFlashButton->setDisabled(true); ui->BurnFlashButton->setDisabled(true);
ui->EEbackupCB->hide(); ui->EEbackupCB->hide();
if (DocName.isEmpty()) { if (DocName.isEmpty()) {
this->setWindowTitle(tr("Write Models and Settings to TX")); setWindowTitle(tr("Write Models and Settings to TX"));
} else {
this->setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
} }
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(); int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid); 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); ui->FWFileName->setText(*hexfileName);
if (Type==2) { if (Type==2) {
checkFw(*hexfileName); checkFw(*hexfileName);
} else { }
else {
burnraw=false; burnraw=false;
if (checkeEprom(*hexfileName)) { if (checkeEprom(*hexfileName)) {
QSettings settings("companion", "companion"); QSettings settings;
int profileid=settings.value("profileId", 1).toInt(); int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid); 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))) { if (!((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6))) {
ui->patchhw_CB->setDisabled(true); ui->patchhw_CB->setDisabled(true);
} }
} else { }
else {
ui->profile_label->hide(); ui->profile_label->hide();
} }
if (!IS_TARANIS(GetEepromInterface()->getBoard())) { if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show(); ui->EEpromCB->show();
} else { }
else {
ui->EEpromCB->setChecked(false); ui->EEpromCB->setChecked(false);
} }
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
@ -116,7 +119,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexfileName->clear(); hexfileName->clear();
} }
else if (Type==2) { else if (Type==2) {
QSettings settings("companion", "companion"); QSettings settings;
QString FileName; QString FileName;
FileName = settings.value("lastFw").toString(); FileName = settings.value("lastFw").toString();
QFile file(FileName); QFile file(FileName);
@ -127,14 +130,15 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
resize(0, 0); resize(0, 0);
} }
burnDialog::~burnDialog() { burnDialog::~burnDialog()
{
delete ui; delete ui;
} }
void burnDialog::on_FlashLoadButton_clicked() void burnDialog::on_FlashLoadButton_clicked()
{ {
QString fileName; QString fileName;
QSettings settings("companion", "companion"); QSettings settings;
ui->ImageLoadButton->setDisabled(true); ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true); ui->libraryButton->setDisabled(true);
ui->InvertColorButton->setDisabled(true); ui->InvertColorButton->setDisabled(true);
@ -153,7 +157,8 @@ void burnDialog::on_FlashLoadButton_clicked()
if (hexType==2) { if (hexType==2) {
fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
checkFw(fileName); 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)); 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 (checkeEprom(fileName)) {
if (burnraw==false) { if (burnraw==false) {
@ -163,10 +168,12 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->patchhw_CB->show(); ui->patchhw_CB->show();
if (!IS_TARANIS(GetEepromInterface()->getBoard())) { if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show(); ui->EEpromCB->show();
} else { }
else {
ui->EEpromCB->setChecked(false); ui->EEpromCB->setChecked(false);
} }
} else { }
else {
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
ui->profile_label->hide(); ui->profile_label->hide();
ui->patchcalib_CB->setChecked(false); ui->patchcalib_CB->setChecked(false);
@ -184,10 +191,11 @@ void burnDialog::checkFw(QString fileName)
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
return; return;
} }
QSettings settings("companion", "companion"); QSettings settings;
if (!IS_TARANIS(GetEepromInterface()->getBoard())) { if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->show(); ui->EEbackupCB->show();
} else { }
else {
ui->EEbackupCB->setChecked(false); ui->EEbackupCB->setChecked(false);
*backup=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->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(flash.getSplashFormat())));
ui->PatchFWCB->setEnabled(true); ui->PatchFWCB->setEnabled(true);
ui->PatchFWCB->setChecked(PatchFwCB); ui->PatchFWCB->setChecked(PatchFwCB);
} else { }
else {
ui->PatchFWCB->setDisabled(true); ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false); ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true); ui->PreferredImageCB->setDisabled(true);
} }
} else { }
else {
ui->PatchFWCB->setDisabled(true); ui->PatchFWCB->setDisabled(true);
ui->PatchFWCB->setChecked(false); ui->PatchFWCB->setChecked(false);
ui->PreferredImageCB->setDisabled(true); ui->PreferredImageCB->setDisabled(true);
} }
} }
} else { }
else {
ui->FwImage->hide(); ui->FwImage->hide();
ui->ImageFileName->setText(""); ui->ImageFileName->setText("");
ui->SplashFrame->hide(); ui->SplashFrame->hide();
} }
} else { }
else {
QMessageBox::warning(this, tr("Warning"), tr("%1 is not a known firmware").arg(fileName)); QMessageBox::warning(this, tr("Warning"), tr("%1 is not a known firmware").arg(fileName));
ui->BurnFlashButton->setText(tr("Burn anyway !")); ui->BurnFlashButton->setText(tr("Burn anyway !"));
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
@ -270,7 +282,8 @@ bool burnDialog::checkeEprom(QString fileName)
} }
QTextStream inputStream(&file); QTextStream inputStream(&file);
XmlInterface(inputStream).load(radioData); 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 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())); QMessageBox::critical(this, tr("Error"),tr("Error opening file %1:\n%2.").arg(fileName).arg(file.errorString()));
return false; return false;
@ -313,7 +326,8 @@ bool burnDialog::checkeEprom(QString fileName)
ui->FWFileName->setText(fileName); ui->FWFileName->setText(fileName);
return true; return true;
} }
} else if (fileType==FILE_TYPE_BIN) { //read binary }
else if (fileType==FILE_TYPE_BIN) { //read binary
int eeprom_size = file.size(); int eeprom_size = file.size();
if (!file.open(QFile::ReadOnly)) { //reading binary file - TODO HEX support 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())); 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]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings("companion", "companion"); QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); 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 gray;
int width = image.width(); int width = image.width();
int height = image.height(); int height = image.height();
for (int i = 0; i < width; ++i) for (int i = 0; i < width; ++i) {
{ for (int j = 0; j < height; ++j) {
for (int j = 0; j < height; ++j) col = image.pixel(i, j);
{ gray = qGray(col);
col = image.pixel(i, j); image.setPixel(i, j, qRgb(gray, gray, gray));
gray = qGray(col); }
image.setPixel(i, j, qRgb(gray, gray, gray));
}
} }
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()))); 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->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
} }
ui->PatchFWCB->setEnabled(true); ui->PatchFWCB->setEnabled(true);
@ -429,7 +442,7 @@ void burnDialog::on_BurnFlashButton_clicked()
if (hexType==2) { if (hexType==2) {
QString fileName=ui->FWFileName->text(); QString fileName=ui->FWFileName->text();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
settings.setValue("lastFw", fileName); settings.setValue("lastFw", fileName);
if (ui->PatchFWCB->isChecked()) { if (ui->PatchFWCB->isChecked()) {
@ -466,7 +479,7 @@ void burnDialog::on_BurnFlashButton_clicked()
} }
} }
if (hexType==1) { if (hexType==1) {
QSettings settings("companion", "companion"); QSettings settings;
int profileid=settings.value("profileId", 1).toInt(); int profileid=settings.value("profileId", 1).toInt();
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid); QString profile=QString("profile%1").arg(profileid);
@ -643,7 +656,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked)
{ {
QString tmpFileName; QString tmpFileName;
if (checked) { if (checked) {
QSettings settings("companion", "companion"); QSettings settings;
QString ImageStr = settings.value("SplashImage", "").toString(); QString ImageStr = settings.value("SplashImage", "").toString();
if (!ImageStr.isEmpty()) { if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr); QImage Image = qstring2image(ImageStr);

View file

@ -66,7 +66,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
} }
} }
str.append("<tr><td class=\"mycss\">&nbsp;</td></tr>"); str.append("<tr><td class=\"mycss\">&nbsp;</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">"+tr("Honors go to Rafal Tomczak (RadioClone) and Thomas Husterer (th9x) \nof course. Also to Erez Raviv (er9x) and it's fantastic eePe, from which\ncompanion9x was forked out.")+"</td></tr>"); str.append("<tr><td colspan=3 class=\"mycss\">"+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\nOpenTX Companion was forked out.")+"</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">"+tr("Thank you all !!!")+"</td></tr>"); str.append("<tr><td colspan=3 class=\"mycss\">"+tr("Thank you all !!!")+"</td></tr>");
str.append("</table>"); str.append("</table>");
str.append("</body></html>"); str.append("</body></html>");

View file

@ -8,23 +8,23 @@
#include "flashinterface.h" #include "flashinterface.h"
customizeSplashDialog::customizeSplashDialog(QWidget *parent) : customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::customizeSplashDialog) { ui(new Ui::customizeSplashDialog)
{
ui->setupUi(this); ui->setupUi(this);
QIcon LibraryIcon; ui->libraryButton->setIcon(CompanionIcon("library.png"));
populate_icon(&LibraryIcon,"library.png");
ui->libraryButton->setIcon(LibraryIcon);
ui->HowToLabel->clear(); ui->HowToLabel->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>"); ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
} }
customizeSplashDialog::~customizeSplashDialog() { customizeSplashDialog::~customizeSplashDialog()
{
delete ui; delete ui;
} }
void customizeSplashDialog::on_FlashLoadButton_clicked() 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); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->ImageLoadButton->setDisabled(true); ui->ImageLoadButton->setDisabled(true);
@ -70,7 +70,7 @@ void customizeSplashDialog::on_ImageLoadButton_clicked() {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings("companion", "companion"); QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); 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() void customizeSplashDialog::on_SaveFlashButton_clicked()
{ {
QString fileName; QString fileName;
QSettings settings("companion", "companion"); QSettings settings;
ui->HowToLabel->clear(); ui->HowToLabel->clear();
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER, 0, QFileDialog::DontConfirmOverwrite); fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER, 0, QFileDialog::DontConfirmOverwrite);
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
@ -180,7 +180,7 @@ void customizeSplashDialog::on_InvertColorButton_clicked()
void customizeSplashDialog::on_SaveImageButton_clicked() void customizeSplashDialog::on_SaveImageButton_clicked()
{ {
QString fileName; 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); fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastImagesDir").toString(), tr("PNG images (*.png);;"), 0, QFileDialog::DontConfirmOverwrite);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {

View file

@ -438,7 +438,7 @@ GeneralSettings::GeneralSettings()
calibSpanNeg[i] = 0x180; calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180; calibSpanPos[i] = 0x180;
} }
QSettings settings("companion", "companion"); QSettings settings;
templateSetup = settings.value("default_channel_order", 0).toInt(); templateSetup = settings.value("default_channel_order", 0).toInt();
stickMode = settings.value("default_mode", 1).toInt(); stickMode = settings.value("default_mode", 1).toInt();
int profile_id = settings.value("ActiveProfile", 0).toInt(); int profile_id = settings.value("ActiveProfile", 0).toInt();
@ -659,7 +659,7 @@ ModelData ModelData::removeGlobalVars()
QList<EEPROMInterface *> eepromInterfaces; QList<EEPROMInterface *> eepromInterfaces;
void RegisterEepromInterfaces() void RegisterEepromInterfaces()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int rev4a = settings.value("rev4asupport",0).toInt(); int rev4a = settings.value("rev4asupport",0).toInt();
eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK));
eepromInterfaces.push_back(new Open9xInterface(BOARD_M128)); eepromInterfaces.push_back(new Open9xInterface(BOARD_M128));

View file

@ -44,7 +44,7 @@ const char * Er9xInterface::getName()
const int Er9xInterface::getEEpromSize() const int Er9xInterface::getEEpromSize()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString avrMCU = settings.value("mcu", QString("m64")).toString(); QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;

View file

@ -47,7 +47,7 @@ const char * Gruvin9xInterface::getName()
const int Gruvin9xInterface::getEEpromSize() const int Gruvin9xInterface::getEEpromSize()
{ {
if (board == BOARD_STOCK) { if (board == BOARD_STOCK) {
QSettings settings("companion", "companion"); QSettings settings;
QString avrMCU = settings.value("mcu", QString("m64")).toString(); QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return EESIZE_STOCK*2; return EESIZE_STOCK*2;

View file

@ -593,7 +593,7 @@ enum Functions {
#endif #endif
FUNC_BACKLIGHT, FUNC_BACKLIGHT,
#if defined(DEBUG) #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 #endif
FUNC_MAX FUNC_MAX
}; };

View file

@ -135,7 +135,7 @@ using namespace Open9xSky9x;
Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface): Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString path=settings.value("sdPath", ".").toString()+"/"; QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {

View file

@ -145,7 +145,7 @@ OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
taranisSimulatorBoard = GetEepromInterface()->getBoard(); taranisSimulatorBoard = GetEepromInterface()->getBoard();
QSettings settings("companion", "companion"); QSettings settings;
QString path=settings.value("sdPath", ".").toString()+"/"; QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {

View file

@ -42,14 +42,10 @@ size_t SizeOfArray( T(&)[ N ] )
return N; return N;
} }
QStringList o9xservers;
Open9xInterface::Open9xInterface(BoardEnum board): Open9xInterface::Open9xInterface(BoardEnum board):
EEPROMInterface(board), EEPROMInterface(board),
efile(new EFile()) efile(new EFile())
{ {
o9xservers.clear();
o9xservers << "93.51.182.154" << "open9x.9xforums.com";
} }
Open9xInterface::~Open9xInterface() Open9xInterface::~Open9xInterface()
@ -309,7 +305,7 @@ bool Open9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
std::cout << " wrong size (" << size << ")\n"; std::cout << " wrong size (" << size << ")\n";
return false; return false;
} else { } 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; size=2048;
} }
} else { } else {
@ -944,14 +940,9 @@ bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esiz
QString geturl( int board) QString geturl( int board)
{ {
QString url="http://"; QSettings settings;
QSettings settings("companion", "companion"); QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString();
int server = settings.value("fwserver", 0).toInt();
if (server >= o9xservers.count()) {
server = 0;
settings.setValue("fwserver",server);
}
url.append(o9xservers.at(server));
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
case BOARD_M128: case BOARD_M128:
@ -972,27 +963,21 @@ QString geturl( int board)
QString getstamp( int board) QString getstamp( int board)
{ {
QString url="http://"; QSettings settings;
QSettings settings("companion", "companion"); QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString();
int server = settings.value("fwserver",0).toInt(); url.append("/stamp-opentx-");
if (server >=o9xservers.count()) {
server=0;
settings.setValue("fwserver",server);
}
url.append(o9xservers.at(server));
url.append("/binaries/stamp-opentx-");
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
url.append("stock.txt"); url.append("9x.txt");
break; break;
case BOARD_M128: case BOARD_M128:
url.append("stock128.txt"); url.append("9x128.txt");
break; break;
case BOARD_GRUVIN9X: case BOARD_GRUVIN9X:
url.append("v4.txt"); url.append("gruvin9x.txt");
break; break;
case BOARD_SKY9X: case BOARD_SKY9X:
url.append("arm.txt"); url.append("sky9x.txt");
break; break;
case BOARD_TARANIS: case BOARD_TARANIS:
case BOARD_TARANIS_REV4a: case BOARD_TARANIS_REV4a:
@ -1007,16 +992,10 @@ QString getstamp( int board)
QString getrnurl( int board) QString getrnurl( int board)
{ {
QString url="http://"; QSettings settings;
QSettings settings("companion", "companion"); QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString();
int server = settings.value("fwserver",0).toInt(); url.append("/releasenotes-");
if (server >=o9xservers.count()) { switch(board) {
server=0;
settings.setValue("fwserver",server);
}
url.append(o9xservers.at(server));
url.append("/docs/releasenotes-");
switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
case BOARD_M128: case BOARD_M128:
case BOARD_GRUVIN9X: 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 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 } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
/* 9x board */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1079,7 +1058,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9x board with M128 chip */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1175,7 +1154,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* Gruvin9x board */ /* 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->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1239,7 +1218,7 @@ void RegisterOpen9xFirmwares()
open9x->addOptions(fai_options); open9x->addOptions(fai_options);
firmwares.push_back(open9x); firmwares.push_back(open9x);
QSettings settings("companion", "companion"); QSettings settings;
int rev4a = settings.value("rev4asupport",0).toInt(); int rev4a = settings.value("rev4asupport",0).toInt();
if (rev4a) { 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); 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);

View file

@ -18,6 +18,9 @@
#include "eeprominterface.h" #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 EFile;
class Open9xInterface : public EEPROMInterface class Open9xInterface : public EEPROMInterface
@ -91,6 +94,7 @@ class Open9xFirmware: public FirmwareInfo {
addLanguage("se"); addLanguage("se");
addLanguage("cz"); addLanguage("cz");
addLanguage("es"); addLanguage("es");
addLanguage("pl");
addLanguage("pt"); addLanguage("pt");
addTTSLanguage("en"); addTTSLanguage("en");
@ -100,6 +104,7 @@ class Open9xFirmware: public FirmwareInfo {
addTTSLanguage("se"); addTTSLanguage("se");
addTTSLanguage("cz"); addTTSLanguage("cz");
addTTSLanguage("sk"); addTTSLanguage("sk");
addTTSLanguage("pl");
addTTSLanguage("pt"); addTTSLanguage("pt");
addTTSLanguage("es"); addTTSLanguage("es");
} }

View file

@ -44,7 +44,7 @@ const char * Th9xInterface::getName()
const int Th9xInterface::getEEpromSize() const int Th9xInterface::getEEpromSize()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString avrMCU = settings.value("mcu", QString("m64")).toString(); QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;

View file

@ -20,7 +20,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(QIcon(":/icon.png")); this->setWindowIcon(QIcon(":/icon.png"));
QSettings settings("companion", "companion"); QSettings settings;
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt());
int profile_id=settings.value("profileId", 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) void GeneralEdit::on_tabWidget_currentChanged(int index)
{ {
// TODO why er9x here // TODO why er9x here
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex()); settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex());
} }
@ -1195,7 +1195,7 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int )
void GeneralEdit::on_calretrieve_PB_clicked() void GeneralEdit::on_calretrieve_PB_clicked()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id); QString profile=QString("profile%1").arg(profile_id);
@ -1312,7 +1312,7 @@ void GeneralEdit::on_calretrieve_PB_clicked()
void GeneralEdit::on_calstore_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(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id); QString profile=QString("profile%1").arg(profile_id);

View file

@ -1485,19 +1485,10 @@ QString getCenterBeep(ModelData * g_model)
return strl.join(", "); 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() QString getTheme()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int theme_set=settings.value("theme", 1).toInt(); int theme_set = settings.value("theme", 1).toInt();
QString Theme; QString Theme;
switch(theme_set) { switch(theme_set) {
case 0: case 0:
@ -1508,4 +1499,14 @@ QString getTheme()
break; break;
} }
return Theme; 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));
}

View file

@ -28,9 +28,14 @@ void populateVoiceLangCB(QComboBox *b, QString language);
void populateTTraceCB(QComboBox *b, int value); void populateTTraceCB(QComboBox *b, int value);
void populateRotEncCB(QComboBox *b, int value, int renumber); void populateRotEncCB(QComboBox *b, int value, int renumber);
void populateBacklightCB(QComboBox *b, const uint8_t value); void populateBacklightCB(QComboBox *b, const uint8_t value);
void populate_icon(QIcon *Icon, QString baseimage);
QString getTheme(); QString getTheme();
class CompanionIcon: public QIcon {
public:
CompanionIcon(QString baseimage);
};
class GVarGroup : public QObject { class GVarGroup : public QObject {
Q_OBJECT Q_OBJECT

View file

@ -130,7 +130,7 @@ void joystickDialog::on_okButton_clicked() {
return; return;
} }
joystick->close(); joystick->close();
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("JsCalibration"); settings.beginGroup("JsCalibration");
for (int i=0; i<8;i++) { for (int i=0; i<8;i++) {
settings.remove(QString("stick%1_axe").arg(i)); settings.remove(QString("stick%1_axe").arg(i));

View file

@ -58,7 +58,7 @@ class lcdWidget : public QWidget {
QPixmap buffer(2*lcdWidth, 2*lcdHeight); QPixmap buffer(2*lcdWidth, 2*lcdHeight);
QPainter p(&buffer); QPainter p(&buffer);
doPaint(p); doPaint(p);
QSettings settings("companion", "companion"); QSettings settings;
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
QApplication::clipboard()->setPixmap( buffer ); QApplication::clipboard()->setPixmap( buffer );
if (!toclipboard) { if (!toclipboard) {

View file

@ -38,7 +38,7 @@ logsDialog::logsDialog(QWidget *parent) :
ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectedFont(legendFont);
ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items
ui->customPlot->legend->setVisible(false); ui->customPlot->legend->setVisible(false);
QSettings settings("companion", "companion"); QSettings settings;
QString Path=settings.value("gePath", "").toString(); QString Path=settings.value("gePath", "").toString();
if (Path.isEmpty() || !QFile(Path).exists()) { if (Path.isEmpty() || !QFile(Path).exists()) {
ui->mapsButton->hide(); 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\ ,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}; ,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(); QString gePath=settings.value("gePath", "").toString();
if (gePath.isEmpty() || !QFile(gePath).exists()) { if (gePath.isEmpty() || !QFile(gePath).exists()) {
ui->FieldsTW->setDisabled(false); ui->FieldsTW->setDisabled(false);
@ -578,7 +578,7 @@ void logsDialog::moveLegend()
void logsDialog::on_fileOpen_BT_clicked() 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()); QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), settings.value("lastLogDir").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("lastLogDir", fileName); settings.setValue("lastLogDir", fileName);

View file

@ -76,66 +76,69 @@ class MyProxyStyle : public QProxyStyle
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Start by borrowing any left over settings from companion9x QCoreApplication::setOrganizationName("OpenTX");
QSettings c9x_settings("companion9x", "companion9x"); QCoreApplication::setOrganizationDomain("open-tx.org");
QSettings com_settings("companion", "companion"); QCoreApplication::setApplicationName("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 ) );
}
}
Q_INIT_RESOURCE(companion); // Start by borrowing any left over settings from companion9x
QApplication app(argc, argv); QSettings c9x_settings("companion9x", "companion9x");
app.setApplicationName("OpenTX Companion"); 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__ #ifdef __APPLE__
app.setStyle(new MyProxyStyle); app.setStyle(new MyProxyStyle);
#endif #endif
QString dir;
if(argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";
QSettings settings("companion", "companion"); QString dir;
QString locale = settings.value("locale",QLocale::system().name()).toString(); if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";
bool showSplash = settings.value("show_splash", true).toBool();
QTranslator companionTranslator; QString locale = settings.value("locale",QLocale::system().name()).toString();
companionTranslator.load(":/companion_" + locale); bool showSplash = settings.value("show_splash", true).toBool();
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);
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(); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
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);
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); QPixmap pixmap = QPixmap(firmware_id.contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png");
current_firmware_variant = GetFirmwareVariant(firmware_id); QSplashScreen *splash = new QSplashScreen(pixmap);
// qDebug() << current_firmware_variant;
MainWindow mainWin; RegisterFirmwares();
if (showSplash) { settings.setValue("firmware", firmware_id);
splash->show(); current_firmware_variant = GetFirmwareVariant(firmware_id);
QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
QTimer::singleShot(1000*SPLASH_TIME, &mainWin, SLOT(show())); MainWindow *mainWin = new MainWindow();
} if (showSplash) {
else { splash->show();
mainWin.show(); QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
} QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));
return app.exec(); }
else {
mainWin->show();
}
int result = app.exec();
delete splash;
delete mainWin;
return result;
} }

View file

@ -62,28 +62,26 @@
#include "helpers.h" #include "helpers.h"
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include #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__ #ifdef __APPLE__
#define C9X_STAMP "http://companion9x.googlecode.com/svn/trunk/companion9x-macosx.stamp" #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-macosx.stamp"
#define C9X_INSTALLER "/Companion9xMacUpdate.%1.pkg.zip" #define C9X_INSTALLER "/CompanionMacUpdate.%1.pkg.zip"
#define C9X_URL "http://companion9x.googlecode.com/files/Companion9xMacUpdate.%1.pkg.zip"
#else #else
#define C9X_STAMP "http://companion9x.googlecode.com/svn/trunk/companion9x.stamp" #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-windows.stamp"
#define C9X_INSTALLER "/companion9xInstall_v%1.exe" #define C9X_INSTALLER "/companionInstall_%1.exe"
#define C9X_URL "http://companion9x.googlecode.com/files/companion9xInstall_v%1.exe"
#endif #endif
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
#include <windows.h> #include <windows.h>
#define sleep(x) Sleep(x*1000) #define sleep(x) Sleep(x*1000)
#else #else
#include <unistd.h> #include <unistd.h>
#include "mountlist.h" #include "mountlist.h"
#endif #endif
MainWindow::MainWindow(): MainWindow::MainWindow():
downloadDialog_forWait(NULL) downloadDialog_forWait(NULL)
{ {
mdiArea = new QMdiArea; mdiArea = new QMdiArea;
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@ -96,7 +94,7 @@ downloadDialog_forWait(NULL)
this, SLOT(setActiveSubWindow(QWidget*))); this, SLOT(setActiveSubWindow(QWidget*)));
MaxRecentFiles=MAX_RECENT; MaxRecentFiles=MAX_RECENT;
QSettings settings("companion", "companion"); QSettings settings;
int icon_size=settings.value("icon_size", 1).toInt(); int icon_size=settings.value("icon_size", 1).toInt();
switch (icon_size) { switch (icon_size) {
case 0: case 0:
@ -138,8 +136,9 @@ downloadDialog_forWait(NULL)
// give time to the splash to disappear and main window to open before starting updates // give time to the splash to disappear and main window to open before starting updates
int updateDelay = 1000; int updateDelay = 1000;
bool showSplash = settings.value("show_splash", true).toBool(); bool showSplash = settings.value("show_splash", true).toBool();
if (showSplash) if (showSplash) {
updateDelay += (SPLASH_TIME*1000); updateDelay += (SPLASH_TIME*1000);
}
QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates())); QTimer::singleShot(updateDelay, this, SLOT(doAutoUpdates()));
QTimer::singleShot(updateDelay, this, SLOT(displayWarnings())); QTimer::singleShot(updateDelay, this, SLOT(displayWarnings()));
@ -189,7 +188,7 @@ downloadDialog_forWait(NULL)
void MainWindow::displayWarnings() void MainWindow::displayWarnings()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int warnId=settings.value("warningId", 0 ).toInt(); int warnId=settings.value("warningId", 0 ).toInt();
if (warnId<WARNING_ID && warnId!=0) { if (warnId<WARNING_ID && warnId!=0) {
int res=0; int res=0;
@ -223,7 +222,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
showcheckForUpdatesResult = ignoreSettings; showcheckForUpdatesResult = ignoreSettings;
check1done = true; check1done = true;
check2done = true; check2done = true;
QSettings settings("companion", "companion"); QSettings settings;
fwToUpdate = fwId; fwToUpdate = fwId;
QString stamp = GetFirmware(fwToUpdate)->stamp; QString stamp = GetFirmware(fwToUpdate)->stamp;
@ -289,7 +288,7 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply)
"Would you like to download it?").arg(version) , "Would you like to download it?").arg(version) ,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
QSettings settings("companion", "companion"); QSettings settings;
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
#if defined __APPLE__ #if defined __APPLE__
@ -299,14 +298,14 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply)
#endif #endif
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("lastUpdatesDir", QFileInfo(fileName).dir().absolutePath()); 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; installer_fileName = fileName;
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
dd->show(); dd->show();
} }
} }
#else #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 #endif
} else { } else {
if (showcheckForUpdatesResult && check1done && check2done) if (showcheckForUpdatesResult && check1done && check2done)
@ -331,7 +330,7 @@ void MainWindow::updateDownloaded()
void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId) void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId)
{ {
QString url, ext, cpuid; QString url, ext, cpuid;
QSettings settings("companion", "companion"); QSettings settings;
url = firmware->getUrl(firmwareId); url = firmware->getUrl(firmwareId);
cpuid=settings.value("cpuid","").toString(); cpuid=settings.value("cpuid","").toString();
ext = url.mid(url.lastIndexOf(".")); ext = url.mid(url.lastIndexOf("."));
@ -354,7 +353,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
void MainWindow::reply1Accepted() void MainWindow::reply1Accepted()
{ {
QString errormsg; QString errormsg;
QSettings settings("companion", "companion"); QSettings settings;
bool autoflash=settings.value("burnFirmware", true).toBool(); bool autoflash=settings.value("burnFirmware", true).toBool();
bool addversion=settings.value("rename_firmware_files", false).toBool(); bool addversion=settings.value("rename_firmware_files", false).toBool();
settings.beginGroup("FwRevisions"); settings.beginGroup("FwRevisions");
@ -478,7 +477,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
// TODO delete downloadDialog_forWait? // TODO delete downloadDialog_forWait?
} }
QSettings settings("companion", "companion"); QSettings settings;
cpuid=settings.value("cpuid","").toString(); cpuid=settings.value("cpuid","").toString();
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
int i = qba.indexOf("SVN_VERS"); int i = qba.indexOf("SVN_VERS");
@ -630,13 +629,14 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("mainWindowGeometry", saveGeometry()); settings.setValue("mainWindowGeometry", saveGeometry());
settings.setValue("mainWindowState", saveState()); settings.setValue("mainWindowState", saveState());
mdiArea->closeAllSubWindows(); mdiArea->closeAllSubWindows();
if (mdiArea->currentSubWindow()) { if (mdiArea->currentSubWindow()) {
event->ignore(); event->ignore();
} else { }
else {
event->accept(); event->accept();
} }
} }
@ -650,7 +650,7 @@ void MainWindow::newFile()
void MainWindow::openFile() void MainWindow::openFile()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
@ -683,7 +683,7 @@ void MainWindow::saveAs()
void MainWindow::openRecentFile() void MainWindow::openRecentFile()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
if (action) { if (action) {
QString fileName=action->data().toString(); QString fileName=action->data().toString();
@ -705,14 +705,14 @@ void MainWindow::openRecentFile()
void MainWindow::loadProfile() void MainWindow::loadProfile()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
int chord,defmod, burnfw; int chord,defmod, burnfw;
bool renfw; bool renfw;
if (action) { if (action) {
int profnum=action->data().toInt(); int profnum=action->data().toInt();
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("ActiveProfile",profnum); settings.setValue("ActiveProfile",profnum);
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profnum); QString profile=QString("profile%1").arg(profnum);
@ -757,8 +757,8 @@ void MainWindow::unloadProfile()
{ {
ActiveProfile=0; ActiveProfile=0;
ActiveProfileName=""; ActiveProfileName="";
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("ActiveProfile",0); settings.setValue("ActiveProfile", 0);
FirmwareInfo *firmware = GetCurrentFirmware(); FirmwareInfo *firmware = GetCurrentFirmware();
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
} }
@ -770,7 +770,8 @@ void MainWindow::preferences()
FirmwareInfo *firmware = GetCurrentFirmware(); FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) { if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); 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)); setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
} }
@ -1080,21 +1081,17 @@ void MainWindow::burnFrom()
QStringList str; QStringList str;
str << path << tempFile; str << path << tempFile;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
res = ad->exec(); res = ad->exec();
sleep(1); sleep(1);
} }
} else { } else {
QStringList str = GetReceiveEEpromCommand(tempFile); QStringList str = GetReceiveEEpromCommand(tempFile);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
res = ad->exec(); res = ad->exec();
} }
if(QFileInfo(tempFile).exists() && res) { if (QFileInfo(tempFile).exists() && res) {
MdiChild *child = createMdiChild(); MdiChild *child = createMdiChild();
child->newFile(); child->newFile();
child->loadFile(tempFile, false); child->loadFile(tempFile, false);
@ -1104,7 +1101,7 @@ void MainWindow::burnFrom()
void MainWindow::burnExtenalToEEPROM() void MainWindow::burnExtenalToEEPROM()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString fileName; QString fileName;
bool backup = false; bool backup = false;
burnDialog *cd = new burnDialog(this, 1, &fileName, &backup); burnDialog *cd = new burnDialog(this, 1, &fileName, &backup);
@ -1141,18 +1138,14 @@ void MainWindow::burnExtenalToEEPROM()
QStringList str; QStringList str;
str << path << backupFile; str << path << backupFile;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
sleep(1); sleep(1);
} }
} else { } else {
QStringList str = GetReceiveEEpromCommand(backupFile); QStringList str = GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"));
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
sleep(1); sleep(1);
} }
@ -1162,9 +1155,7 @@ void MainWindow::burnExtenalToEEPROM()
QString tempFlash = tempDir + "/flash.bin"; QString tempFlash = tempDir + "/flash.bin";
QStringList str = GetReceiveFlashCommand(tempFlash); QStringList str = GetReceiveFlashCommand(tempFlash);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx");
QIcon icon; ad->setWindowIcon(CompanionIcon("read_flash.png"));
populate_icon(&icon,"read_flash.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
sleep(1); sleep(1);
QString restoreFile = tempDir + "/compat.bin"; QString restoreFile = tempDir + "/compat.bin";
@ -1177,7 +1168,8 @@ void MainWindow::burnExtenalToEEPROM()
int rev = getEpromVersion(restoreFile); int rev = getEpromVersion(restoreFile);
if ((rev / 100) != (oldrev / 100)) { if ((rev / 100) != (oldrev / 100)) {
QMessageBox::warning(this, tr("Warning"), tr("The transmitter firmware belongs to another product family, check file and preferences!")); 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!")); QMessageBox::warning(this, tr("Warning"), tr("The transmitter firmware is outdated, please upgrade!"));
} }
fileName = restoreFile; fileName = restoreFile;
@ -1197,19 +1189,18 @@ void MainWindow::burnExtenalToEEPROM()
QStringList str; QStringList str;
str << path << backupFile; str << path << backupFile;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
} else { }
else {
QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"));
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
} }
@ -1219,23 +1210,23 @@ void MainWindow::burnExtenalToEEPROM()
if (path.isEmpty()) { 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.")); 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; return;
} else { }
else {
QStringList str; QStringList str;
str << fileName << path; str << fileName << path;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write Models and Settings To Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write Models and Settings To Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
} else { }
else {
QStringList str = GetSendEEpromCommand(fileName); QStringList str = GetSendEEpromCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Write Models and Settings To Tx", AVR_DIALOG_SHOW_DONE); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Write Models and Settings To Tx", AVR_DIALOG_SHOW_DONE);
QIcon icon; ad->setWindowIcon(CompanionIcon("write_eeprom.png"));
populate_icon(&icon,"write_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
} }
} }
} }
@ -1327,7 +1318,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
} else { } else {
version = fwBuild.toInt(); // TODO changer le nom de la variable version = fwBuild.toInt(); // TODO changer le nom de la variable
} }
} else { }
else {
version = ((Open9xFirmware *)firmware)->getEepromVersion(revision); 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); long result = file.read((char*)eeprom, eeprom_size);
file.close(); file.close();
RadioData radioData; QSharedPointer<RadioData> radioData = QSharedPointer<RadioData>(new RadioData());
if (!LoadEeprom(radioData, eeprom, eeprom_size)) if (!LoadEeprom(*radioData, eeprom, eeprom_size) || !firmware->saveEEPROM(eeprom, *radioData, variant, version))
return false;
if (!firmware->saveEEPROM(eeprom, radioData, variant, version))
return false; return false;
QFile file2(restoreFile); QFile file2(restoreFile);
@ -1366,7 +1355,7 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
void MainWindow::burnToFlash(QString fileToFlash) void MainWindow::burnToFlash(QString fileToFlash)
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString fileName; QString fileName;
bool backup = settings.value("backupOnFlash", false).toBool(); bool backup = settings.value("backupOnFlash", false).toBool();
if(!fileToFlash.isEmpty()) if(!fileToFlash.isEmpty())
@ -1399,18 +1388,17 @@ void MainWindow::burnToFlash(QString fileToFlash)
} }
QStringList str = GetReceiveEEpromCommand(backupFile); QStringList str = GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
int res = ad->exec(); int res = ad->exec();
delete ad;
if (QFileInfo(backupFile).exists() && res) { if (QFileInfo(backupFile).exists() && res) {
sleep(1); sleep(1);
QStringList str = GetSendFlashCommand(fileName); QStringList str = GetSendFlashCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL);
QIcon iconw; CompanionIcon iconw("write_eeprom.png");
populate_icon(&iconw,"write_eeprom.png");
ad->setWindowIcon(iconw); ad->setWindowIcon(iconw);
int res = ad->exec(); int res = ad->exec();
delete ad;
if (res) { if (res) {
QString restoreFile = tempDir + "/restore.bin"; QString restoreFile = tempDir + "/restore.bin";
if (!convertEEPROM(backupFile, restoreFile, fileName)) { if (!convertEEPROM(backupFile, restoreFile, fileName)) {
@ -1421,17 +1409,21 @@ void MainWindow::burnToFlash(QString fileToFlash)
QStringList str = GetSendEEpromCommand(restoreFile); QStringList str = GetSendEEpromCommand(restoreFile);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Restore Models and Settings To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Restore Models and Settings To Tx"), AVR_DIALOG_CLOSE_IF_SUCCESSFUL);
ad->setWindowIcon(iconw); ad->setWindowIcon(iconw);
res=ad->exec(); res = ad->exec();
delete ad;
if (!res) { 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)); 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)); 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")); 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(); bool backupEnable=settings.value("backupEnable", true).toBool();
QString backupPath=settings.value("backupPath", "").toString(); QString backupPath=settings.value("backupPath", "").toString();
if (!QDir(backupPath).exists()) { 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"; QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin";
QStringList str = GetReceiveEEpromCommand(backupFile); QStringList str = GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Backup Models and Settings From Tx"));
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
QStringList str = GetSendFlashCommand(fileName); QStringList str = GetSendFlashCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_SHOW_DONE); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Write Firmware To Tx"), AVR_DIALOG_SHOW_DONE);
QIcon iconw; ad->setWindowIcon(CompanionIcon("write_flash.png"));
populate_icon(&iconw,"write_flash.png");
ad->setWindowIcon(iconw);
ad->exec(); ad->exec();
delete ad;
} }
} }
} }
void MainWindow::burnExtenalFromEEPROM() 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)); 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()) { if (!fileName.isEmpty()) {
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
@ -1473,30 +1463,30 @@ void MainWindow::burnExtenalFromEEPROM()
if (path.isEmpty()) { 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.")); 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; return;
} else { }
else {
QStringList str; QStringList str;
str << path << fileName; str << path << fileName;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Read Models and Settings From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
} }
} else { }
else {
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveEEpromCommand(fileName); QStringList str = GetReceiveEEpromCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx"));
QIcon icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&icon,"read_eeprom.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
} }
} }
} }
void MainWindow::burnFromFlash() 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)); QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), settings.value("lastFlashDir").toString(),tr(FLASH_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QFile file(fileName); QFile file(fileName);
@ -1506,12 +1496,10 @@ void MainWindow::burnFromFlash()
settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveFlashCommand(fileName); QStringList str = GetReceiveFlashCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx");
QIcon icon; ad->setWindowIcon(CompanionIcon("read_flash.png"));
populate_icon(&icon,"read_flash.png");
ad->setWindowIcon(icon);
ad->exec(); ad->exec();
delete ad;
} }
} }
void MainWindow::burnConfig() void MainWindow::burnConfig()
@ -1547,7 +1535,7 @@ void MainWindow::logFile()
void MainWindow::about() void MainWindow::about()
{ {
QString aboutStr = "<center><img src=\":/images/companion-title.png\"></center><br>"; QString aboutStr = "<center><img src=\":/images/companion-title.png\"></center><br>";
aboutStr.append("OpenTX Home Page: <a href='http://opentx.github.io'>http://open-tx.org</a><br><br>"); aboutStr.append("OpenTX Home Page: <a href='http://opentx.github.io'>http://www.open-tx.org</a><br><br>");
aboutStr.append(tr("The Companion project was originally forked from eePe")+QString(" <a href='http://code.google.com/p/eepe'>http://code.google.com/p/eepe</a><br/><br/>")); aboutStr.append(tr("The Companion project was originally forked from eePe")+QString(" <a href='http://code.google.com/p/eepe'>http://code.google.com/p/eepe</a><br/><br/>"));
aboutStr.append(tr("If you've found this program useful, please support by")); aboutStr.append(tr("If you've found this program useful, please support by"));
aboutStr.append(" <a href='" DONATE_STR "'>"); aboutStr.append(" <a href='" DONATE_STR "'>");
@ -1584,7 +1572,7 @@ void MainWindow::updateMenus()
updateRecentFileActions(); updateRecentFileActions();
updateProfilesActions(); updateProfilesActions();
bool notfound=true; bool notfound=true;
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
for (int i=0; i<MAX_PROFILES; i++) { for (int i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1); QString profile=QString("profile%1").arg(i+1);
@ -1648,191 +1636,134 @@ MdiChild *MainWindow::createMdiChild()
void MainWindow::createActions() void MainWindow::createActions()
{ {
QIcon newActIcon; newAct = new QAction(CompanionIcon("new.png"), tr("&New"), this);
populate_icon(&newActIcon,"new.png");
newAct = new QAction(newActIcon, tr("&New"), this);
newAct->setShortcuts(QKeySequence::New); newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file")); newAct->setStatusTip(tr("Create a new file"));
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
QIcon openActIcon; openAct = new QAction(CompanionIcon("open.png"), tr("&Open..."), this);
populate_icon(&openActIcon,"open.png");
openAct = new QAction(openActIcon, tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open); openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file")); openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(openFile())); 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")); loadbackupAct->setStatusTip(tr("Load backup from file"));
connect(loadbackupAct, SIGNAL(triggered()), this, SLOT(loadBackup())); connect(loadbackupAct, SIGNAL(triggered()), this, SLOT(loadBackup()));
QIcon saveActIcon; saveAct = new QAction(CompanionIcon("save.png"), tr("&Save"), this);
populate_icon(&saveActIcon,"save.png");
saveAct = new QAction(saveActIcon, tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save); saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk")); saveAct->setStatusTip(tr("Save the document to disk"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
QIcon saveAsActIcon; saveAsAct = new QAction(CompanionIcon("saveas.png"), tr("Save &As..."), this);
populate_icon(&saveAsActIcon,"saveas.png");
saveAsAct = new QAction(saveAsActIcon, tr("Save &As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs); saveAsAct->setShortcuts(QKeySequence::SaveAs);
saveAsAct->setStatusTip(tr("Save the document under a new name")); saveAsAct->setStatusTip(tr("Save the document under a new name"));
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
QIcon logsActIcon; logsAct = new QAction(CompanionIcon("logs.png"), tr("Lo&gs"), this);
populate_icon(&logsActIcon,"logs.png");
logsAct = new QAction(logsActIcon, tr("Lo&gs"), this);
logsAct->setShortcut(tr("Ctrl+G")); logsAct->setShortcut(tr("Ctrl+G"));
logsAct->setStatusTip(tr("Open log file")); logsAct->setStatusTip(tr("Open log file"));
connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile())); connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile()));
QIcon preferencesActIcon; preferencesAct = new QAction(CompanionIcon("preferences.png"), tr("&Preferences..."), this);
populate_icon(&preferencesActIcon,"preferences.png");
preferencesAct = new QAction(preferencesActIcon, tr("&Preferences..."), this);
preferencesAct->setStatusTip(tr("Edit general preferences")); preferencesAct->setStatusTip(tr("Edit general preferences"));
connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences())); connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences()));
QIcon checkForUpdatesActIcon; checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this);
populate_icon(&checkForUpdatesActIcon,"update.png");
checkForUpdatesAct = new QAction(checkForUpdatesActIcon, tr("&Check for updates..."), this);
checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion")); checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion"));
connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates())); connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates()));
QIcon contributorsActIcon; contributorsAct = new QAction(CompanionIcon("contributors.png"), tr("Contributors &List..."), this);
populate_icon(&contributorsActIcon,"contributors.png");
contributorsAct = new QAction(contributorsActIcon, tr("Contributors &List..."), this);
contributorsAct->setStatusTip(tr("Show Companion contributors list")); contributorsAct->setStatusTip(tr("Show Companion contributors list"));
connect(contributorsAct, SIGNAL(triggered()), this, SLOT(contributors())); connect(contributorsAct, SIGNAL(triggered()), this, SLOT(contributors()));
QIcon changelogActIcon; changelogAct = new QAction(CompanionIcon("changelog.png"), tr("ChangeLog..."), this);
populate_icon(&changelogActIcon,"changelog.png");
changelogAct = new QAction(changelogActIcon, tr("ChangeLog..."), this);
changelogAct->setStatusTip(tr("Show Companion changelog")); changelogAct->setStatusTip(tr("Show Companion changelog"));
connect(changelogAct, SIGNAL(triggered()), this, SLOT(changelog())); connect(changelogAct, SIGNAL(triggered()), this, SLOT(changelog()));
QIcon fwchangelogActIcon; fwchangelogAct = new QAction(CompanionIcon("changelog.png"), tr("Firmware ChangeLog..."), this);
populate_icon(&fwchangelogActIcon,"changelog.png");
fwchangelogAct = new QAction(fwchangelogActIcon, tr("Firmware ChangeLog..."), this);
fwchangelogAct->setStatusTip(tr("Show firmware changelog")); fwchangelogAct->setStatusTip(tr("Show firmware changelog"));
connect(fwchangelogAct, SIGNAL(triggered()), this, SLOT(fwchangelog())); connect(fwchangelogAct, SIGNAL(triggered()), this, SLOT(fwchangelog()));
QIcon compareActIcon; compareAct = new QAction(CompanionIcon("customize.png"), tr("Compare..."), this);
populate_icon(&compareActIcon,"compare.png");
compareAct = new QAction(compareActIcon, tr("Compare..."), this);
compareAct->setStatusTip(tr("Compare models")); compareAct->setStatusTip(tr("Compare models"));
compareAct->setEnabled(false); compareAct->setEnabled(false);
connect(compareAct, SIGNAL(triggered()), this, SLOT(compare())); connect(compareAct, SIGNAL(triggered()), this, SLOT(compare()));
QIcon customizeSplashActIcon; customizeSplashAct = new QAction(CompanionIcon("customize.png"), tr("Customize your &TX..."), this);
populate_icon(&customizeSplashActIcon,"customize.png");
customizeSplashAct = new QAction(customizeSplashActIcon, tr("Customize your &TX..."), this);
customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX")); customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX"));
connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash())); connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash()));
//! [0] exitAct = new QAction(CompanionIcon("exit.png"), tr("E&xit"), this);
QIcon exitActIcon;
populate_icon(&exitActIcon,"exit.png");
exitAct = new QAction(exitActIcon, tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit); exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application")); exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
//! [0]
QIcon cutActIcon; cutAct = new QAction(CompanionIcon("cut.png"), tr("Cu&t"), this);
populate_icon(&cutActIcon,"cut.png");
cutAct = new QAction(cutActIcon, tr("Cu&t"), this);
cutAct->setShortcuts(QKeySequence::Cut); cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the " cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard")); "clipboard"));
connect(cutAct, SIGNAL(triggered()), this, SLOT(cut())); connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
QIcon copyActIcon; copyAct = new QAction(CompanionIcon("copy.png"), tr("&Copy"), this);
populate_icon(&copyActIcon,"copy.png");
copyAct = new QAction(copyActIcon, tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy); copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the " copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard")); "clipboard"));
connect(copyAct, SIGNAL(triggered()), this, SLOT(copy())); connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
QIcon pasteActIcon; pasteAct = new QAction(CompanionIcon("paste.png"), tr("&Paste"), this);
populate_icon(&pasteActIcon,"paste.png");
pasteAct = new QAction(pasteActIcon, tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste); pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection")); "selection"));
connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste())); connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
QIcon burnToActIcon; burnToAct = new QAction(CompanionIcon("write_eeprom.png"), tr("&Write Models and Settings To Tx"), this);
populate_icon(&burnToActIcon,"write_eeprom.png");
burnToAct = new QAction(burnToActIcon, tr("&Write Models and Settings To Tx"), this);
burnToAct->setShortcut(tr("Ctrl+Alt+W")); burnToAct->setShortcut(tr("Ctrl+Alt+W"));
burnToAct->setStatusTip(tr("Write Models and Settings to transmitter")); burnToAct->setStatusTip(tr("Write Models and Settings to transmitter"));
connect(burnToAct,SIGNAL(triggered()),this,SLOT(burnTo())); connect(burnToAct,SIGNAL(triggered()),this,SLOT(burnTo()));
QIcon burnFromActIcon; burnFromAct = new QAction(CompanionIcon("read_eeprom.png"), tr("&Read Models and Settings From Tx"), this);
populate_icon(&burnFromActIcon,"read_eeprom.png");
burnFromAct = new QAction(burnFromActIcon, tr("&Read Models and Settings From Tx"), this);
burnFromAct->setShortcut(tr("Ctrl+Alt+R")); burnFromAct->setShortcut(tr("Ctrl+Alt+R"));
burnFromAct->setStatusTip(tr("Read Models and Settings from transmitter")); burnFromAct->setStatusTip(tr("Read Models and Settings from transmitter"));
connect(burnFromAct,SIGNAL(triggered()),this,SLOT(burnFrom())); connect(burnFromAct,SIGNAL(triggered()),this,SLOT(burnFrom()));
QIcon burnToFlashActIcon; burnToFlashAct = new QAction(CompanionIcon("write_flash.png"), tr("Write Firmware"), this);
populate_icon(&burnToFlashActIcon,"write_flash.png");
burnToFlashAct = new QAction(burnToFlashActIcon, tr("Write Firmware"), this);
burnToFlashAct->setStatusTip(tr("Write firmware to transmitter")); burnToFlashAct->setStatusTip(tr("Write firmware to transmitter"));
connect(burnToFlashAct,SIGNAL(triggered()),this,SLOT(burnToFlash())); connect(burnToFlashAct,SIGNAL(triggered()),this,SLOT(burnToFlash()));
QIcon burnExtenalToEEPROMActIcon; burnExtenalToEEPROMAct = new QAction(CompanionIcon("write_eeprom_file.png"), tr("Write Models and Settings from file to Tx"), this);
populate_icon(&burnExtenalToEEPROMActIcon,"write_eeprom_file.png");
burnExtenalToEEPROMAct = new QAction(burnExtenalToEEPROMActIcon, tr("Write Models and Settings from file to Tx"), this);
burnExtenalToEEPROMAct->setStatusTip(tr("Write Models and Settings from file to transmitter")); burnExtenalToEEPROMAct->setStatusTip(tr("Write Models and Settings from file to transmitter"));
connect(burnExtenalToEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalToEEPROM())); connect(burnExtenalToEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalToEEPROM()));
QIcon burnExtenalFromEEPROMActIcon; burnExtenalFromEEPROMAct = new QAction(CompanionIcon("read_eeprom_file.png"), tr("Save transmitter Models and Settings to file"), this);
populate_icon(&burnExtenalFromEEPROMActIcon,"read_eeprom_file.png");
burnExtenalFromEEPROMAct = new QAction(burnExtenalFromEEPROMActIcon, tr("Save transmitter Models and Settings to file"), this);
burnExtenalFromEEPROMAct->setStatusTip(tr("Save the Models and Settings from the transmitter to a file")); burnExtenalFromEEPROMAct->setStatusTip(tr("Save the Models and Settings from the transmitter to a file"));
connect(burnExtenalFromEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalFromEEPROM())); connect(burnExtenalFromEEPROMAct,SIGNAL(triggered()),this,SLOT(burnExtenalFromEEPROM()));
QIcon burnFromFlashActIcon; burnFromFlashAct = new QAction(CompanionIcon("read_flash.png"), tr("Read Firmware"), this);
populate_icon(&burnFromFlashActIcon,"read_flash.png");
burnFromFlashAct = new QAction(burnFromFlashActIcon, tr("Read Firmware"), this);
burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter")); burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter"));
connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash())); connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash()));
QIcon burnConfigActIcon; burnConfigAct = new QAction(CompanionIcon("configure.png"), tr("&Configure..."), this);
populate_icon(&burnConfigActIcon,"configure.png");
burnConfigAct = new QAction(burnConfigActIcon, tr("&Configure..."), this);
burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter")); burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter"));
connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig())); connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig()));
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
if (!IS_ARM(eepromInterface->getBoard())) { if (!IS_ARM(eepromInterface->getBoard())) {
QIcon burnListActIcon; burnListAct = new QAction(CompanionIcon("list.png"), tr("&List programmers"), this);
populate_icon(&burnListActIcon,"list.png");
burnListAct = new QAction(burnListActIcon, tr("&List programmers"), this);
burnListAct->setStatusTip(tr("List available programmers")); burnListAct->setStatusTip(tr("List available programmers"));
connect(burnListAct,SIGNAL(triggered()),this,SLOT(burnList())); connect(burnListAct,SIGNAL(triggered()),this,SLOT(burnList()));
QIcon burnFusesActIcon; burnFusesAct = new QAction(CompanionIcon("fuses.png"), tr("&Fuses..."), this);
populate_icon(&burnFusesActIcon,"fuses.png");
burnFusesAct = new QAction(burnFusesActIcon, tr("&Fuses..."), this);
burnFusesAct->setStatusTip(tr("Show fuses dialog")); burnFusesAct->setStatusTip(tr("Show fuses dialog"));
connect(burnFusesAct,SIGNAL(triggered()),this,SLOT(burnFuses())); connect(burnFusesAct,SIGNAL(triggered()),this,SLOT(burnFuses()));
} }
QIcon simulateActIcon;
populate_icon(&simulateActIcon,"simulate.png"); simulateAct = new QAction(CompanionIcon("simulate.png"), tr("&Simulate"), this);
simulateAct = new QAction(simulateActIcon, tr("&Simulate"), this);
simulateAct->setShortcut(tr("Alt+S")); simulateAct->setShortcut(tr("Alt+S"));
simulateAct->setStatusTip(tr("Simulate selected model.")); simulateAct->setStatusTip(tr("Simulate selected model."));
simulateAct->setEnabled(false); simulateAct->setEnabled(false);
connect(simulateAct,SIGNAL(triggered()),this,SLOT(simulate())); connect(simulateAct,SIGNAL(triggered()),this,SLOT(simulate()));
QIcon printActIcon; printAct = new QAction(CompanionIcon("print.png"), tr("&Print"), this);
populate_icon(&printActIcon,"print.png");
printAct = new QAction(printActIcon, tr("&Print"), this);
printAct->setShortcut(tr("Ctrl+P")); printAct->setShortcut(tr("Ctrl+P"));
printAct->setStatusTip(tr("Print current model.")); printAct->setStatusTip(tr("Print current model."));
printAct->setEnabled(false); printAct->setEnabled(false);
@ -1872,15 +1803,11 @@ void MainWindow::createActions()
separatorAct = new QAction(this); separatorAct = new QAction(this);
separatorAct->setSeparator(true); separatorAct->setSeparator(true);
QIcon aboutActIcon; aboutAct = new QAction(CompanionIcon("information.png"), tr("&About"), this);
populate_icon(&aboutActIcon,"information.png");
aboutAct = new QAction(aboutActIcon, tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box")); aboutAct->setStatusTip(tr("Show the application's About box"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
QIcon switchLayoutDirectionActIcon; switchLayoutDirectionAct = new QAction(CompanionIcon("switch_dir.png"), tr("Switch layout direction"), this);
populate_icon(&switchLayoutDirectionActIcon,"switch_dir.png");
switchLayoutDirectionAct = new QAction(switchLayoutDirectionActIcon, tr("Switch layout direction"), this);
switchLayoutDirectionAct->setStatusTip(tr("Switch layout Left/Right")); switchLayoutDirectionAct->setStatusTip(tr("Switch layout Left/Right"));
connect(switchLayoutDirectionAct, SIGNAL(triggered()), this, SLOT(switchLayoutDirection())); connect(switchLayoutDirectionAct, SIGNAL(triggered()), this, SLOT(switchLayoutDirection()));
for (int i = 0; i < MaxRecentFiles; ++i) { for (int i = 0; i < MaxRecentFiles; ++i) {
@ -1910,10 +1837,8 @@ void MainWindow::createMenus()
fileMenu->addAction(saveAct); fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct); fileMenu->addAction(saveAsAct);
fileMenu->addMenu(recentFileMenu); fileMenu->addMenu(recentFileMenu);
QIcon recentFileMenuIcon; recentFileMenu->setIcon(CompanionIcon("recentdocument.png"));
populate_icon(&recentFileMenuIcon,"recentdocument.png"); for (int i=0; i<MaxRecentFiles; ++i)
recentFileMenu->setIcon(recentFileMenuIcon);
for ( int i = 0; i < MaxRecentFiles; ++i)
recentFileMenu->addAction(recentFileActs[i]); recentFileMenu->addAction(recentFileActs[i]);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(logsAct); fileMenu->addAction(logsAct);
@ -1925,10 +1850,8 @@ void MainWindow::createMenus()
fileMenu->addAction(preferencesAct); fileMenu->addAction(preferencesAct);
fileMenu->addMenu(profilesMenu); fileMenu->addMenu(profilesMenu);
QIcon profilesMenuIcon; profilesMenu->setIcon(CompanionIcon("profiles.png"));
populate_icon(&profilesMenuIcon,"profiles.png"); for (int i=0; i<MAX_PROFILES; ++i)
profilesMenu->setIcon(profilesMenuIcon);
for ( int i = 0; i < MAX_PROFILES; ++i)
profilesMenu->addAction(profileActs[i]); profilesMenu->addAction(profileActs[i]);
fileMenu->addAction(switchLayoutDirectionAct); fileMenu->addAction(switchLayoutDirectionAct);
fileMenu->addAction(exitAct); fileMenu->addAction(exitAct);
@ -1992,7 +1915,7 @@ QMenu *MainWindow::createProfilesMenu()
void MainWindow::createToolBars() void MainWindow::createToolBars()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int icon_size=settings.value("icon_size",2 ).toInt(); int icon_size=settings.value("icon_size",2 ).toInt();
QSize size; QSize size;
switch(icon_size) { switch(icon_size) {
@ -2017,9 +1940,7 @@ void MainWindow::createToolBars()
QToolButton * recentToolButton = new QToolButton; QToolButton * recentToolButton = new QToolButton;
recentToolButton->setPopupMode(QToolButton::InstantPopup); recentToolButton->setPopupMode(QToolButton::InstantPopup);
recentToolButton->setMenu(createRecentFileMenu()); recentToolButton->setMenu(createRecentFileMenu());
QIcon recentToolButtonIcon; recentToolButton->setIcon(CompanionIcon("recentdocument.png"));
populate_icon(&recentToolButtonIcon,"recentdocument.png");
recentToolButton->setIcon(recentToolButtonIcon);
recentToolButton->setToolTip(tr("Recent Files")); recentToolButton->setToolTip(tr("Recent Files"));
fileToolBar->addWidget(recentToolButton); fileToolBar->addWidget(recentToolButton);
fileToolBar->addAction(saveAct); fileToolBar->addAction(saveAct);
@ -2029,9 +1950,7 @@ void MainWindow::createToolBars()
profileButton = new QToolButton; profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup); profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu()); profileButton->setMenu(createProfilesMenu());
QIcon profileButtonIcon; profileButton->setIcon(CompanionIcon("profiles.png"));
populate_icon(&profileButtonIcon,"profiles.png");
profileButton->setIcon(profileButtonIcon);
profileButton->setToolTip(tr("Firmware Profiles")); profileButton->setToolTip(tr("Firmware Profiles"));
fileToolBar->addWidget(profileButton); fileToolBar->addWidget(profileButton);
bool notfound=true; bool notfound=true;
@ -2088,7 +2007,7 @@ void MainWindow::createStatusBar()
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
QSettings settings("companion", "companion"); QSettings settings;
restoreState(settings.value("mainWindowState").toByteArray()); restoreState(settings.value("mainWindowState").toByteArray());
checkCompanion9x = settings.value("startup_check_companion", true).toBool(); checkCompanion9x = settings.value("startup_check_companion", true).toBool();
checkFW = settings.value("startup_check_fw", true).toBool(); checkFW = settings.value("startup_check_fw", true).toBool();
@ -2141,7 +2060,7 @@ void MainWindow::setActiveSubWindow(QWidget *window)
void MainWindow::updateRecentFileActions() void MainWindow::updateRecentFileActions()
{ {
int i,j, numRecentFiles; int i,j, numRecentFiles;
QSettings settings("companion", "companion"); QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
@ -2161,7 +2080,7 @@ void MainWindow::updateRecentFileActions()
void MainWindow::updateProfilesActions() void MainWindow::updateProfilesActions()
{ {
int i; int i;
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
for (i=0; i<MAX_PROFILES; i++) { for (i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1); QString profile=QString("profile%1").arg(i+1);
@ -2278,7 +2197,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QString fileName = urls.first().toLocalFile(); QString fileName = urls.first().toLocalFile();
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);

View file

@ -68,11 +68,8 @@ MdiChild::MdiChild():
isUntitled(true), isUntitled(true),
fileChanged(false) fileChanged(false)
{ {
QIcon SimulateIcon;
populate_icon(&SimulateIcon,"simulate.png");
ui->setupUi(this); ui->setupUi(this);
ui->SimulateTxButton->setIcon(SimulateIcon); ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png"));
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
eepromInterfaceChanged(); eepromInterfaceChanged();
@ -182,7 +179,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
} }
if (isNew && !wizard) { if (isNew && !wizard) {
int ret; int ret;
QSettings settings("companion", "companion"); QSettings settings;
bool wizardEnable=settings.value("wizardEnable", true).toBool(); bool wizardEnable=settings.value("wizardEnable", true).toBool();
if (wizardEnable) { if (wizardEnable) {
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); 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) bool MdiChild::saveAs(bool isNew)
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString fileName; QString fileName;
if (GetEepromInterface()->getBoard() == BOARD_SKY9X) { if (GetEepromInterface()->getBoard() == BOARD_SKY9X) {
curFile.replace(".eepe", ".bin"); curFile.replace(".eepe", ".bin");
@ -493,7 +490,7 @@ void MdiChild::setCurrentFile(const QString &fileName)
fileChanged = false; fileChanged = false;
setWindowModified(false); setWindowModified(false);
updateTitle(); updateTitle();
QSettings settings("companion", "companion"); QSettings settings;
int MaxRecentFiles =settings.value("history_size",10).toInt(); int MaxRecentFiles =settings.value("history_size",10).toInt();
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName); files.removeAll(fileName);
@ -511,7 +508,7 @@ QString MdiChild::strippedName(const QString &fullFileName)
void MdiChild::burnTo() // write to Tx void MdiChild::burnTo() // write to Tx
{ {
QSettings settings("companion", "companion"); QSettings settings;
bool backupEnable=settings.value("backupEnable", true).toBool(); bool backupEnable=settings.value("backupEnable", true).toBool();
QString backupPath=settings.value("backupPath", "").toString(); QString backupPath=settings.value("backupPath", "").toString();
if (!backupPath.isEmpty()) { if (!backupPath.isEmpty()) {
@ -556,19 +553,17 @@ void MdiChild::burnTo() // write to Tx
QStringList str; QStringList str;
str << path << backupFile; str << path << backupFile;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup EEPROM From Tx")); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Backup EEPROM From Tx")); //, AVR_DIALOG_KEEP_OPEN);
QIcon Icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&Icon,"read_eeprom.png");
ad->setWindowIcon(Icon);
ad->exec(); ad->exec();
sleep(1); sleep(1);
} }
} else { }
else {
QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx"));
QIcon Icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&Icon,"read_eeprom.png");
ad->setWindowIcon(Icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
} }
@ -576,10 +571,9 @@ void MdiChild::burnTo() // write to Tx
QString tempFlash=tempDir + "/flash.bin"; QString tempFlash=tempDir + "/flash.bin";
QStringList str = ((MainWindow *)this->parent())->GetReceiveFlashCommand(tempFlash); QStringList str = ((MainWindow *)this->parent())->GetReceiveFlashCommand(tempFlash);
avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, "Read Flash From Tx"); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, "Read Flash From Tx");
QIcon Icon; ad->setWindowIcon(CompanionIcon("read_flash.png"));
populate_icon(&Icon,"read_flash.png");
ad->setWindowIcon(Icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
QString restoreFile = tempDir + "/compat.bin"; QString restoreFile = tempDir + "/compat.bin";
if (!((MainWindow *)this->parent())->convertEEPROM(tempFile, restoreFile, tempFlash)) { if (!((MainWindow *)this->parent())->convertEEPROM(tempFile, restoreFile, tempFlash)) {
@ -587,7 +581,8 @@ void MdiChild::burnTo() // write to Tx
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (ret==QMessageBox::No) if (ret==QMessageBox::No)
return; return;
} else { }
else {
int rev=((MainWindow *)this->parent())->getEpromVersion(restoreFile); int rev=((MainWindow *)this->parent())->getEpromVersion(restoreFile);
if ((rev/100)!=(oldrev/100)) { 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!")); 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(); QByteArray ba = tempFlash.toLatin1();
char *name = ba.data(); char *name = ba.data();
unlink(name); unlink(name);
} else { }
else {
if (backupEnable) { if (backupEnable) {
QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin"; QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin";
if (IS_TARANIS(eepromInterface->getBoard())) { if (IS_TARANIS(eepromInterface->getBoard())) {
@ -608,16 +604,17 @@ void MdiChild::burnTo() // write to Tx
if (path.isEmpty()) { 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.")); 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; return;
} else { }
else {
QFile::copy(path,backupFile); QFile::copy(path,backupFile);
} }
} else { }
else {
QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile); QStringList str = ((MainWindow *)this->parent())->GetReceiveEEpromCommand(backupFile);
avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, tr("Backup EEPROM From Tx"));
QIcon Icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&Icon,"read_eeprom.png");
ad->setWindowIcon(Icon);
ad->exec(); ad->exec();
delete ad;
sleep(1); sleep(1);
} }
} }
@ -627,23 +624,23 @@ void MdiChild::burnTo() // write to Tx
if (path.isEmpty()) { 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.")); 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; return;
} else { }
else {
QStringList str; QStringList str;
str << tempFile << path; str << tempFile << path;
avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write EEPROM To Tx"), AVR_DIALOG_SHOW_DONE); //, AVR_DIALOG_KEEP_OPEN); avrOutputDialog *ad = new avrOutputDialog(this,"", str, tr("Write EEPROM To Tx"), AVR_DIALOG_SHOW_DONE); //, AVR_DIALOG_KEEP_OPEN);
QIcon Icon; ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
populate_icon(&Icon,"read_eeprom.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
sleep(1); sleep(1);
} }
} else { }
else {
QStringList str = ((MainWindow *)this->parent())->GetSendEEpromCommand(tempFile); 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); avrOutputDialog *ad = new avrOutputDialog(this, ((MainWindow *)this->parent())->GetAvrdudeLocation(), str, "Write EEPROM To Tx", AVR_DIALOG_SHOW_DONE);
QIcon Icon; ad->setWindowIcon(CompanionIcon("write_eeprom.png"));
populate_icon(&Icon,"write_eeprom.png");
ad->setWindowIcon(Icon);
ad->show(); ad->show();
delete ad;
} }
} }
} }
@ -693,7 +690,7 @@ void MdiChild::setEEpromAvail(int eavail)
bool MdiChild::loadBackup() bool MdiChild::loadBackup()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
if (fileName.isEmpty()) if (fileName.isEmpty())
return false; return false;

View file

@ -84,8 +84,6 @@ Curves::Curves(QWidget * parent, ModelData & model):
QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview); QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview);
scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->setItemIndexMethod(QGraphicsScene::NoIndex);
ui->curvePreview->setScene(scene); ui->curvePreview->setScene(scene);
QIcon ClearIcon;
populate_icon(&ClearIcon,"clear.png");
for (int i=0; i<GetEepromInterface()->getCapability(NumCurves); i++) { for (int i=0; i<GetEepromInterface()->getCapability(NumCurves); i++) {
visibleCurves[i] = false; visibleCurves[i] = false;
@ -94,7 +92,7 @@ Curves::Curves(QWidget * parent, ModelData & model):
QPushButton * reset = new QPushButton(this); QPushButton * reset = new QPushButton(this);
reset->setProperty("index", i); reset->setProperty("index", i);
reset->setMinimumSize(QSize(0, 0)); reset->setMinimumSize(QSize(0, 0));
reset->setIcon(ClearIcon); reset->setIcon(CompanionIcon("clear.png"));
reset->setIconSize(QSize(14, 14)); reset->setIconSize(QSize(14, 14));
connect(reset, SIGNAL(clicked()), this, SLOT(resetCurve())); connect(reset, SIGNAL(clicked()), this, SLOT(resetCurve()));
ui->curvesLayout->addWidget(reset, i, 0, 1, 1); ui->curvesLayout->addWidget(reset, i, 0, 1, 1);
@ -600,9 +598,9 @@ void ModelEdit::on_ca_apply_PB_clicked()
void ModelEdit::clearCurves(bool ask) void ModelEdit::clearCurves(bool ask)
{ {
if(ask) { if (ask) {
int res = QMessageBox::question(this,tr("Clear Curves?"),tr("Really clear all the curves?"),QMessageBox::Yes | QMessageBox::No); int res = QMessageBox::question(this, tr("Clear Curves?"), tr("Really clear all the curves?"), QMessageBox::Yes | QMessageBox::No);
if(res!=QMessageBox::Yes) return; if (res!=QMessageBox::Yes) return;
} }
curvesLock=true; curvesLock=true;
for (int j=0; j<16; j++) { for (int j=0; j<16; j++) {

View file

@ -36,7 +36,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
} }
} }
QSettings settings("companion", "companion"); QSettings settings;
QString path = settings.value("sdPath", ".").toString(); QString path = settings.value("sdPath", ".").toString();
path.append("/SOUNDS/"); path.append("/SOUNDS/");
QString lang = generalSettings.ttsLanguage; QString lang = generalSettings.ttsLanguage;
@ -123,11 +123,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
#ifdef PHONON #ifdef PHONON
QIcon PlayIcon;
populate_icon(&PlayIcon,"play.png");
playBT[i] = new QPushButton(this); playBT[i] = new QPushButton(this);
playBT[i]->setObjectName(QString("play_%1").arg(i)); playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(PlayIcon); playBT[i]->setIcon(CompanionIcon("play.png"));
paramLayout->addWidget(playBT[i]); paramLayout->addWidget(playBT[i]);
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic())); connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif #endif
@ -162,8 +160,6 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
{ {
if (phononLock) if (phononLock)
return; return;
QIcon PlayIcon;
populate_icon(&PlayIcon,"play.png");
phononLock=true; phononLock=true;
if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) { 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(); clickObject->clear();
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) { for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
playBT[i]->setObjectName(QString("play_%1").arg(i)); playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(PlayIcon); playBT[i]->setIcon(CompanionIcon("play.png"));
} }
} }
if (newState==Phonon::ErrorState) { if (newState==Phonon::ErrorState) {
@ -181,7 +177,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
clickObject->clear(); clickObject->clear();
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) { for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
playBT[i]->setObjectName(QString("play_%1").arg(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<QPushButton*>(sender()); QPushButton *playButton = qobject_cast<QPushButton*>(sender());
int index=playButton->objectName().mid(5,2).toInt(); int index=playButton->objectName().mid(5,2).toInt();
QString function=playButton->objectName().left(4); QString function=playButton->objectName().left(4);
QSettings settings("companion", "companion"); QSettings settings;
QIcon PlayIcon; QString path = settings.value("sdPath", ".").toString();
populate_icon(&PlayIcon,"play.png");
QIcon StopIcon;
populate_icon(&StopIcon,"stop.png");
QString path=settings.value("sdPath", ".").toString();
QDir qd(path); QDir qd(path);
QString track; QString track;
if (qd.exists()) { if (qd.exists()) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) { if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0'); track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0');
} else { }
else {
path.append("/SOUNDS/"); path.append("/SOUNDS/");
QString lang = generalSettings.ttsLanguage; QString lang = generalSettings.ttsLanguage;
if (lang.isEmpty()) if (lang.isEmpty())
@ -227,12 +219,12 @@ void CustomFunctionsPanel::playMusic()
clickObject->setCurrentSource(Phonon::MediaSource(track)); clickObject->setCurrentSource(Phonon::MediaSource(track));
clickObject->play(); clickObject->play();
playBT[index]->setObjectName(QString("stop_%1").arg(index)); playBT[index]->setObjectName(QString("stop_%1").arg(index));
playBT[index]->setIcon(StopIcon); playBT[index]->setIcon(CompanionIcon("stop.png"));
} else { } else {
clickObject->stop(); clickObject->stop();
clickObject->clear(); clickObject->clear();
playBT[index]->setObjectName(QString("play_%1").arg(index)); playBT[index]->setObjectName(QString("play_%1").arg(index));
playBT[index]->setIcon(PlayIcon); playBT[index]->setIcon(CompanionIcon("play.png"));
} }
#endif #endif
} }
@ -467,14 +459,6 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
{ {
QLabel *label = (QLabel *)sender(); QLabel *label = (QLabel *)sender();
selectedFunction = label->property("index").toInt(); 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); QPoint globalPos = label->mapToGlobal(pos);
@ -483,10 +467,10 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
bool hasData = mimeData->hasFormat("application/x-companion-fsw"); bool hasData = mimeData->hasFormat("application/x-companion-fsw");
QMenu contextMenu; QMenu contextMenu;
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(fswDelete()),tr("Delete")); contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C")); contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X")); contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.exec(globalPos); contextMenu.exec(globalPos);
} }

View file

@ -382,14 +382,6 @@ void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
{ {
QLabel *label = (QLabel *)sender(); QLabel *label = (QLabel *)sender();
selectedSwitch = label->property("index").toInt(); 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); QPoint globalPos = label->mapToGlobal(pos);
@ -398,10 +390,10 @@ void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
bool hasData = mimeData->hasFormat("application/x-companion-csw"); bool hasData = mimeData->hasFormat("application/x-companion-csw");
QMenu contextMenu; QMenu contextMenu;
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(cswDelete()),tr("Delete")); contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(cswDelete()),tr("Delete"));
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C")); contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C"));
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X")); contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X"));
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.exec(globalPos); contextMenu.exec(globalPos);
} }

View file

@ -8,28 +8,21 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g
generalSettings(generalSettings), generalSettings(generalSettings),
expoInserted(false) expoInserted(false)
{ {
QString Theme=getTheme();
QGridLayout * exposLayout = new QGridLayout(this); QGridLayout * exposLayout = new QGridLayout(this);
ExposlistWidget = new MixersList(this, true); ExposlistWidget = new MixersList(this, true);
QPushButton * qbUp = new QPushButton(this); QPushButton * qbUp = new QPushButton(this);
QPushButton * qbDown = new QPushButton(this); QPushButton * qbDown = new QPushButton(this);
QPushButton * qbClear = new QPushButton(this); QPushButton * qbClear = new QPushButton(this);
QIcon qbUpIcon;
populate_icon(&qbUpIcon,"moveup.png");
qbUp->setText(tr("Move Up")); qbUp->setText(tr("Move Up"));
qbUp->setIcon(qbUpIcon); qbUp->setIcon(CompanionIcon("moveup.png"));
qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); qbUp->setShortcut(QKeySequence(tr("Ctrl+Up")));
QIcon qbDownIcon;
populate_icon(&qbDownIcon,"movedown.png");
qbDown->setText(tr("Move Down")); qbDown->setText(tr("Move Down"));
qbDown->setIcon(qbDownIcon); qbDown->setIcon(CompanionIcon("movedown.png"));
qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); qbDown->setShortcut(QKeySequence(tr("Ctrl+Down")));
QIcon qbClearIcon;
populate_icon(&qbClearIcon,"clear.png");
qbClear->setText(tr("Clear Expo Settings")); qbClear->setText(tr("Clear Expo Settings"));
qbClear->setIcon(qbClearIcon); qbClear->setIcon(CompanionIcon("clear.png"));
exposLayout->addWidget(ExposlistWidget,1,1,1,3); exposLayout->addWidget(ExposlistWidget,1,1,1,3);
exposLayout->addWidget(qbUp,2,1); exposLayout->addWidget(qbUp,2,1);
@ -348,24 +341,6 @@ void InputsPanel::expoAdd()
void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos) 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); QPoint globalPos = ExposlistWidget->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard(); const QClipboard *clipboard = QApplication::clipboard();
@ -373,17 +348,17 @@ void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos)
bool hasData = mimeData->hasFormat("application/x-companion-expo"); bool hasData = mimeData->hasFormat("application/x-companion-expo");
QMenu contextMenu; QMenu contextMenu;
contextMenu.addAction(AddIcon, tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A")); contextMenu.addAction(CompanionIcon("add.png"), tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A"));
contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(expoOpen()),tr("Enter")); contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(expoOpen()),tr("Enter"));
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(exposDelete()),tr("Delete")); contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(exposDelete()),tr("Delete"));
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C")); contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C"));
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X")); contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X"));
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.addAction(CompanionIcon("paste.png"), 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("duplicate.png"), tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U"));
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(MoveUpIcon, tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up")); contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up"));
contextMenu.addAction(MoveDownIcon, tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down")); contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down"));
contextMenu.exec(globalPos); contextMenu.exec(globalPos);
} }

View file

@ -14,20 +14,14 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
QPushButton * qbUp = new QPushButton(this); QPushButton * qbUp = new QPushButton(this);
QPushButton * qbDown = new QPushButton(this); QPushButton * qbDown = new QPushButton(this);
QPushButton * qbClear = new QPushButton(this); QPushButton * qbClear = new QPushButton(this);
QIcon qbUpIcon;
populate_icon(&qbUpIcon,"moveup.png");
qbUp->setText(tr("Move Up")); qbUp->setText(tr("Move Up"));
qbUp->setIcon(qbUpIcon); qbUp->setIcon(CompanionIcon("moveup.png"));
qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); qbUp->setShortcut(QKeySequence(tr("Ctrl+Up")));
QIcon qbDownIcon;
populate_icon(&qbDownIcon,"movedown.png");
qbDown->setText(tr("Move Down")); qbDown->setText(tr("Move Down"));
qbDown->setIcon(qbDownIcon); qbDown->setIcon(CompanionIcon("movedown.png"));
qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); qbDown->setShortcut(QKeySequence(tr("Ctrl+Down")));
QIcon qbClearIcon;
populate_icon(&qbClearIcon,"clear.png");
qbClear->setText(tr("Clear Mixes")); qbClear->setText(tr("Clear Mixes"));
qbClear->setIcon(qbClearIcon); qbClear->setIcon(CompanionIcon("clear.png"));
mixesLayout->addWidget(MixerlistWidget,1,1,1,3); mixesLayout->addWidget(MixerlistWidget,1,1,1,3);
mixesLayout->addWidget(qbUp,2,1); mixesLayout->addWidget(qbUp,2,1);
@ -411,24 +405,6 @@ void MixesPanel::mixerAdd()
void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos) 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); QPoint globalPos = MixerlistWidget->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard(); const QClipboard *clipboard = QApplication::clipboard();
@ -436,17 +412,17 @@ void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos)
bool hasData = mimeData->hasFormat("application/x-companion-mix"); bool hasData = mimeData->hasFormat("application/x-companion-mix");
QMenu contextMenu; QMenu contextMenu;
contextMenu.addAction(AddIcon, tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A")); contextMenu.addAction(CompanionIcon("add.png"), tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A"));
contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter")); contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter"));
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete")); contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete"));
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C")); contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C"));
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X")); contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X"));
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.addAction(CompanionIcon("paste.png"), 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("duplicate.png"), tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U"));
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(MoveUpIcon, tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up")); contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up"));
contextMenu.addAction(MoveDownIcon, tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down")); contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down"));
contextMenu.exec(globalPos); contextMenu.exec(globalPos);
} }

View file

@ -21,11 +21,9 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
generalSettings(radioData.generalSettings) generalSettings(radioData.generalSettings)
{ {
ui->setupUi(this); ui->setupUi(this);
QSettings settings("companion", "companion"); QSettings settings;
restoreGeometry(settings.value("modelEditGeometry").toByteArray()); restoreGeometry(settings.value("modelEditGeometry").toByteArray());
QIcon SimulateIcon; ui->pushButton->setIcon(CompanionIcon("simulate.png"));
populate_icon(&SimulateIcon,"simulate.png");
ui->pushButton->setIcon(SimulateIcon);
addTab(new Setup(this, model), tr("Setup")); addTab(new Setup(this, model), tr("Setup"));
addTab(new HeliPanel(this, model), tr("Heli")); addTab(new HeliPanel(this, model), tr("Heli"));
addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes")); addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes"));
@ -47,7 +45,7 @@ ModelEdit::~ModelEdit()
void ModelEdit::closeEvent(QCloseEvent *event) void ModelEdit::closeEvent(QCloseEvent *event)
{ {
QSettings settings("companion", "companion"); QSettings settings;
settings.setValue("modelEditGeometry", saveGeometry()); settings.setValue("modelEditGeometry", saveGeometry());
} }

View file

@ -353,7 +353,7 @@ Setup::Setup(QWidget *parent, ModelData & model):
if (GetEepromInterface()->getCapability(ModelImage)) { if (GetEepromInterface()->getCapability(ModelImage)) {
QStringList items; QStringList items;
items.append(""); items.append("");
QSettings settings("companion", "companion"); QSettings settings;
QString path = settings.value("sdPath", ".").toString(); QString path = settings.value("sdPath", ".").toString();
path.append("/BMP/"); path.append("/BMP/");
QDir qd(path); QDir qd(path);
@ -497,7 +497,7 @@ void Setup::on_image_currentIndexChanged(int index)
{ {
if (!lock) { if (!lock) {
strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength));
QSettings settings("companion", "companion"); QSettings settings;
QString path=settings.value("sdPath", ".").toString(); QString path=settings.value("sdPath", ".").toString();
path.append("/BMP/"); path.append("/BMP/");
QDir qd(path); QDir qd(path);

View file

@ -342,7 +342,7 @@ TelemetryPanel::~TelemetryPanel()
void TelemetryPanel::setup() void TelemetryPanel::setup()
{ {
QSettings settings("companion", "companion"); QSettings settings;
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
lock=true; lock=true;

View file

@ -83,47 +83,23 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos)
const QClipboard *clipboard = QApplication::clipboard(); const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData(); const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion"); 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; QMenu contextMenu;
contextMenu.addAction(EditIcon, tr("&Edit"),this,SLOT(OpenEditWindow())); contextMenu.addAction(CompanionIcon("edit.png"), tr("&Edit"),this,SLOT(OpenEditWindow()));
contextMenu.addAction(OpenIcon, tr("&Restore from backup"),this,SLOT(LoadBackup())); contextMenu.addAction(CompanionIcon("open.png"), tr("&Restore from backup"),this,SLOT(LoadBackup()));
contextMenu.addAction(WizardIcon, tr("&Model Wizard"),this,SLOT(OpenWizard())); contextMenu.addAction(CompanionIcon("wizard.png"), tr("&Model Wizard"),this,SLOT(OpenWizard()));
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(confirmDelete()),tr("Delete")); contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(confirmDelete()),tr("Delete"));
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(copy()),tr("Ctrl+C")); contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(copy()),tr("Ctrl+C"));
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(cut()),tr("Ctrl+X")); contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(cut()),tr("Ctrl+X"));
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(paste()),tr("Ctrl+V"))->setEnabled(hasData); contextMenu.addAction(CompanionIcon("paste.png"), 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("duplicate.png"), tr("D&uplicate"),this,SLOT(duplicate()),tr("Ctrl+U"));
contextMenu.addSeparator(); 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.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.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); contextMenu.exec(globalPos);
} }

View file

@ -17,15 +17,9 @@ preferencesDialog::preferencesDialog(QWidget *parent) :
updateLock(false) updateLock(false)
{ {
ui->setupUi(this); ui->setupUi(this);
QIcon Icon; setWindowIcon(CompanionIcon("preferences.png"));
populate_icon(&Icon,"preferences.png"); ui->splashLibraryButton->setIcon(CompanionIcon("library.png"));
this->setWindowIcon(Icon); ui->clearImageButton->setIcon(CompanionIcon("clear.png"));
QIcon LibraryIcon;
populate_icon(&LibraryIcon,"library.png");
ui->splashLibraryButton->setIcon(LibraryIcon);
QIcon ClearIcon;
populate_icon(&ClearIcon,"clear.png");
ui->clearImageButton->setIcon(ClearIcon);
QCheckBox * OptionCheckBox[]= { QCheckBox * OptionCheckBox[]= {
ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7, 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_LE->hide();
ui->CPU_ID_LABEL->hide(); ui->CPU_ID_LABEL->hide();
} }
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("FwRevisions"); settings.beginGroup("FwRevisions");
int fwrev = settings.value(variant.id, -1).toInt(); int fwrev = settings.value(variant.id, -1).toInt();
settings.endGroup(); settings.endGroup();
@ -259,7 +253,7 @@ void preferencesDialog::firmwareChanged()
void preferencesDialog::writeValues() void preferencesDialog::writeValues()
{ {
QSettings settings("companion", "companion"); QSettings settings;
if (ui->locale_QB->currentIndex() > 0) if (ui->locale_QB->currentIndex() > 0)
settings.setValue("locale", ui->locale_QB->itemData(ui->locale_QB->currentIndex())); settings.setValue("locale", ui->locale_QB->itemData(ui->locale_QB->currentIndex()));
else else
@ -392,7 +386,7 @@ void preferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
void preferencesDialog::initSettings() void preferencesDialog::initSettings()
{ {
QSettings settings("companion", "companion"); QSettings settings;
int i = ui->locale_QB->findData(settings.value("locale")); int i = ui->locale_QB->findData(settings.value("locale"));
if (i < 0) i = 0; if (i < 0) i = 0;
ui->locale_QB->setCurrentIndex(i); ui->locale_QB->setCurrentIndex(i);
@ -533,7 +527,7 @@ void preferencesDialog::on_fw_dnld_clicked()
writeValues(); writeValues();
if (!variant.firmware->getUrl(variant.id).isNull()) { if (!variant.firmware->getUrl(variant.id).isNull()) {
if (ui->burnFirmware->isChecked()) { if (ui->burnFirmware->isChecked()) {
QSettings settings("companion", "companion"); QSettings settings;
current_firmware_variant = getFirmwareVariant(); current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id); settings.setValue("firmware", current_firmware_variant.id);
} }
@ -554,7 +548,7 @@ void preferencesDialog::on_voice_dnld_clicked()
void preferencesDialog::on_libraryPathButton_clicked() void preferencesDialog::on_libraryPathButton_clicked()
{ {
ui->ProfSave_PB->setEnabled(true); 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()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("libraryPath", fileName); settings.setValue("libraryPath", fileName);
@ -564,7 +558,7 @@ void preferencesDialog::on_libraryPathButton_clicked()
void preferencesDialog::on_snapshotPathButton_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()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("snapshotpath", fileName); settings.setValue("snapshotpath", fileName);
@ -575,7 +569,7 @@ void preferencesDialog::on_snapshotPathButton_clicked()
void preferencesDialog::on_snapshotClipboardCKB_clicked() void preferencesDialog::on_snapshotClipboardCKB_clicked()
{ {
QSettings settings("companion", "companion"); QSettings settings;
if (ui->snapshotClipboardCKB->isChecked()) { if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true); ui->snapshotPathButton->setDisabled(true);
@ -591,7 +585,7 @@ void preferencesDialog::on_snapshotClipboardCKB_clicked()
void preferencesDialog::on_backupPathButton_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()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("backupPath", fileName); settings.setValue("backupPath", fileName);
@ -602,7 +596,7 @@ void preferencesDialog::on_backupPathButton_clicked()
void preferencesDialog::on_ge_pathButton_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()); QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->ge_lineedit->setText(fileName); ui->ge_lineedit->setText(fileName);
@ -628,7 +622,7 @@ void preferencesDialog::on_splashLibraryButton_clicked()
void preferencesDialog::on_sdPathButton_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()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName); ui->sdPath->setText(fileName);
@ -638,7 +632,7 @@ void preferencesDialog::on_sdPathButton_clicked()
void preferencesDialog::on_ProfSlot_SB_valueChanged() void preferencesDialog::on_ProfSlot_SB_valueChanged()
{ {
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
settings.beginGroup(profile); settings.beginGroup(profile);
@ -667,7 +661,7 @@ void preferencesDialog::on_ProfSlot_SB_valueChanged()
void preferencesDialog::on_ProfSave_PB_clicked() void preferencesDialog::on_ProfSave_PB_clicked()
{ {
QSettings settings("companion", "companion"); QSettings settings;
settings.beginGroup("Profiles"); settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value()); QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString name=ui->ProfName_LE->text(); QString name=ui->ProfName_LE->text();
@ -706,7 +700,7 @@ void preferencesDialog::on_ProfSave_PB_clicked()
void preferencesDialog::on_export_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 profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString name=ui->ProfName_LE->text(); QString name=ui->ProfName_LE->text();
if (!name.isEmpty()) { if (!name.isEmpty()) {
@ -727,7 +721,7 @@ void preferencesDialog::on_export_PB_clicked()
void preferencesDialog::on_import_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 profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString name=ui->ProfName_LE->text(); QString name=ui->ProfName_LE->text();
if (!name.isEmpty()) { if (!name.isEmpty()) {
@ -760,7 +754,7 @@ void preferencesDialog::on_SplashSelect_clicked()
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings("companion", "companion"); QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); 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() { void preferencesDialog::on_joystickcalButton_clicked() {
//QSettings settings("companion", "companion"); //QSettings settings;
//settings.setValue("joystick-name",ui->joystickCB->currentText()); //settings.setValue("joystick-name",ui->joystickCB->currentText());
joystickDialog * jd=new joystickDialog(this, ui->joystickCB->currentIndex()); joystickDialog * jd=new joystickDialog(this, ui->joystickCB->currentIndex());
jd->exec(); jd->exec();
@ -849,7 +843,7 @@ void preferencesDialog::on_checkFWUpdates_clicked()
{ {
FirmwareVariant variant = getFirmwareVariant(); FirmwareVariant variant = getFirmwareVariant();
if (ui->burnFirmware->isChecked()) { if (ui->burnFirmware->isChecked()) {
QSettings settings("companion", "companion"); QSettings settings;
current_firmware_variant = variant; current_firmware_variant = variant;
settings.setValue("firmware", variant.id); settings.setValue("firmware", variant.id);
} }

View file

@ -32,7 +32,7 @@ simulatorDialog::simulatorDialog(QWidget *parent) :
beepVal = 0; beepVal = 0;
beepShow = 0; beepShow = 0;
QSettings settings("companion", "companion"); QSettings settings;
backLight = settings.value("backLight",0).toInt(); backLight = settings.value("backLight",0).toInt();
bool simuSW=settings.value("simuSW",false).toBool(); bool simuSW=settings.value("simuSW",false).toBool();
switch (backLight) { switch (backLight) {
@ -211,7 +211,7 @@ void simulatorDialog::setupTimer()
void simulatorDialog::onButtonPressed(int value) void simulatorDialog::onButtonPressed(int value)
{ {
if (value==Qt::Key_Print) { if (value==Qt::Key_Print) {
QSettings settings("companion", "companion"); QSettings settings;
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
QString fileName =""; QString fileName ="";
if (!toclipboard) { if (!toclipboard) {

View file

@ -9,12 +9,8 @@
splashLibrary::splashLibrary(QWidget *parent, QString * fileName) : QDialog(parent), ui(new Ui::splashLibrary) { splashLibrary::splashLibrary(QWidget *parent, QString * fileName) : QDialog(parent), ui(new Ui::splashLibrary) {
splashFileName = fileName; splashFileName = fileName;
ui->setupUi(this); ui->setupUi(this);
QIcon NextIcon; ui->nextPage->setIcon(CompanionIcon("arrow-right.png"));
populate_icon(&NextIcon,"arrow-right.png"); ui->prevPage->setIcon(CompanionIcon("arrow-left.png"));
QIcon PrevIcon;
populate_icon(&PrevIcon,"arrow-left.png");
ui->nextPage->setIcon(NextIcon);
ui->prevPage->setIcon(PrevIcon);
page = 0; page = 0;
getFileList(); getFileList();
if (imageList.size() > 20) { if (imageList.size() > 20) {
@ -65,7 +61,7 @@ void splashLibrary::setupPage(int page) {
} }
void splashLibrary::getFileList() { void splashLibrary::getFileList() {
QSettings settings("companion", "companion"); QSettings settings;
imageList.clear(); imageList.clear();
if (settings.value("embedded_splashes", 0).toInt() == 0) { if (settings.value("embedded_splashes", 0).toInt() == 0) {
QDir myRes(":/images/library"); QDir myRes(":/images/library");

View file

@ -30,7 +30,7 @@ xsimulatorDialog::xsimulatorDialog(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
ui->lcd->setFocus(); ui->lcd->setFocus();
QSettings settings("companion", "companion"); QSettings settings;
ui->lcd->setBackgroundColor(47, 123, 227); ui->lcd->setBackgroundColor(47, 123, 227);
setupSticks(); setupSticks();
resize(0, 0); // to force min height, min width resize(0, 0); // to force min height, min width
@ -179,7 +179,7 @@ void xsimulatorDialog::setupTimer()
void xsimulatorDialog::onButtonPressed(int value) void xsimulatorDialog::onButtonPressed(int value)
{ {
if (value==Qt::Key_Print) { if (value==Qt::Key_Print) {
QSettings settings("companion", "companion"); QSettings settings;
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool(); bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
QString fileName =""; QString fileName ="";
if (!toclipboard) { if (!toclipboard) {