diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 3a8dd26b7..20c86879c 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -155,7 +155,6 @@ SET( companion_SRCS modelslist.cpp mountlist.cpp avroutputdialog.cpp - preferencesdialog.cpp apppreferencesdialog.cpp fwpreferencesdialog.cpp burnconfigdialog.cpp @@ -178,7 +177,6 @@ SET( companion_SRCS SET( companion_MOC_HDRS avroutputdialog.h - preferencesdialog.h apppreferencesdialog.h fwpreferencesdialog.h burnconfigdialog.h @@ -214,7 +212,6 @@ SET( companion_UIS comparedialog.ui fusesdialog.ui logsdialog.ui - preferencesdialog.ui apppreferencesdialog.ui fwpreferencesdialog.ui simulatordialog.ui diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 4b425a61b..ebbb5bb55 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -14,7 +14,7 @@ appPreferencesDialog::appPreferencesDialog(QWidget *parent) : ui(new Ui::appPreferencesDialog) { ui->setupUi(this); - setWindowIcon(CompanionIcon("preferences.png")); + setWindowIcon(CompanionIcon("apppreferences.png")); initSettings(); connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); #ifndef JOYSTICKS @@ -56,8 +56,17 @@ void appPreferencesDialog::writeValues() settings.remove("js_ctrl"); } - MainWindow * mw = (MainWindow *)this->parent(); - mw->unloadProfile(); + settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); + settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); + settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); + settings.setValue("profileId", ui->profileIndexLE->text()); + settings.setValue("sdPath", ui->sdPath->text()); + settings.setValue("SplashFileName", ui->SplashFileName->text()); + if (!ui->SplashFileName->text().isEmpty()) + settings.setValue("SplashImage", ""); + + saveProfile(); } void appPreferencesDialog::on_snapshotPathButton_clicked() @@ -75,6 +84,7 @@ void appPreferencesDialog::initSettings() { QSettings settings; ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool()); + ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool()); QString Path=settings.value("snapshotPath", "").toString(); if (QDir(Path).exists()) { @@ -142,6 +152,24 @@ void appPreferencesDialog::initSettings() ui->joystickcalButton->setDisabled(true); } #endif +// Profile Tab Inits + ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt()); + ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt()); + ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool()); + Path=settings.value("sdPath", "").toString(); + if (QDir(Path).exists()) { + ui->sdPath->setText(Path); + } + ui->profileIndexLE->setText(settings.value("profileId", "").toString()); + + QString fileName=settings.value("SplashFileName","").toString(); + if (!fileName.isEmpty()) { + QFile file(fileName); + if (file.exists()){ + ui->SplashFileName->setText(fileName); + displayImage( fileName ); + } + } } void appPreferencesDialog::on_libraryPathButton_clicked() @@ -222,3 +250,140 @@ void appPreferencesDialog::on_joystickcalButton_clicked() { } #endif +// ******** Profile tab functions + +void appPreferencesDialog::on_sdPathButton_clicked() +{ + QSettings settings; + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString()); + if (!fileName.isEmpty()) { + ui->sdPath->setText(fileName); + } +} + +void appPreferencesDialog::saveProfile() +{ + QSettings settings; + + QString profile=QString("profile") + settings.value("profileId").toString(); + QString name=ui->ProfName_LE->text(); + if (name.isEmpty()) { + name = profile; + ui->ProfName_LE->setText(name); + } + settings.beginGroup("Profiles"); + settings.beginGroup(profile); + settings.setValue("Name",name); + settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); + settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); + settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); + settings.setValue("sdPath", ui->sdPath->text()); + settings.setValue("SplashFileName", ui->SplashFileName->text()); + settings.endGroup(); + settings.endGroup(); +} + +void appPreferencesDialog::loadProfileString(QString profile, QString label) +{ + QSettings settings; + QString value; + + settings.beginGroup("Profiles"); + settings.beginGroup(profile); + value = settings.value(label).toString(); + settings.endGroup(); + settings.endGroup(); + + settings.setValue( label, value ); +} + +void appPreferencesDialog::loadProfile() +{ + QSettings settings; + QString profile=QString("profile") + settings.value("profileId").toString(); + + loadProfileString( profile, "Name" ); + loadProfileString( profile, "default_channel_order" ); + loadProfileString( profile, "default_mode" ); + loadProfileString( profile, "burnFirmware" ); + loadProfileString( profile, "rename_firmware_files" ); + loadProfileString( profile, "sdPath" ); + loadProfileString( profile, "SplashFileName" ); +} + +void appPreferencesDialog::on_removeProfileButton_clicked() +{ + QSettings settings; + QString profileId = settings.value("profileId").toString(); + if ( profileId == "1" ) + QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed.")); + else + { + QString profile=QString("profile") + profileId; + settings.beginGroup("Profiles"); + settings.remove(profile); + settings.endGroup(); + settings.setValue("profileId", "1"); + + loadProfile(); + initSettings(); + } +} + +bool appPreferencesDialog::displayImage( QString fileName ) +{ + QImage image(fileName); + if (image.isNull()) + { + QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); + return false; + } + + int width=ui->imageLabel->width(); + ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, 64))); + if (width==212) { + image=image.convertToFormat(QImage::Format_RGB32); + QRgb col; + int gray, height = image.height(); + for (int i = 0; i < width; ++i) { + for (int j = 0; j < height; ++j) { + col = image.pixel(i, j); + gray = qGray(col); + image.setPixel(i, j, qRgb(gray, gray, gray)); + } + } + ui->imageLabel->setPixmap(QPixmap::fromImage(image)); + } + else { + ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono))); + } + return true; +} + +void appPreferencesDialog::on_SplashSelect_clicked() +{ + QString supportedImageFormats; + for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) { + supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; + } + + QSettings settings; + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); + + if (!fileName.isEmpty()) { + settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); + + if (displayImage(fileName)) + ui->SplashFileName->setText(fileName); + } +} + +void appPreferencesDialog::on_clearImageButton_clicked() { + ui->imageLabel->clear(); + ui->SplashFileName->clear(); +} + + + diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index d47682512..b6f6c3896 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -23,6 +23,10 @@ public: private: Ui::appPreferencesDialog *ui; void initSettings(); + bool displayImage( QString fileName ); + void saveProfile(); + void loadProfileString(QString profile, QString label); + void loadProfile(); private slots: void writeValues(); @@ -31,6 +35,12 @@ private slots: void on_snapshotClipboardCKB_clicked(); void on_backupPathButton_clicked(); void on_ge_pathButton_clicked(); + + void on_sdPathButton_clicked(); + void on_removeProfileButton_clicked(); + void on_SplashSelect_clicked(); + void on_clearImageButton_clicked(); + #ifdef JOYSTICKS void on_joystickChkB_clicked(); void on_joystickcalButton_clicked(); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index bc1f734f3..cea4246f6 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 685 - 456 + 431 @@ -23,7 +23,7 @@ - Application Preferences + Edit Settings @@ -32,230 +32,7 @@ 6 - - - - Open Folder - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Joystick - - - - - - - Simulator capture folder - - - - - - - Remember simulator switch values - - - - - - - - 0 - 0 - - - - User Splash Screens - - - - - - - - 0 - 0 - - - - Files to keep - - - - - - - Offer to use wizard for new models - - - true - - - - - - - Qt::Horizontal - - - - - - - - 100 - 16777215 - - - - - Blue - - - - - Green - - - - - Red - - - - - Orange - - - - - Yellow - - - - - - - - Automatic check for Companion updates - - - true - - - - - - - Qt::Horizontal - - - - - - - true - - - true - - - - - - - Only capture to clipboard - - - - - - - - 40 - 0 - - - - - 50 - 16777215 - - - - 15 - - - 10 - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - - 250 - 0 - - - - true - - - - - - - Calibrate - - - - - - - Automatic Backup Folder - - - - + Qt::Horizontal @@ -265,187 +42,905 @@ - - - - Open Folder - - - false - - - - - - - true - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Simulator BackLight - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Enable automatic backup before writing firmware - - - - - - - Show splash screen when Companion starts - - - true - - - - - - - Find Executable - - - - - - - Open Folder - - - - - - - Enable - - - - - - - Google Earth Executable - - - - - - - Automatic check for OpenTX firmware updates - - - true - - - - - - - - 0 - 0 - - - - - Include companion splashes - - - - - Only user defined splashes - - - - - - - - - 0 - 0 - - - - Splash Screen Library - - - - - - - true - - - true + + + + 0 + + + Application Settings + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Automatic Backup Folder + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + 15 + + + 10 + + + + + + + + 0 + 0 + + + + User Splash Screens + + + + + + + + 0 + 0 + + + + + Include companion splashes + + + + + Only user defined splashes + + + + + + + + Google Earth Executable + + + + + + + Automatic check for OpenTX firmware updates + + + true + + + + + + + + 350 + 0 + + + + true + + + + + + + Open Folder + + + + + + + Qt::Horizontal + + + + + + + + 350 + 0 + + + + true + + + + + + + Find Executable + + + + + + + + 0 + 0 + + + + Files to keep + + + + + + + + 0 + 0 + + + + Splash Screen Library + + + + + + + Enable automatic backup before writing firmware + + + + + + + Open Folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + Automatic check for Companion updates + + + true + + + + + + + Qt::Horizontal + + + + + + + Offer to use wizard for new models + + + true + + + + + + + Show splash screen when Companion starts + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + true + + + + + + + + Simulator Settings + + + + + + + 0 + 0 + + + + Simulator BackLight + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Enable + + + + + + + Open Folder + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 16777215 + + + + + Blue + + + + + Green + + + + + Red + + + + + Orange + + + + + Yellow + + + + + + + + + 0 + 0 + + + + Joystick + + + + + + + Only capture to clipboard + + + + + + + + 0 + 0 + + + + + + + + Calibrate + + + + + + + Remember simulator switch values + + + + + + + Simulator capture folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + true + + + + 350 + 0 + + + + true + + + + + + + + Radio Settings + + + + + + + 16777215 + 16777215 + + + + Mode selection: + +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + + + + 1 + + + + Mode 1 (RUD ELE THR AIL) + + + + + Mode 2 (RUD THR ELE AIL) + + + + + Mode 3 (AIL ELE THR RUD) + + + + + Mode 4 (AIL THR ELE RUD) + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Channel order + +This is used by the templated to determine which channel goes to what number output. + + + 0 + + + + R E T A + + + + + R E A T + + + + + R T E A + + + + + R T A E + + + + + R A E T + + + + + R A T E + + + + + E R T A + + + + + E R A T + + + + + E T R A + + + + + E T A R + + + + + E A R T + + + + + E A T R + + + + + T R E A + + + + + T R A E + + + + + T E R A + + + + + T E A R + + + + + T A R E + + + + + T A E R + + + + + A R E T + + + + + A R T E + + + + + A E R T + + + + + A E T R + + + + + A T R E + + + + + A T E R + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Default Stick Mode + + + + + + + Settings Profile + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + Splash Screen + + + + + + + + 0 + 0 + + + + Channel Order + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Append version number to FW file name + + + + + + + + 0 + 0 + + + + SD Structure path + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + true + + + + 350 + 0 + + + + true + + + + + + + Select Image + + + + + + + + 0 + 0 + + + + + 128 + 64 + + + + + 128 + 64 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Offer to write FW to Tx after download + + + + + + + Remove Profile + + + + + + + Clear Image + + + + + + + Open Folder + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + + + + true + + + + 0 + 0 + + + + true + + + + + + + false + + + + 30 + 16777215 + + + + + + - startupCheck_companion9x - backupEnable - line - backupPath - line_2 - startupCheck_fw - wizardEnable_ChkB - ge_label - label_5 - showSplash - line_3 - ge_pathButton - line_4 - backupPathButton - label_3 - backLightColor - snapshotPath - snapshotPathButton - snapshotClipboardCKB - label_11 - joystickCB - joystickcalButton - ge_lineedit - simuSW - buttonBox - line_5 - joystickChkB - label_17 - label_19 - historySize - label_9 - libraryPath - libraryPathButton - line_6 - splashincludeCB - label_10 - buttonBox + tabWidget ge_lineedit ge_pathButton historySize @@ -456,6 +951,10 @@ backupPath backupPathButton backupEnable + splashincludeCB + libraryPath + libraryPathButton + buttonBox snapshotPath snapshotPathButton snapshotClipboardCKB @@ -464,6 +963,12 @@ joystickCB joystickChkB joystickcalButton + sdPath + SplashFileName + stickmodeCB + channelorderCB + renameFirmware + burnFirmware @@ -476,8 +981,8 @@ accept() - 376 - 596 + 382 + 455 157 @@ -492,8 +997,8 @@ reject() - 396 - 596 + 402 + 455 286 diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 070fe3dc0..3b8240f6c 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -7,19 +7,128 @@ #include "splashlibrary.h" #include "flashinterface.h" +//*** Side Class *** + Side::Side(){ imageLabel = 0; fileNameEdit = 0; saveButton = 0; - source=new Source; - *source = UNDEFINED; + saveToFileName = new QString(""); + source = new Source(UNDEFINED); } -void Side::copyImage( Side side ){ - if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED)) +void Side::copyImage( Side side ) +{ + if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED)) imageLabel->setPixmap(*side.imageLabel->pixmap()); } +bool Side::displayImage( QString fileName, Source pictSource ) +{ + QImage image; + + if (fileName.isEmpty()) { + return false; + } + if (pictSource == FW ){ + FlashInterface flash(fileName); + if (!flash.hasSplash()) + return false; + else + image = flash.getSplash(); + } + else { + image.load(fileName); + } + if (image.isNull()) { + return false; + } + if (imageLabel->width()==424) { + image=image.convertToFormat(QImage::Format_RGB32); + QRgb col; + int gray; + int width = image.width(); + int height = image.height(); + for (int i = 0; i < width; ++i) { + for (int j = 0; j < height; ++j) { + col = image.pixel(i, j); + gray = qGray(col); + image.setPixel(i, j, qRgb(gray, gray, gray)); + } + } + imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2))); + } + else { + imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); + } + switch (pictSource){ + case FW: + fileNameEdit->setText(QObject::tr("FW: %1").arg(fileName)); + *saveToFileName = fileName; + *source=FW; + break; + case PICT: + fileNameEdit->setText(QObject::tr("Pict: %1").arg(fileName)); + *saveToFileName = fileName; + *source=PICT; + break; + case PROFILE: + fileNameEdit->setText(QObject::tr("Profile image")); + *saveToFileName = fileName; + *source=PROFILE; + break; + default: + break; + } + saveButton->setEnabled(true); + libraryButton->setEnabled(true); + invertButton->setEnabled(true); + return true; +} + +bool Side::refreshImage() +{ + return displayImage( *saveToFileName, *source ); +} + +bool Side::saveImage() +{ + QSettings settings; + + if (*source == FW ) + { + FlashInterface flash(*saveToFileName); + if (!flash.hasSplash()) { + return false; + } + QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); + if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) { + settings.setValue("lastFlashDir", QFileInfo(*saveToFileName).dir().absolutePath()); + } + else { + return false; + } + } + else if (*source == PICT) { + QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); + if (image.save(*saveToFileName)) { + settings.setValue("lastImagesDir", QFileInfo(*saveToFileName).dir().absolutePath()); + } + else { + return false; + } + } + else if (*source == PROFILE) { + QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); + if (!image.save(*saveToFileName)) { + return false; + } + } + return true; +} + +//*** customizeSplashDialog Class *** + customizeSplashDialog::customizeSplashDialog(QWidget *parent) : QDialog(parent), ui(new Ui::customizeSplashDialog) @@ -39,6 +148,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) : left.invertButton = ui->leftInvertButton; right.invertButton = ui->rightInvertButton; + loadProfile(left); resize(0,0); } @@ -62,25 +172,10 @@ void customizeSplashDialog::loadFirmware(Side side) QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); if (!fileName.isEmpty()) { - QFile file(fileName); - if (fileName.isEmpty() || !file.exists()) - return; - - FlashInterface flash(fileName); - if (!flash.hasSplash()) { - QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file")); - return; - } - - side.saveButton->setEnabled(true); - side.imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash())); - side.imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2); - side.fileNameEdit->setText(fileName); + if (!side.displayImage( fileName, FW )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName)); + else settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); - *side.source=FW; - side.saveButton->setEnabled(true); - side.libraryButton->setEnabled(true); - side.invertButton->setEnabled(true); } } @@ -96,46 +191,25 @@ void customizeSplashDialog::loadPicture(Side side) QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); - if (fileName.isEmpty()){ - return; + if (!fileName.isEmpty()) { + if (!side.displayImage( fileName, PICT )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName)); + else + settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); } - QImage image(fileName); - if (image.isNull()) { - QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); - return; - } - if (side.imageLabel->width()==424) { - image=image.convertToFormat(QImage::Format_RGB32); - QRgb col; - int gray; - int width = image.width(); - int height = image.height(); - for (int i = 0; i < width; ++i) - { - for (int j = 0; j < height; ++j) - { - col = image.pixel(i, j); - gray = qGray(col); - image.setPixel(i, j, qRgb(gray, gray, gray)); - } - } - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2))); - } else { - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); - } - - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); - side.fileNameEdit->setText(fileName); - *side.source=PICT; - side.saveButton->setEnabled(true); - side.libraryButton->setEnabled(true); - side.invertButton->setEnabled(true); } void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left);} void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);} void customizeSplashDialog::loadProfile(Side side) { + QSettings settings; + QString fileName=settings.value("SplashFileName","").toString(); + + if (!fileName.isEmpty()) { + if (!side.displayImage( fileName, PROFILE )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the profile image %1.").arg(fileName)); + } } void customizeSplashDialog::on_leftLibraryButton_clicked(){libraryButton_clicked(left);} @@ -143,67 +217,26 @@ void customizeSplashDialog::on_rightLibraryButton_clicked(){libraryButton_clicke void customizeSplashDialog::libraryButton_clicked( Side side ) { QString fileName; - splashLibrary *ld = new splashLibrary(this,&fileName); ld->exec(); if (!fileName.isEmpty()) { - QImage image(fileName); - if (image.isNull()) { - QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); - return; - } - if (side.imageLabel->width()==424) { - image=image.convertToFormat(QImage::Format_RGB32); - QRgb col; - int gray; - int width = image.width(); - int height = image.height(); - for (int i = 0; i < width; ++i) - { - for (int j = 0; j < height; ++j) - { - col = image.pixel(i, j); - gray = qGray(col); - image.setPixel(i, j, qRgb(gray, gray, gray)); - } - } - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2))); - } else { - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); - } + if (!side.displayImage( fileName, UNDEFINED )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the library image %1.").arg(fileName)); } } void customizeSplashDialog::on_leftSaveButton_clicked(){saveButton_clicked(left);} void customizeSplashDialog::on_rightSaveButton_clicked(){saveButton_clicked(right);} -void customizeSplashDialog::saveButton_clicked(Side side) +void customizeSplashDialog::saveButton_clicked( Side side ) { - QSettings settings; - QString fileName = side.fileNameEdit->text(); - - if (*side.source == FW) - { - FlashInterface flash(fileName); - if (!flash.hasSplash()) { - QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName)); - return; - } - QImage image = side.imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); - if (flash.setSplash(image) && (flash.saveFlash(fileName) > 0)) - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); - else - QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName)); - } - else if (*side.source == PICT) - { - if (!fileName.isEmpty()) { - QImage image = side.imageLabel->pixmap()->toImage().scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); - if (image.save(fileName)) - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); - else - QMessageBox::critical(this, tr("Error"), tr("The image file %1 could not be stored").arg(fileName)); + if (side.saveImage()){ + QMessageBox::information(this, tr("File Saved"), tr("The image was saved to the file %1").arg(*side.saveToFileName)); + if ( !side.refreshImage()){ + QMessageBox::critical(this, tr("Image Refresh Error"), tr("Failed to refresh image from file %1").arg(*side.saveToFileName)); } } + else + QMessageBox::critical(this, tr("File Save Error"), tr("Failed to write image to %1").arg(*side.saveToFileName)); } void customizeSplashDialog::on_leftInvertButton_clicked(){invertButton_clicked(left);} diff --git a/companion/src/customizesplashdialog.h b/companion/src/customizesplashdialog.h index 8ae954d1c..b4db9a60e 100644 --- a/companion/src/customizesplashdialog.h +++ b/companion/src/customizesplashdialog.h @@ -17,6 +17,9 @@ class Side public: Side(); void copyImage( Side ); + bool displayImage( QString fileName, Source source ); + bool saveImage(); + bool refreshImage(); QLabel *imageLabel; QLineEdit *fileNameEdit; @@ -24,6 +27,9 @@ public: QPushButton *invertButton; QToolButton *libraryButton; + QString *saveToFileName; + +private: Source *source; }; diff --git a/companion/src/customizesplashdialog.ui b/companion/src/customizesplashdialog.ui index b98d87907..fa6c57d9f 100644 --- a/companion/src/customizesplashdialog.ui +++ b/companion/src/customizesplashdialog.ui @@ -254,6 +254,16 @@ + + + + true + + + Load Profile + + + @@ -268,16 +278,6 @@ - - - - false - - - Load Profile - - - @@ -550,6 +550,16 @@ + + + + true + + + Load Profile + + + @@ -567,16 +577,6 @@ - - - - false - - - Load Profile - - - @@ -625,12 +625,17 @@ leftFileNameEdit leftInvertButton + leftLibraryButton + leftLoadProfileButton + leftLoadFwButton leftLoadPictButton leftSaveButton copyLeftToRightButton copyRightToLeftButton rightFileNameEdit rightInvertButton + rightLibraryButton + rightLoadProfileButton rightLoadFwButton rightLoadPictButton rightSaveButton diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 3864b9f41..6a3806b21 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -734,7 +734,7 @@ GeneralSettings::GeneralSettings() QSettings settings; templateSetup = settings.value("default_channel_order", 0).toInt(); stickMode = settings.value("default_mode", 1).toInt(); - int profile_id = settings.value("ActiveProfile", 0).toInt(); + int profile_id = settings.value("profileId", 0).toInt(); if (profile_id>0) { settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profile_id); diff --git a/companion/src/fwpreferencesdialog.cpp b/companion/src/fwpreferencesdialog.cpp index 2dfce0e73..735e18acc 100644 --- a/companion/src/fwpreferencesdialog.cpp +++ b/companion/src/fwpreferencesdialog.cpp @@ -12,7 +12,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) : updateLock(false) { ui->setupUi(this); - setWindowIcon(CompanionIcon("preferences.png")); + setWindowIcon(CompanionIcon("fwpreferences.png")); QCheckBox * OptionCheckBox[]= { ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7, @@ -38,7 +38,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) : connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged())); connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); - resize(0,0); + shrink(); } @@ -47,32 +47,43 @@ fwPreferencesDialog::~fwPreferencesDialog() delete ui; } +void fwPreferencesDialog::showVoice(bool show) +{ + if (show) + showVoice(); + else + hideVoice(); +} + +void fwPreferencesDialog::showVoice() +{ + ui->voiceLine->show(); + ui->voiceLabel->show(); + ui->voiceCombo->show(); + ui->voice_dnld->show(); +} + +void fwPreferencesDialog::hideVoice() +{ + ui->voiceLine->hide(); + ui->voiceLabel->hide(); + ui->voiceCombo->hide(); + ui->voice_dnld->hide(); + QTimer::singleShot(0, this, SLOT(shrink())); +} + +void fwPreferencesDialog::shrink() +{ + resize(0,0); +} + void fwPreferencesDialog::baseFirmwareChanged() { QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex()); voice=NULL; foreach(FirmwareInfo * firmware, firmwares) { if (firmware->id == selected_firmware) { - if (firmware->voice) { - ui->voiceLabel->show(); - ui->voiceCombo->show(); - ui->voice_dnld->show(); - ui->sdPathButton->show(); - ui->sdPath->show(); - ui->sdPathLabel->show(); - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); - } else { - ui->voiceLabel->hide(); - ui->voiceCombo->hide(); - ui->voice_dnld->hide(); - ui->sdPathButton->hide(); - ui->sdPath->hide(); - ui->sdPathLabel->hide(); - } + showVoice(firmware->voice); populateFirmwareOptions(firmware); break; } @@ -109,11 +120,6 @@ FirmwareVariant fwPreferencesDialog::getFirmwareVariant() return default_firmware_variant; } -void fwPreferencesDialog::firmwareLangChanged() -{ - firmwareChanged(); -} - void fwPreferencesDialog::firmwareOptionChanged(bool state) { QCheckBox *cb = qobject_cast(sender()); @@ -134,19 +140,7 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state) } } if (voice) { - if (voice->isChecked()) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); - } else { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setDisabled(true); - ui->sdPath->setDisabled(true); - } + showVoice(voice->isChecked()); } return firmwareChanged(); @@ -157,37 +151,24 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state) } } else if (cb && !state) { if (cb->text()=="voice") { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); + hideVoice(); } } - if (voice ) { - if (voice->isChecked()) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - } else { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setDisabled(true); - ui->sdPath->setDisabled(true); - } + if (voice) { + showVoice(voice->isChecked()); } else if (firmware) { if (firmware->voice) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); + showVoice(); } } return firmwareChanged(); } +void fwPreferencesDialog::firmwareLangChanged() +{ + firmwareChanged(); +} + void fwPreferencesDialog::firmwareChanged() { if (updateLock) @@ -233,21 +214,10 @@ void fwPreferencesDialog::firmwareChanged() void fwPreferencesDialog::writeValues() { QSettings settings; - settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); - settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("cpu_id", ui->CPU_ID_LE->text()); - settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); - settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); current_firmware_variant = getFirmwareVariant(); settings.setValue("firmware", current_firmware_variant.id); - settings.setValue("profileId", ui->ProfSlot_SB->value()); - settings.setValue("sdPath", ui->sdPath->text()); - settings.setValue("SplashFileName", ui->SplashFileName->text()); - if (!ui->SplashFileName->text().isEmpty()) - settings.setValue("SplashImage", ""); - - MainWindow * mw = (MainWindow *)this->parent(); - mw->unloadProfile(); } void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) @@ -269,14 +239,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1); } - if (ui->langCombo->count()) { - ui->langCombo->show(); - ui->langLabel->show(); - } - else { - ui->langCombo->hide(); - ui->langLabel->hide(); - } + showVoice(ui->langCombo->count()!=0); int index = 0; foreach(QList @@ -32,181 +32,13 @@ 6 - - - - Download Voice + + + + Qt::Horizontal - - - - - - Offer to write FW to Tx after download - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - Download FW - - - - - - - Options - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - Processor ID - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - FwInfo - - - - - - - - 0 - 0 - - - - CheckBox + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -223,6 +55,19 @@ + + + + + 0 + 0 + + + + CheckBox + + + @@ -246,35 +91,6 @@ - - - - - 0 - 0 - - - - Default Stick Mode - - - - - - - - 0 - 0 - - - - Channel Order - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -301,60 +117,6 @@ - - - - - 190 - 16777215 - - - - Mode selection: - -Mode 1: - Left stick: Elevator, Rudder - Right stick: Throttle, Aileron - -Mode 2: - Left stick: Throttle, Rudder - Right stick: Elevator, Aileron - -Mode 3: - Left stick: Elevator, Aileron - Right stick: Throttle, Rudder - -Mode 4: - Left stick: Throttle, Aileron - Right stick: Elevator, Rudder - - - - - 1 - - - - Mode 1 (RUD ELE THR AIL) - - - - - Mode 2 (RUD THR ELE AIL) - - - - - Mode 3 (AIL ELE THR RUD) - - - - - Mode 4 (AIL THR ELE RUD) - - - - @@ -394,6 +156,9 @@ Mode 4: + + + @@ -410,8 +175,8 @@ Mode 4: - - + + @@ -436,159 +201,6 @@ Mode 4: - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 75 - 16777215 - - - - Channel order - -This is used by the templated to determine which channel goes to what number output. - - - 0 - - - - R E T A - - - - - R E A T - - - - - R T E A - - - - - R T A E - - - - - R A E T - - - - - R A T E - - - - - E R T A - - - - - E R A T - - - - - E T R A - - - - - E T A R - - - - - E A R T - - - - - E A T R - - - - - T R E A - - - - - T R A E - - - - - T E R A - - - - - T E A R - - - - - T A R E - - - - - T A E R - - - - - A R E T - - - - - A R T E - - - - - A E R T - - - - - A E T R - - - - - A T R E - - - - - A T E R - - - - @@ -641,19 +253,6 @@ This is used by the templated to determine which channel goes to what number out - - - - - 0 - 0 - - - - CheckBox - - - @@ -914,40 +513,6 @@ This is used by the templated to determine which channel goes to what number out - - - - Append version number to FW file name - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - Sans Serif - 75 - true - - - - Profile - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -961,37 +526,6 @@ This is used by the templated to determine which channel goes to what number out - - - - true - - - true - - - - - - - - 50 - 16777215 - - - - Set language of voice. -May be different from firmware language - - - - - - - Open Image - - - @@ -1006,109 +540,202 @@ May be different from firmware language - - - - - 0 - 0 - - - - Splash Screen - - - - - - - Clear Image - - - - - - - - - - - 0 - 0 - - + + - 16777215 + 50 16777215 - - 1 - - - 10 + + Set language of voice. +May be different from firmware language - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - + + - Open Folder + Download Voice - - - - true - - - true - - - - - + + - + 0 0 - SD Structure path - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + CheckBox - - + + + + + 0 + 0 + + - Save Profile + CheckBox + + + + + + + Download FW + + + + + + + Options + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + Processor ID + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + FwInfo + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal @@ -1161,10 +788,6 @@ May be different from firmware language optionCheckBox_40 optionCheckBox_41 optionCheckBox_42 - stickmodeCB - channelorderCB - renameFirmware - burnFirmware diff --git a/companion/src/images/originals/classical icons/apppreferences.png b/companion/src/images/originals/classical icons/apppreferences.png index 1f6613e40..d24ef0ad7 100644 Binary files a/companion/src/images/originals/classical icons/apppreferences.png and b/companion/src/images/originals/classical icons/apppreferences.png differ diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index df57d182c..f43b7f2c1 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -124,12 +124,6 @@ MainWindow::MainWindow(): updateMenus(); readSettings(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } setUnifiedTitleAndToolBarOnMac(true); this->setWindowIcon(QIcon(":/icon.png")); this->setIconSize(QSize(32,32)); @@ -758,11 +752,10 @@ void MainWindow::loadProfile() if (action) { int profnum=action->data().toInt(); QSettings settings; - settings.setValue("ActiveProfile",profnum); + settings.setValue("profileId",profnum); settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profnum); settings.beginGroup(profile); - ActiveProfile=profnum; ActiveProfileName=settings.value("Name", "").toString(); chord=settings.value("default_channel_order", 0).toInt(); defmod=settings.value("default_mode", 0).toInt(); @@ -785,46 +778,15 @@ void MainWindow::loadProfile() settings.setValue("SplashFileName", SplashFileName); settings.setValue("SplashImage", SplashImage); settings.setValue("firmware", firmware_id); - settings.setValue("profileId", profnum); current_firmware_variant = GetFirmwareVariant(firmware_id); - FirmwareInfo *firmware = GetCurrentFirmware(); - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - // settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { MdiChild *mdiChild = qobject_cast(window->widget()); mdiChild->eepromInterfaceChanged(); } - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } -} -void MainWindow::unloadProfile() -{ - ActiveProfile=0; - ActiveProfileName=""; - QSettings settings; - settings.setValue("ActiveProfile", 0); - FirmwareInfo *firmware = GetCurrentFirmware(); - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); -} - -void MainWindow::preferences() -{ - preferencesDialog *pd = new preferencesDialog(this); - pd->exec(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); + updateMenus(); } - else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } - - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { - MdiChild *mdiChild = qobject_cast(window->widget()); - mdiChild->eepromInterfaceChanged(); - } - updateMenus(); } void MainWindow::appPreferences() @@ -838,14 +800,6 @@ void MainWindow::fwPreferences() { fwPreferencesDialog *pd = new fwPreferencesDialog(this); pd->exec(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } - else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { MdiChild *mdiChild = qobject_cast(window->widget()); mdiChild->eepromInterfaceChanged(); @@ -1640,19 +1594,9 @@ void MainWindow::updateMenus() compareAct->setEnabled(activeMdiChild()); updateRecentFileActions(); updateProfilesActions(); - bool notfound=true; + QSettings settings; - settings.beginGroup("Profiles"); - for (int i=0; isetDisabled(notfound); + setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString())); } MdiChild *MainWindow::createMdiChild() @@ -1701,16 +1645,12 @@ void MainWindow::createActions() logsAct->setStatusTip(tr("Open log file")); connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile())); - preferencesAct = new QAction(tr("&Old Preferences Dialog..."), this); - preferencesAct->setStatusTip(tr("Used the old Preferences Dialog")); - connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences())); - - appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Application Preferences..."), this); - appPreferencesAct->setStatusTip(tr("Edit application preferences")); + appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Setting..."), this); + appPreferencesAct->setStatusTip(tr("Edit Settings")); connect(appPreferencesAct, SIGNAL(triggered()), this, SLOT(appPreferences())); - fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads and Profiles..."), this); - fwPreferencesAct->setStatusTip(tr("Firmware and voice file downloads as well as profile definition.")); + fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads..."), this); + fwPreferencesAct->setStatusTip(tr("Download firmware and voice files")); connect(fwPreferencesAct, SIGNAL(triggered()), this, SLOT(fwPreferences())); checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this); @@ -1833,6 +1773,9 @@ void MainWindow::createActions() connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); } updateProfilesActions(); + createProfileAct = new QAction(tr("New Profile"), this); + createProfileAct->setStatusTip(tr("Create a new Radio Setting Profile")); + connect(createProfileAct, SIGNAL(triggered()), this, SLOT(createProfile())); classicThemeAct = new QAction(tr("Classic"), this); classicThemeAct->setStatusTip(tr("The multicolor classical Companion icon theme")); @@ -1917,7 +1860,6 @@ void MainWindow::createMenus() { QMenu *recentFileMenu=new QMenu(tr("Recent Files")); - QMenu *profilesMenu=new QMenu(tr("Firmware Profiles")); QMenu *languageMenu=new QMenu(tr("Set Menu Language")); QMenu *themeMenu=new QMenu(tr("Set Icon Theme")); QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size")); @@ -1939,11 +1881,7 @@ void MainWindow::createMenus() fileMenu->addAction(compareAct); fileMenu->addSeparator(); fileMenu->addAction(fwPreferencesAct); - fileMenu->addMenu(profilesMenu); - - profilesMenu->setIcon(CompanionIcon("profiles.png")); - for (int i=0; iaddAction(profileActs[i]); + fileMenu->addMenu(createProfilesMenu()); fileMenu->addAction(exitAct); editMenu = menuBar()->addMenu(tr("&Edit")); @@ -1977,7 +1915,6 @@ void MainWindow::createMenus() settingsMenu->addSeparator(); settingsMenu->addAction(appPreferencesAct); settingsMenu->addAction(customizeSplashAct); - settingsMenu->addAction(preferencesAct); settingsMenu->addAction(burnConfigAct); burnMenu = menuBar()->addMenu(tr("&Read/Write")); @@ -2021,9 +1958,15 @@ QMenu *MainWindow::createRecentFileMenu() QMenu *MainWindow::createProfilesMenu() { - QMenu *profilesMenu = new QMenu(this); - for ( int i = 0; i < MAX_PROFILES; ++i) + QMenu *profilesMenu=new QMenu(tr("Radio Settings Profiles")); + int i; + for ( i = 0; i < MAX_PROFILES; ++i) { profilesMenu->addAction(profileActs[i]); + } + if ( i>0 ) + profilesMenu->addSeparator(); + profilesMenu->addAction(createProfileAct); + profilesMenu->setIcon(CompanionIcon("profiles.png")); return profilesMenu; } @@ -2039,11 +1982,14 @@ void MainWindow::createToolBars() case 1: size=QSize(24,24); break; + case 2: + size=QSize(32,32); + break; case 3: size=QSize(48,48); break; default: - size=QSize(32,32); + size=QSize(24,24); break; } fileToolBar = addToolBar(tr("File")); @@ -2051,11 +1997,11 @@ void MainWindow::createToolBars() fileToolBar->setObjectName("File"); fileToolBar->addAction(newAct); fileToolBar->addAction(openAct); - QToolButton * recentToolButton = new QToolButton; - recentToolButton->setPopupMode(QToolButton::InstantPopup); - recentToolButton->setMenu(createRecentFileMenu()); - recentToolButton->setIcon(CompanionIcon("recentdocument.png")); - recentToolButton->setToolTip(tr("Recent Files")); + QToolButton * recentToolButton = new QToolButton; + recentToolButton->setPopupMode(QToolButton::InstantPopup); + recentToolButton->setMenu(createRecentFileMenu()); + recentToolButton->setIcon(CompanionIcon("recentdocument.png")); + recentToolButton->setToolTip(tr("Recent Files")); fileToolBar->addWidget(recentToolButton); fileToolBar->addAction(saveAct); fileToolBar->addAction(logsAct); @@ -2063,24 +2009,12 @@ void MainWindow::createToolBars() fileToolBar->addAction(appPreferencesAct); fileToolBar->addAction(fwPreferencesAct); fileToolBar->addAction(customizeSplashAct); - profileButton = new QToolButton; - profileButton->setPopupMode(QToolButton::InstantPopup); - profileButton->setMenu(createProfilesMenu()); - profileButton->setIcon(CompanionIcon("profiles.png")); - profileButton->setToolTip(tr("Firmware Profiles")); + profileButton = new QToolButton; + profileButton->setPopupMode(QToolButton::InstantPopup); + profileButton->setMenu(createProfilesMenu()); + profileButton->setIcon(CompanionIcon("profiles.png")); + profileButton->setToolTip(tr("Firmware Profiles")); fileToolBar->addWidget(profileButton); - bool notfound=true; - settings.beginGroup("Profiles"); - for (int i=0; isetDisabled(notfound); fileToolBar->addSeparator(); fileToolBar->addAction(simulateAct); fileToolBar->addAction(printAct); @@ -2092,7 +2026,6 @@ void MainWindow::createToolBars() editToolBar->addAction(cutAct); editToolBar->addAction(copyAct); editToolBar->addAction(pasteAct); - burnToolBar = new QToolBar(tr("Write")); addToolBar( Qt::LeftToolBarArea, burnToolBar ); @@ -2128,15 +2061,18 @@ void MainWindow::readSettings() checkCompanion9x = settings.value("startup_check_companion", true).toBool(); checkFW = settings.value("startup_check_fw", true).toBool(); MaxRecentFiles =settings.value("history_size",10).toInt(); - ActiveProfile=settings.value("activeprofile",0).toInt(); - if (ActiveProfile) { - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(ActiveProfile); - settings.beginGroup(profile); - ActiveProfileName=settings.value("Name","").toString(); - settings.endGroup(); - settings.endGroup(); + if (settings.value("profileId",0).toInt() == 0) + { + createProfile(); + settings.setValue("profileId", "1"); } + int activeProfile=settings.value("profileId",0).toInt(); + settings.beginGroup("Profiles"); + QString profile=QString("profile%1").arg(activeProfile); + settings.beginGroup(profile); + ActiveProfileName=settings.value("Name","").toString(); + settings.endGroup(); + settings.endGroup(); } MdiChild *MainWindow::activeMdiChild() @@ -2189,6 +2125,8 @@ void MainWindow::updateProfilesActions() { int i; QSettings settings; + int activeProfile = settings.value("profileId").toInt(); + settings.beginGroup("Profiles"); for (i=0; isetText(text); profileActs[i]->setData(i+1); profileActs[i]->setVisible(true); + if ((i+1) == activeProfile) + profileActs[i]->setIcon(CompanionIcon("arrow-right.png")); + else + profileActs[i]->setIcon(CompanionIcon("")); + } else { profileActs[i]->setVisible(false); } settings.endGroup(); } - // separatorAct->setVisible(numRecentFiles > 0); } +void MainWindow::createProfile() +{ + int firstFreeIndex = 0; + QSettings settings; + settings.beginGroup("Profiles"); + for (int i=0; firstFreeIndex ==0 && i + + appPreferencesDialog + + + + 0 + 0 + 685 + 456 + + + + + 0 + 0 + + + + + 685 + 0 + + + + Application Preferences + + + + 2 + + + 6 + + + + + Open Folder + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Joystick + + + + + + + Simulator capture folder + + + + + + + Remember simulator switch values + + + + + + + + 0 + 0 + + + + User Splash Screens + + + + + + + + 0 + 0 + + + + Files to keep + + + + + + + Offer to use wizard for new models + + + true + + + + + + + Qt::Horizontal + + + + + + + + 100 + 16777215 + + + + + Blue + + + + + Green + + + + + Red + + + + + Orange + + + + + Yellow + + + + + + + + Automatic check for Companion updates + + + true + + + + + + + Qt::Horizontal + + + + + + + true + + + true + + + + + + + Only capture to clipboard + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + 15 + + + 10 + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 250 + 0 + + + + true + + + + + + + Calibrate + + + + + + + Automatic Backup Folder + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Open Folder + + + false + + + + + + + true + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Simulator BackLight + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Enable automatic backup before writing firmware + + + + + + + Show splash screen when Companion starts + + + true + + + + + + + Find Executable + + + + + + + Open Folder + + + + + + + Enable + + + + + + + Google Earth Executable + + + + + + + Automatic check for OpenTX firmware updates + + + true + + + + + + + + 0 + 0 + + + + + Include companion splashes + + + + + Only user defined splashes + + + + + + + + + 0 + 0 + + + + Splash Screen Library + + + + + + + true + + + true + + + + + startupCheck_companion9x + backupEnable + line + backupPath + line_2 + startupCheck_fw + wizardEnable_ChkB + ge_label + label_5 + showSplash + line_3 + ge_pathButton + line_4 + backupPathButton + label_3 + backLightColor + snapshotPath + snapshotPathButton + snapshotClipboardCKB + label_11 + joystickCB + joystickcalButton + ge_lineedit + simuSW + buttonBox + line_5 + joystickChkB + label_17 + label_19 + historySize + label_9 + libraryPath + libraryPathButton + line_6 + splashincludeCB + label_10 + + + buttonBox + ge_lineedit + ge_pathButton + historySize + showSplash + startupCheck_fw + startupCheck_companion9x + wizardEnable_ChkB + backupPath + backupPathButton + backupEnable + snapshotPath + snapshotPathButton + snapshotClipboardCKB + simuSW + backLightColor + joystickCB + joystickChkB + joystickcalButton + + + + + + + buttonBox + accepted() + appPreferencesDialog + accept() + + + 376 + 596 + + + 157 + 274 + + + + + buttonBox + rejected() + appPreferencesDialog + reject() + + + 396 + 596 + + + 286 + 274 + + + + + diff --git a/companion/src/themes/classic/16/apppreferences.png b/companion/src/themes/classic/16/apppreferences.png index dae98ee8a..afcc0a532 100644 Binary files a/companion/src/themes/classic/16/apppreferences.png and b/companion/src/themes/classic/16/apppreferences.png differ diff --git a/companion/src/themes/classic/24/apppreferences.png b/companion/src/themes/classic/24/apppreferences.png index ebca2028c..f979f3c96 100644 Binary files a/companion/src/themes/classic/24/apppreferences.png and b/companion/src/themes/classic/24/apppreferences.png differ diff --git a/companion/src/themes/classic/32/apppreferences.png b/companion/src/themes/classic/32/apppreferences.png index a9cee976b..cdc052910 100644 Binary files a/companion/src/themes/classic/32/apppreferences.png and b/companion/src/themes/classic/32/apppreferences.png differ diff --git a/companion/src/themes/classic/48/apppreferences.png b/companion/src/themes/classic/48/apppreferences.png index 713e2cbeb..8a94b21f8 100644 Binary files a/companion/src/themes/classic/48/apppreferences.png and b/companion/src/themes/classic/48/apppreferences.png differ