mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 00:05:17 +03:00
Almost all global settings wrapped in protective object to guarantee type safety and protect against tag spelling errors (I have found and corrected a lot of those!).
Joystick settings and burner configuration is not yet within the global object.
This commit is contained in:
parent
2633b61433
commit
c23a096a73
18 changed files with 204 additions and 1156 deletions
|
@ -187,6 +187,7 @@ class Profile:DataObj
|
|||
QString _SplashFileName;
|
||||
bool _burnFirmware;
|
||||
bool _rename_firmware_files;
|
||||
bool _patchImage;
|
||||
int _default_channel_order;
|
||||
int _default_mode;
|
||||
|
||||
|
@ -212,6 +213,7 @@ class Profile:DataObj
|
|||
QString SplashFileName() { return _SplashFileName; }
|
||||
bool burnFirmware() { return _burnFirmware; }
|
||||
bool rename_firmware_files() { return _rename_firmware_files; }
|
||||
bool patchImage() { return _patchImage; }
|
||||
int default_channel_order() { return _default_channel_order; }
|
||||
int default_mode() { return _default_mode; }
|
||||
|
||||
|
@ -240,6 +242,7 @@ class Profile:DataObj
|
|||
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" ,"Profiles", QString("profile%1").arg(index));}
|
||||
void burnFirmware (const bool bl) { store(bl, _burnFirmware, "burnFirmware" ,"Profiles", QString("profile%1").arg(index));}
|
||||
void rename_firmware_files (const bool bl) { store(bl, _rename_firmware_files, "rename_firmware_files" ,"Profiles", QString("profile%1").arg(index));}
|
||||
void patchImage (const bool bl) { store(bl, _patchImage, "patchImage" ,"Profiles", QString("profile%1").arg(index));}
|
||||
void default_channel_order (const int it) { store(it, _default_channel_order, "default_channel_order" ,"Profiles", QString("profile%1").arg(index));}
|
||||
void default_mode (const int it) { store(it, _default_mode, "default_mode" ,"Profiles", QString("profile%1").arg(index));}
|
||||
|
||||
|
@ -295,6 +298,7 @@ class Profile:DataObj
|
|||
getset( _SplashFileName, "SplashFileName" ,"" ,"Profiles", QString("profile%1").arg(index));
|
||||
getset( _burnFirmware, "burnFirmware" ,false ,"Profiles", QString("profile%1").arg(index));
|
||||
getset( _rename_firmware_files, "rename_firmware_files" ,false ,"Profiles", QString("profile%1").arg(index));
|
||||
getset( _patchImage, "patchImage" ,false ,"Profiles", QString("profile%1").arg(index));
|
||||
getset( _default_channel_order, "default_channel_order" ,0 ,"Profiles", QString("profile%1").arg(index));
|
||||
getset( _default_mode, "default_mode" ,1 ,"Profiles", QString("profile%1").arg(index));
|
||||
|
||||
|
@ -322,6 +326,7 @@ class Profile:DataObj
|
|||
_SplashFileName = "";
|
||||
_burnFirmware = false;
|
||||
_rename_firmware_files = false;
|
||||
_patchImage = false;
|
||||
_default_channel_order = 0;
|
||||
_default_mode = 1;
|
||||
|
||||
|
@ -353,18 +358,16 @@ class AppData:DataObj
|
|||
{
|
||||
// All the global variables
|
||||
public:
|
||||
Profile profile[MAX_PROFILES];
|
||||
Profile pro[MAX_PROFILES];
|
||||
|
||||
private:
|
||||
QStringList _recentFileList;
|
||||
QByteArray _mainWindowGeometry;
|
||||
QByteArray _mainWindowState;
|
||||
|
||||
QString _firmware;
|
||||
QString _locale;
|
||||
QString _cpu_id;
|
||||
QString _Name;
|
||||
QString _SplashFileName;
|
||||
QString _lastFw;
|
||||
QString _modelEditGeometry;
|
||||
|
||||
QString _backupPath;
|
||||
|
@ -372,16 +375,15 @@ class AppData:DataObj
|
|||
QString _lastDir;
|
||||
QString _lastFlashDir;
|
||||
QString _lastImagesDir;
|
||||
QString _lastLogDir;
|
||||
QString _libraryPath;
|
||||
QString _sdPath;
|
||||
QString _snapshotpath;
|
||||
|
||||
bool _backupEnable;
|
||||
bool _backupOnFlash;
|
||||
bool _burnFirmware;
|
||||
bool _maximized;
|
||||
bool _js_support;
|
||||
bool _rename_firmware_files;
|
||||
bool _rev4asupport;
|
||||
bool _show_splash;
|
||||
bool _snapshot_to_clipboard;
|
||||
bool _startup_check_companion;
|
||||
|
@ -390,8 +392,6 @@ class AppData:DataObj
|
|||
bool _wizardEnable;
|
||||
|
||||
int _backLight;
|
||||
int _default_channel_order;
|
||||
int _default_mode;
|
||||
int _embedded_splashes; // Shouldn't this be bool ??
|
||||
int _fwserver;
|
||||
int _generalEditTab;
|
||||
|
@ -403,8 +403,6 @@ class AppData:DataObj
|
|||
int _theme;
|
||||
int _warningId;
|
||||
|
||||
// Storage functions
|
||||
|
||||
|
||||
public:
|
||||
// All the get declarations
|
||||
|
@ -412,11 +410,9 @@ public:
|
|||
QByteArray mainWindowGeometry(){ return _mainWindowGeometry; }
|
||||
QByteArray mainWindowState() { return _mainWindowState; }
|
||||
|
||||
QString firmware() { return _firmware; }
|
||||
QString locale() { return _locale; }
|
||||
QString cpu_id() { return _cpu_id; }
|
||||
QString Name() { return _Name; }
|
||||
QString SplashFileName() { return _SplashFileName; }
|
||||
QString lastFw() { return _lastFw; }
|
||||
QString modelEditGeometry() { return _modelEditGeometry; }
|
||||
|
||||
QString backupPath() { return _backupPath; }
|
||||
|
@ -424,16 +420,15 @@ public:
|
|||
QString lastDir() { return _lastDir; }
|
||||
QString lastFlashDir() { return _lastFlashDir; }
|
||||
QString lastImagesDir() { return _lastImagesDir; }
|
||||
QString lastLogDir() { return _lastLogDir; }
|
||||
QString libraryPath() { return _libraryPath; }
|
||||
QString sdPath() { return _sdPath; }
|
||||
QString snapshotpath() { return _snapshotpath; }
|
||||
|
||||
bool backupEnable() { return _backupEnable; }
|
||||
bool backupOnFlash() { return _backupOnFlash; }
|
||||
bool burnFirmware() { return _burnFirmware; }
|
||||
bool js_support() { return _js_support; }
|
||||
bool rev4asupport() { return _rev4asupport; }
|
||||
bool maximized() { return _maximized; }
|
||||
bool rename_firmware_files() { return _rename_firmware_files; }
|
||||
bool show_splash() { return _show_splash; }
|
||||
bool snapshot_to_clipboard() { return _snapshot_to_clipboard; }
|
||||
bool startup_check_companion() { return _startup_check_companion;}
|
||||
|
@ -442,8 +437,6 @@ public:
|
|||
bool wizardEnable() { return _wizardEnable; }
|
||||
|
||||
int backLight() { return _backLight; }
|
||||
int default_channel_order() { return _default_channel_order; }
|
||||
int default_mode() { return _default_mode; }
|
||||
int embedded_splashes() { return _embedded_splashes; }
|
||||
int fwserver() { return _fwserver; }
|
||||
int generalEditTab() { return _generalEditTab; }
|
||||
|
@ -455,16 +448,14 @@ public:
|
|||
int theme() { return _theme; }
|
||||
int warningId() { return _warningId; }
|
||||
|
||||
// All the set declarations
|
||||
// All the set declarations
|
||||
void recentFileList (const QStringList l) { store(l, _recentFileList, "recentFileList" );}
|
||||
void mainWindowGeometry (const QByteArray a) { store(a, _mainWindowGeometry, "mainWindowGeometry");}
|
||||
void mainWindowState (const QByteArray a) { store(a, _mainWindowState, "mainWindowState" );}
|
||||
|
||||
void firmware (const QString str) { store(str, _firmware, "firmware" );}
|
||||
void locale (const QString str) { store(str, _locale, "locale" );}
|
||||
void cpu_id (const QString str) { store(str, _cpu_id, "cpu_id" );}
|
||||
void Name (const QString str) { store(str, _Name, "Name" );}
|
||||
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" );}
|
||||
void lastFw (const QString str) { store(str, _lastFw, "lastFw" );}
|
||||
void modelEditGeometry (const QString str) { store(str, _modelEditGeometry, "modelEditGeometry" );}
|
||||
|
||||
void backupPath (const QString str) { store(str, _backupPath, "backupPath" );}
|
||||
|
@ -472,16 +463,15 @@ public:
|
|||
void lastDir (const QString str) { store(str, _lastDir, "lastDir" );}
|
||||
void lastFlashDir (const QString str) { store(str, _lastFlashDir, "lastFlashDir" );}
|
||||
void lastImagesDir (const QString str) { store(str, _lastImagesDir, "lastImagesDir" );}
|
||||
void lastLogDir (const QString str) { store(str, _lastLogDir, "lastLogDir" );}
|
||||
void libraryPath (const QString str) { store(str, _libraryPath, "libraryPath" );}
|
||||
void sdPath (const QString str) { store(str, _sdPath, "sdPath" );}
|
||||
void snapshotpath (const QString str) { store(str, _snapshotpath, "snapshotpath" );}
|
||||
|
||||
void backupEnable (const bool bl) { store(bl, _backupEnable, "backupEnable" );}
|
||||
void backupOnFlash (const bool bl) { store(bl, _backupOnFlash, "backupOnFlash" );}
|
||||
void burnFirmware (const bool bl) { store(bl, _burnFirmware, "burnFirmware" );}
|
||||
void maximized (const bool bl) { store(bl, _maximized, "maximized" );}
|
||||
void js_support (const bool bl) { store(bl, _js_support, "js_support" );}
|
||||
void rename_firmware_files (const bool bl) { store(bl, _rename_firmware_files, "rename_firmware_files" );}
|
||||
void rev4asupport (const bool bl) { store(bl, _rev4asupport, "rev4asupport" );}
|
||||
void show_splash (const bool bl) { store(bl, _show_splash, "show_splash" );}
|
||||
void snapshot_to_clipboard (const bool bl) { store(bl, _snapshot_to_clipboard, "snapshot_to_clipboard" );}
|
||||
void startup_check_companion (const bool bl) { store(bl, _startup_check_companion, "startup_check_companion" );}
|
||||
|
@ -490,8 +480,6 @@ public:
|
|||
void wizardEnable (const bool bl) { store(bl, _wizardEnable, "wizardEnable" );}
|
||||
|
||||
void backLight (const int it) { store(it, _backLight, "backLight" );}
|
||||
void default_channel_order (const int it) { store(it, _default_channel_order, "default_channel_order" );}
|
||||
void default_mode (const int it) { store(it, _default_mode, "default_mode" );}
|
||||
void embedded_splashes (const int it) { store(it, _embedded_splashes, "embedded_splashes" );}
|
||||
void fwserver (const int it) { store(it, _fwserver, "fwserver" );}
|
||||
void generalEditTab (const int it) { store(it, _generalEditTab, "generalEditTab" );}
|
||||
|
@ -506,34 +494,58 @@ public:
|
|||
// Constructor
|
||||
AppData()
|
||||
{
|
||||
// Start by hijacking all left over settings from companion9x, but only do it one time
|
||||
//Initialize the profiles
|
||||
for (int i=0; i<MAX_PROFILES; i++)
|
||||
pro[i].init( i );
|
||||
|
||||
// Import settings from companion9x, but only do it one time.
|
||||
// Use "location" tag as an indicator that the settings are missing
|
||||
QSettings c9x_settings("companion9x", "companion9x");
|
||||
QSettings settings(PRODUCT, COMPANY);
|
||||
if (!settings.contains("locale")) {
|
||||
if (!settings.contains("locale"))
|
||||
{
|
||||
QStringList keys = c9x_settings.allKeys();
|
||||
for (QStringList::iterator i=keys.begin(); i!=keys.end(); i++) {
|
||||
for (QStringList::iterator i=keys.begin(); i!=keys.end(); i++)
|
||||
{
|
||||
settings.setValue(*i, c9x_settings.value(*i));
|
||||
}
|
||||
// Convert firmware name
|
||||
QString firmware = settings.value("firmware", "").toString();
|
||||
firmware.replace("open9x","opentx");
|
||||
firmware.replace("x9da","taranis");
|
||||
|
||||
// Move Companion9x settings to profile0, the new default profile
|
||||
pro[0].firmware(firmware);
|
||||
pro[0].Name(settings.value( "Name", "" ).toString());
|
||||
pro[0].sdPath(settings.value( "sdPath", "" ).toString());
|
||||
pro[0].SplashFileName(settings.value( "SplashFileName", "" ).toString());
|
||||
pro[0].burnFirmware(settings.value( "burnFirmware", false ).toBool());
|
||||
pro[0].rename_firmware_files(settings.value("rename_firmware_files", false ).toBool());
|
||||
pro[0].patchImage(settings.value( "patchImage", false ).toBool());
|
||||
pro[0].default_channel_order(settings.value("default_channel_order", "0" ).toInt());
|
||||
pro[0].default_mode(settings.value( "default_mode", "1" ).toInt());
|
||||
|
||||
// Delete unused settings
|
||||
settings.remove("firmware");
|
||||
settings.remove("Name");
|
||||
settings.remove("sdPath");
|
||||
settings.remove("SplashFileName");
|
||||
settings.remove("burnFirmware");
|
||||
settings.remove("rename_firmware_files");
|
||||
settings.remove("patchImage");
|
||||
settings.remove("default_channel_order");
|
||||
settings.remove("default_mode");
|
||||
}
|
||||
|
||||
//Initialize the index variables of the profiles
|
||||
for (int i=0; i<MAX_PROFILES; i++)
|
||||
profile[i].init( i );
|
||||
|
||||
|
||||
|
||||
// Load and store all variables. Use default values if setting values are missing
|
||||
|
||||
getset( _recentFileList, "recentFileList" ,"" );
|
||||
getset( _mainWindowGeometry, "mainWindowGeometry" ,"" );
|
||||
getset( _mainWindowState, "mainWindowState" ,"" );
|
||||
|
||||
getset( _firmware, "firmware" ,"" );
|
||||
getset( _locale, "locale" ,"" );
|
||||
getset( _cpu_id, "cpu_id" ,"" );
|
||||
getset( _Name, "Name" ,"----" );
|
||||
getset( _SplashFileName, "SplashFileName" ,"" );
|
||||
getset( _lastFw, "lastFw" ,"" );
|
||||
getset( _modelEditGeometry, "modelEditGeometry" ,"" );
|
||||
|
||||
getset( _backupPath, "backupPath" ,"" );
|
||||
|
@ -541,16 +553,15 @@ public:
|
|||
getset( _lastDir, "lastDir" ,"" );
|
||||
getset( _lastFlashDir, "lastFlashDir" ,"" );
|
||||
getset( _lastImagesDir, "lastImagesDir" ,"" );
|
||||
getset( _lastLogDir, "lastLogDir" ,"" );
|
||||
getset( _libraryPath, "libraryPath" ,"" );
|
||||
getset( _sdPath, "sdPath" ,"" );
|
||||
getset( _snapshotpath, "snapshotpath" ,"" );
|
||||
|
||||
getset( _backupEnable, "backupEnable" ,false );
|
||||
getset( _backupOnFlash, "backupOnFlash" ,true );
|
||||
getset( _burnFirmware, "burnFirmware" ,false );
|
||||
getset( _js_support, "js_support" ,false );
|
||||
getset( _rev4asupport, "rev4asupport" ,false );
|
||||
getset( _maximized, "maximized" ,false );
|
||||
getset( _rename_firmware_files, "rename_firmware_files" ,false );
|
||||
getset( _show_splash, "show_splash" ,true );
|
||||
getset( _snapshot_to_clipboard, "snapshot_to_clipboard" ,false );
|
||||
getset( _startup_check_companion, "startup_check_companion" ,true );
|
||||
|
@ -559,8 +570,6 @@ public:
|
|||
getset( _wizardEnable, "wizardEnable" ,true );
|
||||
|
||||
getset( _backLight, "backLight" ,0 );
|
||||
getset( _default_channel_order, "default_channel_order" ,0 );
|
||||
getset( _default_mode, "default_mode" ,1 );
|
||||
getset( _embedded_splashes, "embedded_splashes" ,0 );
|
||||
getset( _fwserver, "fwserver" ,0 );
|
||||
getset( _generalEditTab, "generalEditTab" ,0 );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "apppreferencesdialog.h"
|
||||
#include "ui_apppreferencesdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "appdata.h"
|
||||
#include "helpers.h"
|
||||
#include "flashinterface.h"
|
||||
#ifdef JOYSTICKS
|
||||
|
@ -56,15 +57,16 @@ void appPreferencesDialog::writeValues()
|
|||
glob.js_ctrl(0);
|
||||
}
|
||||
|
||||
glob.default_channel_order(ui->channelorderCB->currentIndex());
|
||||
glob.default_mode(ui->stickmodeCB->currentIndex());
|
||||
glob.rename_firmware_files(ui->renameFirmware->isChecked());
|
||||
glob.burnFirmware(ui->burnFirmware->isChecked());
|
||||
glob.profileId(ui->profileIndexLE->text().toInt());
|
||||
glob.Name(ui->profileNameLE->text());
|
||||
glob.sdPath(ui->sdPath->text());
|
||||
glob.SplashFileName(ui->SplashFileName->text());
|
||||
glob.firmware(ui->firmwareLE->text());
|
||||
|
||||
glob.pro[glob.profileId()].default_channel_order(ui->channelorderCB->currentIndex());
|
||||
glob.pro[glob.profileId()].default_mode(ui->stickmodeCB->currentIndex());
|
||||
glob.pro[glob.profileId()].rename_firmware_files(ui->renameFirmware->isChecked());
|
||||
glob.pro[glob.profileId()].burnFirmware(ui->burnFirmware->isChecked());
|
||||
glob.pro[glob.profileId()].Name(ui->profileNameLE->text());
|
||||
glob.pro[glob.profileId()].sdPath(ui->sdPath->text());
|
||||
glob.pro[glob.profileId()].SplashFileName(ui->SplashFileName->text());
|
||||
glob.pro[glob.profileId()].firmware(ui->firmwareLE->text());
|
||||
|
||||
saveProfile();
|
||||
}
|
||||
|
@ -82,7 +84,7 @@ void appPreferencesDialog::on_snapshotPathButton_clicked()
|
|||
void appPreferencesDialog::initSettings()
|
||||
{
|
||||
ui->snapshotClipboardCKB->setChecked(glob.snapshot_to_clipboard());
|
||||
ui->burnFirmware->setChecked(glob.burnFirmware());
|
||||
ui->burnFirmware->setChecked(glob.pro[glob.profileId()].burnFirmware());
|
||||
ui->snapshotPath->setText(glob.snapshotpath());
|
||||
ui->snapshotPath->setReadOnly(true);
|
||||
if (ui->snapshotClipboardCKB->isChecked())
|
||||
|
@ -141,15 +143,15 @@ void appPreferencesDialog::initSettings()
|
|||
}
|
||||
#endif
|
||||
// Profile Tab Inits
|
||||
ui->channelorderCB->setCurrentIndex(glob.default_channel_order());
|
||||
ui->stickmodeCB->setCurrentIndex(glob.default_mode());
|
||||
ui->renameFirmware->setChecked(glob.rename_firmware_files());
|
||||
ui->sdPath->setText(glob.sdPath());
|
||||
ui->channelorderCB->setCurrentIndex(glob.pro[glob.profileId()].default_channel_order());
|
||||
ui->stickmodeCB->setCurrentIndex(glob.pro[glob.profileId()].default_mode());
|
||||
ui->renameFirmware->setChecked(glob.pro[glob.profileId()].rename_firmware_files());
|
||||
ui->sdPath->setText(glob.pro[glob.profileId()].sdPath());
|
||||
ui->profileIndexLE->setText(QString("%1").arg(glob.profileId()));
|
||||
ui->profileNameLE->setText(glob.Name());
|
||||
ui->firmwareLE->setText(glob.firmware());
|
||||
ui->SplashFileName->setText(glob.SplashFileName());
|
||||
displayImage( glob.SplashFileName() );
|
||||
ui->profileNameLE->setText(glob.pro[glob.profileId()].Name());
|
||||
ui->firmwareLE->setText(glob.pro[glob.profileId()].firmware());
|
||||
ui->SplashFileName->setText(glob.pro[glob.profileId()].SplashFileName());
|
||||
displayImage( glob.pro[glob.profileId()].SplashFileName() );
|
||||
}
|
||||
|
||||
void appPreferencesDialog::on_libraryPathButton_clicked()
|
||||
|
@ -230,7 +232,7 @@ void appPreferencesDialog::on_joystickcalButton_clicked() {
|
|||
|
||||
void appPreferencesDialog::on_sdPathButton_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), glob.sdPath());
|
||||
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), glob.pro[glob.profileId()].sdPath());
|
||||
if (!fileName.isEmpty()) {
|
||||
ui->sdPath->setText(fileName);
|
||||
}
|
||||
|
@ -242,63 +244,41 @@ void appPreferencesDialog::saveProfile()
|
|||
if (ui->profileNameLE->text().isEmpty())
|
||||
ui->profileNameLE->setText("----");
|
||||
|
||||
glob.profile[glob.profileId()].Name( ui->profileNameLE->text() );
|
||||
glob.profile[glob.profileId()].default_channel_order( ui->channelorderCB->currentIndex());
|
||||
glob.profile[glob.profileId()].default_mode( ui->stickmodeCB->currentIndex());
|
||||
glob.profile[glob.profileId()].burnFirmware( ui->burnFirmware->isChecked());
|
||||
glob.profile[glob.profileId()].rename_firmware_files( ui->renameFirmware->isChecked());
|
||||
glob.profile[glob.profileId()].sdPath( ui->sdPath->text());
|
||||
glob.profile[glob.profileId()].SplashFileName( ui->SplashFileName->text());
|
||||
glob.profile[glob.profileId()].firmware( ui->firmwareLE->text());
|
||||
}
|
||||
|
||||
void appPreferencesDialog::loadFromProfile()
|
||||
{
|
||||
int i = glob.profileId();
|
||||
glob.Name( glob.profile[i].Name() );
|
||||
glob.default_channel_order( glob.profile[i].default_channel_order());
|
||||
glob.default_mode( glob.profile[i].default_mode());
|
||||
glob.burnFirmware( glob.profile[i].burnFirmware());
|
||||
glob.rename_firmware_files( glob.profile[i].rename_firmware_files());
|
||||
glob.sdPath( glob.profile[i].sdPath());
|
||||
glob.SplashFileName( glob.profile[i].SplashFileName());
|
||||
glob.firmware( glob.profile[i].firmware());
|
||||
glob.pro[glob.profileId()].Name( ui->profileNameLE->text() );
|
||||
glob.pro[glob.profileId()].default_channel_order( ui->channelorderCB->currentIndex());
|
||||
glob.pro[glob.profileId()].default_mode( ui->stickmodeCB->currentIndex());
|
||||
glob.pro[glob.profileId()].burnFirmware( ui->burnFirmware->isChecked());
|
||||
glob.pro[glob.profileId()].rename_firmware_files( ui->renameFirmware->isChecked());
|
||||
glob.pro[glob.profileId()].sdPath( ui->sdPath->text());
|
||||
glob.pro[glob.profileId()].SplashFileName( ui->SplashFileName->text());
|
||||
glob.pro[glob.profileId()].firmware( ui->firmwareLE->text());
|
||||
}
|
||||
|
||||
void appPreferencesDialog::on_removeProfileButton_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
if ( glob.profileId() == 0 )
|
||||
QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
|
||||
else
|
||||
{
|
||||
glob.profile[glob.profileId()].remove();
|
||||
glob.pro[glob.profileId()].remove();
|
||||
glob.profileId( 0 );
|
||||
loadFromProfile();
|
||||
initSettings();
|
||||
}
|
||||
}
|
||||
|
||||
bool appPreferencesDialog::displayImage( QString fileName )
|
||||
{
|
||||
// Start by filling the pixmap with white
|
||||
// Start by clearing the pixmap
|
||||
ui->imageLabel->setPixmap(QPixmap());
|
||||
|
||||
QImage image(fileName);
|
||||
if (image.isNull())
|
||||
return false;
|
||||
|
||||
// This code below just figures out if the width of the latest firmware is 128 or 212. It works , but...
|
||||
QString filePath1 = glob.lastFlashDir() + "/" + glob.firmware() + ".bin";
|
||||
QString filePath2 = glob.lastFlashDir() + "/" + glob.firmware() + ".hex";
|
||||
QFile file(filePath1);
|
||||
if (!file.exists())
|
||||
filePath1 = filePath2;
|
||||
// Use the firmware name to determine splash width
|
||||
int width = SPLASH_WIDTH;
|
||||
FlashInterface flash(filePath1);
|
||||
if (flash.hasSplash())
|
||||
width = flash.getSplashWidth(); // Returns SPLASHX9D_HEIGHT if filePath1 does not exist!
|
||||
// There must be a cleaner way of finding out the width of the firmware splash!
|
||||
if (glob.pro[glob.profileId()].firmware().contains("taranis"))
|
||||
width = SPLASHX9D_WIDTH;
|
||||
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT)));
|
||||
if (width==SPLASHX9D_WIDTH) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "splashlibrary.h"
|
||||
#include "flashinterface.h"
|
||||
#include "hexinterface.h"
|
||||
#include "appdata.h"
|
||||
|
||||
burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName):
|
||||
QDialog(parent),
|
||||
|
@ -58,15 +59,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
|
|||
else {
|
||||
setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
|
||||
}
|
||||
QSettings settings;
|
||||
int profileid=settings.value("profileId", 1).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profileid);
|
||||
settings.beginGroup(profile);
|
||||
QString Name=settings.value("Name","").toString();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
ui->profile_label->setText(tr("Current profile")+QString(": ")+Name);
|
||||
ui->profile_label->setText(tr("Current profile")+QString(": ")+glob.pro[glob.profileId()].Name());
|
||||
}
|
||||
if (!hexfileName->isEmpty()) {
|
||||
ui->FWFileName->setText(*hexfileName);
|
||||
|
@ -77,9 +70,8 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
|
|||
burnraw=false;
|
||||
if (checkeEprom(*hexfileName)) {
|
||||
QSettings settings;
|
||||
int profileid=settings.value("profileId", 1).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profileid);
|
||||
QString profile=QString("profile%1").arg(glob.profileId());
|
||||
settings.beginGroup(profile);
|
||||
QString Name=settings.value("Name","").toString();
|
||||
QString calib=settings.value("StickPotCalib","").toString();
|
||||
|
@ -119,9 +111,8 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
|
|||
hexfileName->clear();
|
||||
}
|
||||
else if (Type==2) {
|
||||
QSettings settings;
|
||||
QString FileName;
|
||||
FileName = settings.value("lastFw").toString();
|
||||
FileName = glob.lastFw();
|
||||
QFile file(FileName);
|
||||
if (file.exists()) {
|
||||
checkFw(FileName);
|
||||
|
@ -138,7 +129,7 @@ burnDialog::~burnDialog()
|
|||
void burnDialog::on_FlashLoadButton_clicked()
|
||||
{
|
||||
QString fileName;
|
||||
QSettings settings;
|
||||
|
||||
ui->ImageLoadButton->setDisabled(true);
|
||||
ui->libraryButton->setDisabled(true);
|
||||
ui->InvertColorButton->setDisabled(true);
|
||||
|
@ -155,11 +146,11 @@ void burnDialog::on_FlashLoadButton_clicked()
|
|||
ui->EEbackupCB->hide();
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
if (hexType==2) {
|
||||
fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
|
||||
fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastFlashDir(), FLASH_FILES_FILTER);
|
||||
checkFw(fileName);
|
||||
}
|
||||
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"), glob.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
|
||||
if (checkeEprom(fileName)) {
|
||||
if (burnraw==false) {
|
||||
ui->BurnFlashButton->setEnabled(true);
|
||||
|
@ -191,7 +182,6 @@ void burnDialog::checkFw(QString fileName)
|
|||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QSettings settings;
|
||||
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||
ui->EEbackupCB->show();
|
||||
}
|
||||
|
@ -216,8 +206,8 @@ void burnDialog::checkFw(QString fileName)
|
|||
ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
|
||||
ui->FwImage->show();
|
||||
ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash()));
|
||||
QString ImageStr = settings.value("SplashImage", "").toString();
|
||||
bool PatchFwCB = settings.value("patchImage", false).toBool();
|
||||
QString ImageStr = glob.pro[glob.profileId()].SplashFileName();
|
||||
bool PatchFwCB = glob.pro[glob.profileId()].patchImage();
|
||||
if (!ImageStr.isEmpty()) {
|
||||
QImage Image = qstring2image(ImageStr);
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat())));
|
||||
|
@ -260,7 +250,7 @@ void burnDialog::checkFw(QString fileName)
|
|||
ui->BurnFlashButton->setEnabled(true);
|
||||
}
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
}
|
||||
|
||||
bool burnDialog::checkeEprom(QString fileName)
|
||||
|
@ -360,12 +350,11 @@ void burnDialog::on_ImageLoadButton_clicked()
|
|||
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));
|
||||
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastImagesDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
QImage image(fileName);
|
||||
if (image.isNull()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
|
||||
|
@ -442,11 +431,10 @@ void burnDialog::on_BurnFlashButton_clicked()
|
|||
if (hexType==2) {
|
||||
QString fileName=ui->FWFileName->text();
|
||||
if (!fileName.isEmpty()) {
|
||||
QSettings settings;
|
||||
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
|
||||
settings.setValue("lastFw", fileName);
|
||||
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
glob.lastFw( fileName );
|
||||
if (ui->PatchFWCB->isChecked()) {
|
||||
settings.setValue("patchImage", true);
|
||||
glob.pro[glob.profileId()].patchImage( true );
|
||||
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height());
|
||||
if (!image.isNull()) {
|
||||
QString tempDir = QDir::tempPath();
|
||||
|
@ -469,7 +457,7 @@ void burnDialog::on_BurnFlashButton_clicked()
|
|||
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
|
||||
}
|
||||
} else {
|
||||
settings.setValue("patchImage", false);
|
||||
glob.pro[glob.profileId()].patchImage( false );
|
||||
hexfileName->clear();
|
||||
hexfileName->append(fileName);
|
||||
}
|
||||
|
@ -480,7 +468,7 @@ void burnDialog::on_BurnFlashButton_clicked()
|
|||
}
|
||||
if (hexType==1) {
|
||||
QSettings settings;
|
||||
int profileid=settings.value("profileId", 1).toInt();
|
||||
int profileid=glob.profileId();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profileid);
|
||||
settings.beginGroup(profile);
|
||||
|
@ -656,8 +644,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked)
|
|||
{
|
||||
QString tmpFileName;
|
||||
if (checked) {
|
||||
QSettings settings;
|
||||
QString ImageStr = settings.value("SplashImage", "").toString();
|
||||
QString ImageStr = glob.pro[glob.profileId()].SplashFileName();
|
||||
if (!ImageStr.isEmpty()) {
|
||||
QImage Image = qstring2image(ImageStr);
|
||||
if (ui->imageLabel->width()!=128) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_customizesplashdialog.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include "appdata.h"
|
||||
#include "helpers.h"
|
||||
#include "burndialog.h"
|
||||
#include "splashlibrary.h"
|
||||
|
@ -28,9 +29,10 @@ bool Side::displayImage( QString fileName, Source pictSource )
|
|||
{
|
||||
QImage image;
|
||||
|
||||
if (fileName.isEmpty()) {
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine which picture format to use
|
||||
if (pictSource == FW ){
|
||||
FlashInterface flash(fileName);
|
||||
if (!flash.hasSplash())
|
||||
|
@ -43,10 +45,13 @@ bool Side::displayImage( QString fileName, Source pictSource )
|
|||
image.load(fileName);
|
||||
if (pictSource== PICT)
|
||||
*format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X;
|
||||
else if (pictSource == PROFILE)
|
||||
*format = (glob.pro[glob.profileId()].firmware().contains("taranis")) ? LCDTARANIS : LCD9X;
|
||||
}
|
||||
if (image.isNull()) {
|
||||
return false;
|
||||
}
|
||||
// Prepare and display image
|
||||
if (*format==LCDTARANIS) {
|
||||
image=image.convertToFormat(QImage::Format_RGB32);
|
||||
QRgb col;
|
||||
|
@ -102,8 +107,6 @@ bool Side::refreshImage()
|
|||
|
||||
bool Side::saveImage()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
if (*source == FW )
|
||||
{
|
||||
FlashInterface flash(*saveToFileName);
|
||||
|
@ -112,7 +115,7 @@ bool Side::saveImage()
|
|||
}
|
||||
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());
|
||||
glob.lastFlashDir( QFileInfo(*saveToFileName).dir().absolutePath() );
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -121,7 +124,7 @@ bool Side::saveImage()
|
|||
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());
|
||||
glob.lastImagesDir( QFileInfo(*saveToFileName).dir().absolutePath() );
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -178,13 +181,12 @@ void customizeSplashDialog::on_leftLoadFwButton_clicked() {loadFirmware(left);}
|
|||
void customizeSplashDialog::on_rightLoadFwButton_clicked() {loadFirmware(right);}
|
||||
void customizeSplashDialog::loadFirmware(Side side)
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastFlashDir(), FLASH_FILES_FILTER);
|
||||
if (!fileName.isEmpty()) {
|
||||
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());
|
||||
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,15 +198,14 @@ void customizeSplashDialog::loadPicture(Side side)
|
|||
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));
|
||||
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
|
||||
|
||||
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());
|
||||
glob.lastImagesDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,8 +213,7 @@ 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();
|
||||
QString fileName=glob.pro[glob.profileId()].SplashFileName();
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!side.displayImage( fileName, PROFILE ))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "firmwares/opentx/opentxinterface.h"
|
||||
#include "firmwares/ersky9x/ersky9xinterface.h"
|
||||
#include "qsettings.h"
|
||||
#include "appdata.h"
|
||||
#include "helpers.h"
|
||||
|
||||
QString EEPROMWarnings;
|
||||
|
@ -734,8 +735,8 @@ GeneralSettings::GeneralSettings()
|
|||
QSettings settings;
|
||||
templateSetup = settings.value("default_channel_order", 0).toInt();
|
||||
stickMode = settings.value("default_mode", 1).toInt();
|
||||
int profile_id = settings.value("profileId", 0).toInt();
|
||||
if (profile_id>0) {
|
||||
int profile_id = glob.profileId();
|
||||
if (profile_id>-1) {
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profile_id);
|
||||
settings.beginGroup(profile);
|
||||
|
@ -990,14 +991,12 @@ ModelData ModelData::removeGlobalVars()
|
|||
QList<EEPROMInterface *> eepromInterfaces;
|
||||
void RegisterEepromInterfaces()
|
||||
{
|
||||
QSettings settings;
|
||||
int rev4a = settings.value("rev4asupport",0).toInt();
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK));
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_M128));
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X));
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X));
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS));
|
||||
if (rev4a)
|
||||
if (glob.rev4asupport())
|
||||
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a));
|
||||
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK));
|
||||
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QtGui>
|
||||
|
||||
|
@ -213,11 +214,9 @@ void fwPreferencesDialog::firmwareChanged()
|
|||
|
||||
void fwPreferencesDialog::writeValues()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
settings.setValue("cpu_id", ui->CPU_ID_LE->text());
|
||||
glob.cpu_id( ui->CPU_ID_LE->text() );
|
||||
current_firmware_variant = getFirmwareVariant();
|
||||
settings.setValue("firmware", current_firmware_variant.id);
|
||||
glob.pro[glob.profileId()].firmware( current_firmware_variant.id );
|
||||
}
|
||||
|
||||
void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
|
||||
|
@ -275,9 +274,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
|
|||
|
||||
void fwPreferencesDialog::initSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
|
||||
ui->CPU_ID_LE->setText(glob.cpu_id());
|
||||
FirmwareInfo * current_firmware = GetCurrentFirmware();
|
||||
|
||||
foreach(FirmwareInfo * firmware, firmwares) {
|
||||
|
@ -293,12 +290,10 @@ void fwPreferencesDialog::initSettings()
|
|||
|
||||
void fwPreferencesDialog::on_checkFWUpdates_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
if (settings.value("burnFirmware", true).toBool()) {
|
||||
if (glob.pro[glob.profileId()].burnFirmware()) {
|
||||
current_firmware_variant = variant;
|
||||
settings.setValue("firmware", variant.id);
|
||||
glob.pro[glob.profileId()].firmware( variant.id );
|
||||
}
|
||||
MainWindow * mw = (MainWindow *)this->parent();
|
||||
mw->checkForUpdates(true, variant.id);
|
||||
|
@ -307,14 +302,13 @@ void fwPreferencesDialog::on_checkFWUpdates_clicked()
|
|||
|
||||
void fwPreferencesDialog::on_fw_dnld_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
MainWindow * mw = (MainWindow *)this->parent();
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
writeValues();
|
||||
if (!variant.firmware->getUrl(variant.id).isNull()) {
|
||||
if (settings.value("burnFirmware", true).toBool()) {
|
||||
if (glob.pro[glob.profileId()].burnFirmware()) {
|
||||
current_firmware_variant = getFirmwareVariant();
|
||||
settings.setValue("firmware", current_firmware_variant.id);
|
||||
glob.pro[glob.profileId()].firmware( current_firmware_variant.id );
|
||||
}
|
||||
mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <QtGui>
|
||||
#include "appdata.h"
|
||||
#include "helpers.h"
|
||||
|
||||
QString getPhaseName(int val, char * phasename)
|
||||
|
@ -913,8 +914,7 @@ QString getCenterBeep(ModelData * g_model)
|
|||
|
||||
QString getTheme()
|
||||
{
|
||||
QSettings settings;
|
||||
int theme_set = settings.value("theme", 1).toInt();
|
||||
int theme_set = glob.theme();
|
||||
QString Theme;
|
||||
switch(theme_set) {
|
||||
case 0:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define lcd_widget_h
|
||||
|
||||
#include <QWidget>
|
||||
#include "appdata.h"
|
||||
|
||||
class lcdWidget : public QWidget {
|
||||
public:
|
||||
|
@ -58,11 +59,10 @@ class lcdWidget : public QWidget {
|
|||
QPixmap buffer(2*lcdWidth, 2*lcdHeight);
|
||||
QPainter p(&buffer);
|
||||
doPaint(p);
|
||||
QSettings settings;
|
||||
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
|
||||
bool toclipboard=glob.snapshot_to_clipboard();
|
||||
QApplication::clipboard()->setPixmap( buffer );
|
||||
if (!toclipboard) {
|
||||
QString Path=settings.value("snapshotPath", "").toString();
|
||||
QString Path=glob.snapshotpath();
|
||||
if (Path.isEmpty() || !QDir(Path).exists()) {
|
||||
Path=".";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "logsdialog.h"
|
||||
#include "appdata.h"
|
||||
#include "ui_logsdialog.h"
|
||||
#include "qcustomplot.h"
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
|
@ -38,8 +39,7 @@ logsDialog::logsDialog(QWidget *parent) :
|
|||
ui->customPlot->legend->setSelectedFont(legendFont);
|
||||
ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items
|
||||
ui->customPlot->legend->setVisible(false);
|
||||
QSettings settings;
|
||||
QString Path=settings.value("gePath", "").toString();
|
||||
QString Path=glob.gePath();
|
||||
if (Path.isEmpty() || !QFile(Path).exists()) {
|
||||
ui->mapsButton->hide();
|
||||
}
|
||||
|
@ -202,8 +202,7 @@ void logsDialog::on_mapsButton_clicked() {
|
|||
,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\
|
||||
,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F};
|
||||
|
||||
QSettings settings;
|
||||
QString gePath=settings.value("gePath", "").toString();
|
||||
QString gePath=glob.gePath();
|
||||
if (gePath.isEmpty() || !QFile(gePath).exists()) {
|
||||
ui->FieldsTW->setDisabled(false);
|
||||
ui->logTable->setDisabled(false);
|
||||
|
@ -585,10 +584,9 @@ void logsDialog::moveLegend()
|
|||
|
||||
void logsDialog::on_fileOpen_BT_clicked()
|
||||
{
|
||||
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"), glob.lastLogDir());
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastLogDir", fileName);
|
||||
glob.lastLogDir( fileName );
|
||||
ui->FileName_LE->setText(fileName);
|
||||
if (cvsFileParse()) {
|
||||
ui->FieldsTW->clear();
|
||||
|
|
|
@ -45,12 +45,12 @@
|
|||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QSettings>
|
||||
#include <QSplashScreen>
|
||||
#include <QThread>
|
||||
#include <iostream>
|
||||
#include "mainwindow.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "appdata.h"
|
||||
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
#include <windows.h>
|
||||
|
@ -98,19 +98,15 @@ int main(int argc, char *argv[])
|
|||
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
if (glob.firmware().isEmpty())
|
||||
glob.firmware(default_firmware_variant.id);
|
||||
QString tmp_id = glob.firmware();
|
||||
tmp_id.replace("open9x", "opentx");
|
||||
tmp_id.replace("x9da", "taranis");
|
||||
glob.firmware(tmp_id);
|
||||
if (glob.pro[glob.profileId()].firmware().isEmpty())
|
||||
glob.pro[glob.profileId()].firmware(default_firmware_variant.id);
|
||||
|
||||
QPixmap pixmap = QPixmap(glob.firmware().contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png");
|
||||
QPixmap pixmap = QPixmap(glob.pro[glob.profileId()].firmware().contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png");
|
||||
QSplashScreen *splash = new QSplashScreen(pixmap);
|
||||
|
||||
RegisterFirmwares();
|
||||
|
||||
current_firmware_variant = GetFirmwareVariant(glob.firmware());
|
||||
current_firmware_variant = GetFirmwareVariant(glob.pro[glob.profileId()].firmware());
|
||||
|
||||
MainWindow *mainWin = new MainWindow();
|
||||
if (glob.show_splash()) {
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "avroutputdialog.h"
|
||||
#include "comparedialog.h"
|
||||
#include "logsdialog.h"
|
||||
#include "preferencesdialog.h"
|
||||
#include "apppreferencesdialog.h"
|
||||
#include "fwpreferencesdialog.h"
|
||||
#include "flashinterface.h"
|
||||
|
@ -63,6 +62,7 @@
|
|||
#include "hexinterface.h"
|
||||
#include "warnings.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include
|
||||
|
||||
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
|
||||
|
@ -408,7 +408,7 @@ void MainWindow::reply1Accepted()
|
|||
int pos=rev.lastIndexOf("-r");
|
||||
if (pos>0) {
|
||||
currentFWrev=rev.mid(pos+2).toInt();
|
||||
if (settings.value("rename_firmware_files", false).toBool() && needRename) {
|
||||
if (glob.pro[glob.profileId()].rename_firmware_files() && needRename) {
|
||||
QFileInfo fi(downloadedFWFilename);
|
||||
QString path=fi.path()+QDir::separator ();
|
||||
path.append(fi.completeBaseName());
|
||||
|
@ -421,7 +421,7 @@ void MainWindow::reply1Accepted()
|
|||
downloadedFWFilename=path;
|
||||
}
|
||||
settings.setValue(downloadedFW, currentFWrev);
|
||||
if (settings.value("burnFirmware", true).toBool()) {
|
||||
if (glob.pro[glob.profileId()].burnFirmware()) {
|
||||
int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the transmitter now ?"), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::Yes) {
|
||||
writeFlash(downloadedFWFilename);
|
||||
|
@ -558,7 +558,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate);
|
||||
QString ext = url.mid(url.lastIndexOf("."));
|
||||
needRename=false;
|
||||
bool addversion=glob.rename_firmware_files();
|
||||
bool addversion=glob.pro[glob.profileId()].rename_firmware_files();
|
||||
QString fileName;
|
||||
if (addversion) {
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + fwToUpdate + newrev + ext);
|
||||
|
@ -711,24 +711,8 @@ void MainWindow::loadProfile() //TODO Load all variables - Also HW!
|
|||
int profnum=action->data().toInt();
|
||||
glob.profileId( profnum );
|
||||
|
||||
// Upgrade old firmware names
|
||||
QString firmware = glob.profile[profnum].firmware();
|
||||
firmware.replace("open9x","opentx");
|
||||
firmware.replace("x9da","taranis");
|
||||
glob.profile[profnum].firmware(firmware);
|
||||
|
||||
// Copy profile data from profile to main variables
|
||||
glob.Name( glob.profile[profnum].Name() );
|
||||
glob.default_channel_order( glob.profile[profnum].default_channel_order() );
|
||||
glob.default_mode( glob.profile[profnum].default_mode() );
|
||||
glob.burnFirmware( glob.profile[profnum].burnFirmware() );
|
||||
glob.rename_firmware_files( glob.profile[profnum].rename_firmware_files() );
|
||||
glob.sdPath( glob.profile[profnum].sdPath() );
|
||||
glob.SplashFileName( glob.profile[profnum].SplashFileName() );
|
||||
glob.firmware( glob.profile[profnum].firmware() );
|
||||
|
||||
// TODO Get rid of this global variable - glob.firmware is the real source
|
||||
current_firmware_variant = GetFirmwareVariant(glob.firmware());
|
||||
// TODO Get rid of this global variable - The profile.firmware is the real source
|
||||
current_firmware_variant = GetFirmwareVariant(glob.pro[glob.profileId()].firmware());
|
||||
|
||||
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
|
||||
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
|
||||
|
@ -1543,7 +1527,7 @@ void MainWindow::updateMenus()
|
|||
updateIconSizeActions();
|
||||
updateIconThemeActions();
|
||||
|
||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( glob.Name() ));
|
||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( glob.pro[glob.profileId()].Name() ));
|
||||
}
|
||||
|
||||
MdiChild *MainWindow::createMdiChild()
|
||||
|
@ -1909,20 +1893,25 @@ void MainWindow::setActiveSubWindow(QWidget *window)
|
|||
|
||||
void MainWindow::updateRecentFileActions()
|
||||
{
|
||||
int i,j, numRecentFiles;
|
||||
QSettings settings;
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
int i, numRecentFiles;
|
||||
|
||||
// Hide all document slots
|
||||
for ( i=0 ; i < glob.history_size(); i++)
|
||||
recentFileActs[i]->setVisible(false);
|
||||
|
||||
// Fill slots with content and unhide them
|
||||
QStringList files = glob.recentFileList();
|
||||
numRecentFiles = qMin(files.size(), glob.history_size());
|
||||
|
||||
for ( i = 0; i < numRecentFiles; ++i) {
|
||||
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
|
||||
for ( i = 0; i < numRecentFiles; i++) {
|
||||
QString text = strippedName(files[i]);
|
||||
if (!text.trimmed().isEmpty())
|
||||
{
|
||||
recentFileActs[i]->setText(text);
|
||||
recentFileActs[i]->setData(files[i]);
|
||||
recentFileActs[i]->setVisible(true);
|
||||
}
|
||||
for ( j = numRecentFiles; j < glob.history_size(); ++j)
|
||||
recentFileActs[j]->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateIconSizeActions()
|
||||
|
@ -1982,9 +1971,9 @@ void MainWindow::updateProfilesActions()
|
|||
{
|
||||
for (int i=0; i<MAX_PROFILES; i++)
|
||||
{
|
||||
if (!glob.profile[i].Name().isEmpty())
|
||||
if (!glob.pro[i].Name().isEmpty())
|
||||
{
|
||||
QString text = tr("&%1: %2").arg(i).arg(glob.profile[i].Name());
|
||||
QString text = tr("&%1: %2").arg(i).arg(glob.pro[i].Name());
|
||||
profileActs[i]->setText(text);
|
||||
profileActs[i]->setData(i);
|
||||
profileActs[i]->setVisible(true);
|
||||
|
@ -2000,14 +1989,14 @@ void MainWindow::updateProfilesActions()
|
|||
|
||||
void MainWindow::createProfile()
|
||||
{ int i;
|
||||
for (i=0; i<MAX_PROFILES && !glob.profile[i].Name().isEmpty(); i++)
|
||||
for (i=0; i<MAX_PROFILES && !glob.pro[i].Name().isEmpty(); i++)
|
||||
;
|
||||
if (i==MAX_PROFILES) //Failed to find free slot
|
||||
return;
|
||||
|
||||
// Create profile name and force a flush to file
|
||||
glob.profile[i].Name( QString("profile%1").arg(i));
|
||||
glob.profile[i].flush();
|
||||
glob.pro[i].Name( QString("profile%1").arg(i));
|
||||
glob.pro[i].flush();
|
||||
|
||||
updateMenus();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <QtGui>
|
||||
#include <QMainWindow>
|
||||
#include <QDateTime>
|
||||
#include "appdata.h"
|
||||
#include "downloaddialog.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "printdialog.h"
|
||||
#include "burndialog.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include <QFileInfo>
|
||||
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
|
@ -179,8 +180,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
|
|||
}
|
||||
if (isNew && !wizard) {
|
||||
int ret;
|
||||
QSettings settings;
|
||||
bool wizardEnable=settings.value("wizardEnable", true).toBool();
|
||||
bool wizardEnable=glob.wizardEnable();
|
||||
if (wizardEnable) {
|
||||
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::Yes) {
|
||||
|
@ -189,7 +189,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
|
|||
qSleep(500);
|
||||
ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::No) {
|
||||
settings.setValue("wizardEnable", false);
|
||||
glob.wizardEnable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,34 +346,33 @@ bool MdiChild::save()
|
|||
|
||||
bool MdiChild::saveAs(bool isNew)
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName;
|
||||
if (GetEepromInterface()->getBoard() == BOARD_SKY9X) {
|
||||
curFile.replace(".eepe", ".bin");
|
||||
QFileInfo fi(curFile);
|
||||
#ifdef __APPLE__
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName());
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName());
|
||||
#else
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(BIN_FILES_FILTER));
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
QFileInfo fi(curFile);
|
||||
#ifdef __APPLE__
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName());
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName());
|
||||
#else
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER));
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER));
|
||||
#endif
|
||||
}
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
if (fileName.contains("rev4a")) {
|
||||
settings.setValue("rev4asupport", 1);
|
||||
glob.rev4asupport( true );
|
||||
}
|
||||
if (fileName.contains("norev4a")) {
|
||||
settings.setValue("rev4asupport", 0);
|
||||
glob.rev4asupport( false );
|
||||
}
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
if (isNew)
|
||||
return saveFile(fileName);
|
||||
else
|
||||
|
@ -490,15 +489,14 @@ void MdiChild::setCurrentFile(const QString &fileName)
|
|||
fileChanged = false;
|
||||
setWindowModified(false);
|
||||
updateTitle();
|
||||
QSettings settings;
|
||||
int MaxRecentFiles =settings.value("history_size",10).toInt();
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
int MaxRecentFiles = glob.history_size();
|
||||
QStringList files = glob.recentFileList();
|
||||
files.removeAll(fileName);
|
||||
files.prepend(fileName);
|
||||
while (files.size() > MaxRecentFiles)
|
||||
files.removeLast();
|
||||
|
||||
settings.setValue("recentFileList", files);
|
||||
glob.recentFileList( files );
|
||||
}
|
||||
|
||||
QString MdiChild::strippedName(const QString &fullFileName)
|
||||
|
@ -508,9 +506,8 @@ QString MdiChild::strippedName(const QString &fullFileName)
|
|||
|
||||
void MdiChild::writeEeprom() // write to Tx
|
||||
{
|
||||
QSettings settings;
|
||||
bool backupEnable=settings.value("backupEnable", true).toBool();
|
||||
QString backupPath=settings.value("backupPath", "").toString();
|
||||
bool backupEnable=glob.backupEnable();
|
||||
QString backupPath=glob.backupPath();
|
||||
if (!backupPath.isEmpty()) {
|
||||
if (!QDir(backupPath).exists()) {
|
||||
if (backupEnable) {
|
||||
|
@ -521,13 +518,7 @@ void MdiChild::writeEeprom() // write to Tx
|
|||
} else {
|
||||
backupEnable=false;
|
||||
}
|
||||
int profileid=settings.value("profileId", 1).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profileid);
|
||||
settings.beginGroup(profile);
|
||||
QString stickCal=settings.value("StickPotCalib","").toString();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
QString stickCal=glob.pro[glob.profileId()].StickPotCalib();
|
||||
burnConfigDialog bcd;
|
||||
QString tempDir = QDir::tempPath();
|
||||
QString tempFile = tempDir + "/temp.bin";
|
||||
|
@ -690,8 +681,7 @@ void MdiChild::setEEpromAvail(int eavail)
|
|||
|
||||
bool MdiChild::loadBackup()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastDir(),tr(EEPROM_FILES_FILTER));
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
QFile file(fileName);
|
||||
|
|
|
@ -1,827 +0,0 @@
|
|||
#include "preferencesdialog.h"
|
||||
#include "ui_preferencesdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "splashlibrary.h"
|
||||
#include "helpers.h"
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#include "joystickdialog.h"
|
||||
#endif
|
||||
#include <QDesktopServices>
|
||||
#include <QtGui>
|
||||
|
||||
preferencesDialog::preferencesDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::preferencesDialog),
|
||||
updateLock(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(CompanionIcon("preferences.png"));
|
||||
ui->splashLibraryButton->setIcon(CompanionIcon("library.png"));
|
||||
ui->clearImageButton->setIcon(CompanionIcon("clear.png"));
|
||||
|
||||
QCheckBox * OptionCheckBox[]= {
|
||||
ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7,
|
||||
ui->optionCheckBox_8, ui->optionCheckBox_9, ui->optionCheckBox_10, ui->optionCheckBox_11, ui->optionCheckBox_12, ui->optionCheckBox_13, ui->optionCheckBox_14,
|
||||
ui->optionCheckBox_15,ui->optionCheckBox_16, ui->optionCheckBox_17, ui->optionCheckBox_18, ui->optionCheckBox_19, ui->optionCheckBox_20, ui->optionCheckBox_21,
|
||||
ui->optionCheckBox_22, ui->optionCheckBox_23, ui->optionCheckBox_24, ui->optionCheckBox_25, ui->optionCheckBox_26, ui->optionCheckBox_27, ui->optionCheckBox_28,
|
||||
ui->optionCheckBox_29, ui->optionCheckBox_30, ui->optionCheckBox_31, ui->optionCheckBox_32, ui->optionCheckBox_33, ui->optionCheckBox_34, ui->optionCheckBox_35,
|
||||
ui->optionCheckBox_36, ui->optionCheckBox_37, ui->optionCheckBox_38, ui->optionCheckBox_39, ui->optionCheckBox_40, ui->optionCheckBox_41, ui->optionCheckBox_42,
|
||||
NULL };
|
||||
|
||||
voice=NULL;
|
||||
|
||||
connect(ui->langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged()));
|
||||
connect(ui->voiceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged()));
|
||||
|
||||
for (int i=0; OptionCheckBox[i]; i++) {
|
||||
optionsCheckBoxes.push_back(OptionCheckBox[i]);
|
||||
connect(OptionCheckBox[i], SIGNAL(toggled(bool)), this, SLOT(firmwareOptionChanged(bool)));
|
||||
}
|
||||
|
||||
initSettings();
|
||||
connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged()));
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
|
||||
#ifndef JOYSTICKS
|
||||
ui->joystickCB->hide();
|
||||
ui->joystickCB->setDisabled(true);
|
||||
ui->joystickcalButton->hide();
|
||||
ui->joystickChkB->hide();
|
||||
ui->label_11->hide();
|
||||
#endif
|
||||
resize(0,0);
|
||||
}
|
||||
|
||||
|
||||
preferencesDialog::~preferencesDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void preferencesDialog::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);
|
||||
ui->ge_label->show();
|
||||
ui->ge_lineedit->show();
|
||||
ui->ge_pathButton->show();
|
||||
} else {
|
||||
ui->voiceLabel->hide();
|
||||
ui->voiceCombo->hide();
|
||||
ui->voice_dnld->hide();
|
||||
ui->sdPathButton->hide();
|
||||
ui->sdPath->hide();
|
||||
ui->sdPathLabel->hide();
|
||||
ui->ge_label->hide();
|
||||
ui->ge_lineedit->hide();
|
||||
ui->ge_pathButton->hide();
|
||||
}
|
||||
populateFirmwareOptions(firmware);
|
||||
int width=firmware->eepromInterface->getCapability(LCDWidth);
|
||||
ui->imageLabel->setFixedWidth(width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
firmwareChanged();
|
||||
}
|
||||
|
||||
FirmwareVariant preferencesDialog::getFirmwareVariant()
|
||||
{
|
||||
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
|
||||
bool voice=false;
|
||||
foreach(FirmwareInfo * firmware, firmwares) {
|
||||
if (firmware->id == selected_firmware) {
|
||||
QString id = firmware->id;
|
||||
foreach(QCheckBox *cb, optionsCheckBoxes) {
|
||||
if (cb->isChecked()) {
|
||||
if (cb->text()=="voice" && cb->isChecked())
|
||||
voice=true;
|
||||
id += QString("-") + cb->text();
|
||||
}
|
||||
}
|
||||
if (! firmware->eepromInterface->getCapability(MultiLangVoice)) {
|
||||
if (ui->voiceCombo->count() && (voice || firmware->voice))
|
||||
id += QString("-tts") + ui->voiceCombo->currentText();
|
||||
}
|
||||
if (ui->langCombo->count())
|
||||
id += QString("-") + ui->langCombo->currentText();
|
||||
|
||||
return GetFirmwareVariant(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Should never occur...
|
||||
return default_firmware_variant;
|
||||
}
|
||||
|
||||
void preferencesDialog::firmwareLangChanged()
|
||||
{
|
||||
firmwareChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::firmwareOptionChanged(bool state)
|
||||
{
|
||||
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
|
||||
FirmwareInfo * firmware=NULL;
|
||||
if (cb && state) {
|
||||
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
|
||||
foreach(firmware, firmwares) {
|
||||
if (firmware->id == selected_firmware) {
|
||||
foreach(QList<Option> opts, firmware->opts) {
|
||||
foreach(Option opt, opts) {
|
||||
if (cb->text() == opt.name) {
|
||||
foreach(Option other, opts) {
|
||||
if (other.name != opt.name) {
|
||||
foreach(QCheckBox *ocb, optionsCheckBoxes) {
|
||||
if (ocb->text() == other.name)
|
||||
ocb->setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return firmwareChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
return firmwareChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::firmwareChanged()
|
||||
{
|
||||
if (updateLock)
|
||||
return;
|
||||
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
QString stamp;
|
||||
stamp.append(variant.firmware->stamp);
|
||||
ui->fw_dnld->setEnabled(!variant.firmware->getUrl(variant.id).isNull());
|
||||
QString url=variant.firmware->getUrl(variant.id);
|
||||
// B-Plan
|
||||
if (false) {
|
||||
ui->CPU_ID_LE->show();
|
||||
ui->CPU_ID_LABEL->show();
|
||||
} else {
|
||||
ui->CPU_ID_LE->hide();
|
||||
ui->CPU_ID_LABEL->hide();
|
||||
}
|
||||
QSettings settings;
|
||||
settings.beginGroup("FwRevisions");
|
||||
int fwrev = settings.value(variant.id, -1).toInt();
|
||||
settings.endGroup();
|
||||
if (fwrev != -1) {
|
||||
ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev));
|
||||
if (!stamp.isEmpty()) {
|
||||
ui->checkFWUpdates->show();
|
||||
} else {
|
||||
ui->checkFWUpdates->hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ui->fw_dnld->isEnabled()) {
|
||||
ui->FwInfo->setText(tr("The selected firmware has never been downloaded by Companion."));
|
||||
ui->checkFWUpdates->hide();
|
||||
}
|
||||
else {
|
||||
ui->FwInfo->setText(tr("The selected firmware cannot be downloaded by Companion."));
|
||||
ui->checkFWUpdates->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::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("startup_check_companion", ui->startupCheck_companion9x->isChecked());
|
||||
settings.setValue("startup_check_fw", ui->startupCheck_fw->isChecked());
|
||||
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
|
||||
settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked());
|
||||
settings.setValue("show_splash", ui->showSplash->isChecked());
|
||||
settings.setValue("simuSW", ui->simuSW->isChecked());
|
||||
settings.setValue("history_size", ui->historySize->value());
|
||||
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("backLight", ui->backLightColor->currentIndex());
|
||||
settings.setValue("libraryPath", ui->libraryPath->text());
|
||||
settings.setValue("sdPath", ui->sdPath->text());
|
||||
settings.setValue("gePath", ui->ge_lineedit->text());
|
||||
settings.setValue("embedded_splashes", ui->splashincludeCB->currentIndex());
|
||||
if (!ui->SplashFileName->text().isEmpty()) {
|
||||
QImage Image = ui->imageLabel->pixmap()->toImage();
|
||||
settings.setValue("SplashImage", image2qstring(Image));
|
||||
settings.setValue("SplashFileName", ui->SplashFileName->text());
|
||||
}
|
||||
else {
|
||||
settings.setValue("SplashFileName", "");
|
||||
settings.setValue("SplashImage", "");
|
||||
}
|
||||
|
||||
if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) {
|
||||
settings.setValue("js_support", ui->joystickChkB ->isChecked());
|
||||
settings.setValue("js_ctrl", ui->joystickCB ->currentIndex());
|
||||
}
|
||||
else {
|
||||
settings.remove("js_support");
|
||||
settings.remove("js_ctrl");
|
||||
}
|
||||
settings.setValue("backupEnable", ui->backupEnable->isChecked());
|
||||
MainWindow * mw = (MainWindow *)this->parent();
|
||||
mw->unloadProfile();
|
||||
}
|
||||
|
||||
void preferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
|
||||
{
|
||||
const FirmwareInfo * parent = firmware->parent ? firmware->parent : firmware;
|
||||
|
||||
updateLock = true;
|
||||
|
||||
ui->langCombo->clear();
|
||||
foreach(const char *lang, parent->languages) {
|
||||
ui->langCombo->addItem(lang);
|
||||
if (current_firmware_variant.id.endsWith(lang))
|
||||
ui->langCombo->setCurrentIndex(ui->langCombo->count() - 1);
|
||||
}
|
||||
ui->voiceCombo->clear();
|
||||
foreach(const char *lang, parent->ttslanguages) {
|
||||
ui->voiceCombo->addItem(lang);
|
||||
if (current_firmware_variant.id.contains(QString("-tts%1").arg(lang)))
|
||||
ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1);
|
||||
}
|
||||
|
||||
if (ui->langCombo->count()) {
|
||||
ui->langCombo->show();
|
||||
ui->langLabel->show();
|
||||
}
|
||||
else {
|
||||
ui->langCombo->hide();
|
||||
ui->langLabel->hide();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
foreach(QList<Option> opts, parent->opts) {
|
||||
foreach(Option opt, opts) {
|
||||
if (index >= optionsCheckBoxes.size()) {
|
||||
qDebug() << "This firmware needs more options checkboxes!";
|
||||
}
|
||||
else {
|
||||
QCheckBox *cb = optionsCheckBoxes.at(index++);
|
||||
if (cb) {
|
||||
cb->show();
|
||||
cb->setText(opt.name);
|
||||
cb->setToolTip(opt.tooltip);
|
||||
cb->setCheckState(current_firmware_variant.id.contains(opt.name) ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
if (opt.name==QString("voice")) {
|
||||
voice=cb;
|
||||
ui->voiceLabel->show();
|
||||
ui->voiceCombo->show();
|
||||
ui->voice_dnld->show();
|
||||
ui->sdPathButton->show();
|
||||
ui->sdPath->show();
|
||||
ui->sdPathLabel->show();
|
||||
ui->ge_label->show();
|
||||
ui->ge_lineedit->show();
|
||||
ui->ge_pathButton->show();
|
||||
if (current_firmware_variant.id.contains(opt.name) ||firmware->voice) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; index<optionsCheckBoxes.size(); index++) {
|
||||
QCheckBox *cb = optionsCheckBoxes.at(index);
|
||||
cb->hide();
|
||||
cb->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
updateLock = false;
|
||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||
}
|
||||
|
||||
void preferencesDialog::initSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool());
|
||||
if (ui->snapshotClipboardCKB->isChecked()) {
|
||||
ui->snapshotPath->setDisabled(true);
|
||||
ui->snapshotPathButton->setDisabled(true);
|
||||
} else {
|
||||
QString Path=settings.value("snapshotPath", "").toString();
|
||||
if (QDir(Path).exists()) {
|
||||
ui->snapshotPath->setText(Path);
|
||||
ui->snapshotPath->setReadOnly(true);
|
||||
ui->snapshotPathButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt());
|
||||
ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt());
|
||||
ui->startupCheck_companion9x->setChecked(settings.value("startup_check_companion", true).toBool());
|
||||
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool());
|
||||
ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool());
|
||||
ui->showSplash->setChecked(settings.value("show_splash", true).toBool());
|
||||
ui->historySize->setValue(settings.value("history_size", 10).toInt());
|
||||
ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt());
|
||||
ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool());
|
||||
ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool());
|
||||
ui->simuSW->setChecked(settings.value("simuSW", false).toBool());
|
||||
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
|
||||
QString Path=settings.value("libraryPath", "").toString();
|
||||
if (QDir(Path).exists()) {
|
||||
ui->libraryPath->setText(Path);
|
||||
}
|
||||
Path=settings.value("sdPath", "").toString();
|
||||
if (QDir(Path).exists()) {
|
||||
ui->sdPath->setText(Path);
|
||||
}
|
||||
Path=settings.value("gePath", "").toString();
|
||||
if (QFile(Path).exists()) {
|
||||
ui->ge_lineedit->setText(Path);
|
||||
}
|
||||
Path=settings.value("backupPath", "").toString();
|
||||
if (!Path.isEmpty()) {
|
||||
if (QDir(Path).exists()) {
|
||||
ui->backupPath->setText(Path);
|
||||
ui->backupEnable->setEnabled(true);
|
||||
ui->backupEnable->setChecked(settings.value("backupEnable", true).toBool());
|
||||
} else {
|
||||
ui->backupEnable->setDisabled(true);
|
||||
}
|
||||
} else {
|
||||
ui->backupEnable->setDisabled(true);
|
||||
}
|
||||
ui->splashincludeCB->setCurrentIndex(settings.value("embedded_splashes", 0).toInt());
|
||||
FirmwareInfo * current_firmware = GetCurrentFirmware();
|
||||
|
||||
// qDebug() << current_firmware->id;
|
||||
|
||||
foreach(FirmwareInfo * firmware, firmwares) {
|
||||
ui->downloadVerCB->addItem(firmware->name, firmware->id);
|
||||
if (current_firmware == firmware) {
|
||||
ui->downloadVerCB->setCurrentIndex(ui->downloadVerCB->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
baseFirmwareChanged();
|
||||
ui->ProfSlot_SB->setValue(settings.value("profileId", 1).toInt());
|
||||
on_ProfSlot_SB_valueChanged();
|
||||
QString ImageStr = settings.value("SplashImage", "").toString();
|
||||
if (!ImageStr.isEmpty()) {
|
||||
QImage Image = qstring2image(ImageStr);
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(QImage::Format_Mono)));
|
||||
ui->InvertPixels->setEnabled(true);
|
||||
QString fileName=settings.value("SplashFileName","").toString();
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (!file.exists()) {
|
||||
ui->SplashFileName->setText(tr("Image stored in settings"));
|
||||
}
|
||||
else {
|
||||
ui->SplashFileName->setText(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef JOYSTICKS
|
||||
ui->joystickChkB->setChecked(settings.value("js_support", false).toBool());
|
||||
if (ui->joystickChkB->isChecked()) {
|
||||
QStringList joystickNames;
|
||||
joystickNames << tr("No joysticks found");
|
||||
joystick = new Joystick(0,false,0,0);
|
||||
ui->joystickcalButton->setDisabled(true);
|
||||
ui->joystickCB->setDisabled(true);
|
||||
|
||||
if ( joystick ) {
|
||||
if ( joystick->joystickNames.count() > 0 ) {
|
||||
joystickNames = joystick->joystickNames;
|
||||
ui->joystickCB->setEnabled(true);
|
||||
ui->joystickcalButton->setEnabled(true);
|
||||
}
|
||||
joystick->close();
|
||||
}
|
||||
ui->joystickCB->clear();
|
||||
ui->joystickCB->insertItems(0, joystickNames);
|
||||
ui->joystickCB->setCurrentIndex(settings.value("js_ctrl", 0).toInt());
|
||||
}
|
||||
else {
|
||||
ui->joystickCB->clear();
|
||||
ui->joystickCB->setDisabled(true);
|
||||
ui->joystickcalButton->setDisabled(true);
|
||||
}
|
||||
#endif
|
||||
firmwareChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::on_fw_dnld_clicked()
|
||||
{
|
||||
MainWindow * mw = (MainWindow *)this->parent();
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
writeValues();
|
||||
if (!variant.firmware->getUrl(variant.id).isNull()) {
|
||||
if (ui->burnFirmware->isChecked()) {
|
||||
QSettings settings;
|
||||
current_firmware_variant = getFirmwareVariant();
|
||||
settings.setValue("firmware", current_firmware_variant.id);
|
||||
}
|
||||
mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id);
|
||||
}
|
||||
firmwareChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::on_voice_dnld_clicked()
|
||||
{
|
||||
ui->ProfSave_PB->setEnabled(true);
|
||||
QString url="http://fw.opentx.it/voices/";
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
url.append(QString("%1/%2/").arg(variant.firmware->id).arg(ui->voiceCombo->currentText()));
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void preferencesDialog::on_libraryPathButton_clicked()
|
||||
{
|
||||
ui->ProfSave_PB->setEnabled(true);
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString());
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("libraryPath", fileName);
|
||||
ui->libraryPath->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_snapshotPathButton_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString());
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("snapshotpath", fileName);
|
||||
settings.setValue("snapshot_to_clipboard", false);
|
||||
ui->snapshotPath->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_snapshotClipboardCKB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
if (ui->snapshotClipboardCKB->isChecked()) {
|
||||
ui->snapshotPath->setDisabled(true);
|
||||
ui->snapshotPathButton->setDisabled(true);
|
||||
settings.setValue("snapshot_to_clipboard", true);
|
||||
} else {
|
||||
ui->snapshotPath->setEnabled(true);
|
||||
ui->snapshotPath->setReadOnly(true);
|
||||
ui->snapshotPathButton->setEnabled(true);
|
||||
settings.setValue("snapshot_to_clipboard", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void preferencesDialog::on_backupPathButton_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString());
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("backupPath", fileName);
|
||||
ui->backupPath->setText(fileName);
|
||||
}
|
||||
ui->backupEnable->setEnabled(true);
|
||||
}
|
||||
|
||||
void preferencesDialog::on_ge_pathButton_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text());
|
||||
if (!fileName.isEmpty()) {
|
||||
ui->ge_lineedit->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_splashLibraryButton_clicked()
|
||||
{
|
||||
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;
|
||||
}
|
||||
ui->SplashFileName->setText(fileName);
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(128, 64).convertToFormat(QImage::Format_Mono)));
|
||||
ui->InvertPixels->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::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);
|
||||
}
|
||||
ui->ProfSave_PB->setEnabled(true);
|
||||
}
|
||||
|
||||
void preferencesDialog::on_ProfSlot_SB_valueChanged()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
|
||||
settings.beginGroup(profile);
|
||||
QString name=settings.value("Name","").toString();
|
||||
ui->ProfName_LE->setText(name);
|
||||
/* if (!(name.isEmpty())) {
|
||||
QString firmwarename=settings.value("firmware", default_firmware_id).toString();
|
||||
FirmwareInfo * fw = getFirmware(firmwarename);
|
||||
int i=0;
|
||||
foreach(FirmwareInfo * firmware, firmwares) {
|
||||
if (fw == firmware) {
|
||||
qDebug() << fw->id;
|
||||
qDebug() << firmware->id;
|
||||
qDebug() << i;
|
||||
ui->downloadVerCB->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
baseFirmwareChanged();
|
||||
populateFirmwareOptions(fw);
|
||||
}*/
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void preferencesDialog::on_ProfSave_PB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
|
||||
QString name=ui->ProfName_LE->text();
|
||||
if (name.isEmpty()) {
|
||||
int ret = QMessageBox::question(this, "Companion",
|
||||
tr("Profile name is empty, profile slot %1 will be deleted.<br>Are you sure ?").arg(ui->ProfSlot_SB->value()) ,
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret==QMessageBox::Yes) {
|
||||
settings.remove(profile);
|
||||
} else {
|
||||
settings.beginGroup(profile);
|
||||
ui->ProfName_LE->setText(settings.value("Name","").toString());
|
||||
}
|
||||
} else {
|
||||
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.setValue("gePath", ui->ge_lineedit->text());
|
||||
if (ui->imageLabel->pixmap()) {
|
||||
QImage Image = ui->imageLabel->pixmap()->toImage();
|
||||
settings.setValue("SplashImage", image2qstring(Image));
|
||||
} else {
|
||||
settings.remove("SplashImage");
|
||||
}
|
||||
current_firmware_variant = getFirmwareVariant();
|
||||
settings.setValue("firmware", current_firmware_variant.id);
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_export_PB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
|
||||
QString name=ui->ProfName_LE->text();
|
||||
if (!name.isEmpty()) {
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export profile As"), settings.value("lastDir").toString() + "/" +name+".ini" , "*.ini");
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QSettings exportfile(fileName, QSettings::IniFormat);
|
||||
settings.beginGroup("Profiles");
|
||||
settings.beginGroup(profile);
|
||||
QStringList keys = settings.childKeys();
|
||||
foreach (QString key, keys) {
|
||||
exportfile.setValue(key,settings.value(key));
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void preferencesDialog::on_import_PB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
|
||||
QString name=ui->ProfName_LE->text();
|
||||
if (!name.isEmpty()) {
|
||||
int ret = QMessageBox::question(this, "Companion",
|
||||
tr("Profile slot is not empty, profile slot %1 will we overwritten.<br>Are you sure ?").arg(ui->ProfSlot_SB->value()) ,
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret==QMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Profile to import"), settings.value("lastDir").toString(), "*.ini");
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QSettings importfile(fileName, QSettings::IniFormat);
|
||||
settings.beginGroup("Profiles");
|
||||
settings.beginGroup(profile);
|
||||
QStringList keys = importfile.childKeys();
|
||||
foreach (QString key, keys) {
|
||||
settings.setValue(key,importfile.value(key));
|
||||
}
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
on_ProfSlot_SB_valueChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::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());
|
||||
QImage image(fileName);
|
||||
if (image.isNull()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
|
||||
return;
|
||||
}
|
||||
ui->SplashFileName->setText(fileName);
|
||||
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;
|
||||
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));
|
||||
}
|
||||
}
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
||||
} else {
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono)));
|
||||
}
|
||||
ui->InvertPixels->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_InvertPixels_clicked() {
|
||||
QImage image = ui->imageLabel->pixmap()->toImage();
|
||||
image.invertPixels();
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
void preferencesDialog::on_clearImageButton_clicked() {
|
||||
ui->imageLabel->clear();
|
||||
ui->SplashFileName->clear();
|
||||
}
|
||||
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
|
||||
void preferencesDialog::on_joystickChkB_clicked() {
|
||||
if (ui->joystickChkB->isChecked()) {
|
||||
QStringList joystickNames;
|
||||
joystickNames << tr("No joysticks found");
|
||||
joystick = new Joystick(0,false,0,0);
|
||||
ui->joystickcalButton->setDisabled(true);
|
||||
ui->joystickCB->setDisabled(true);
|
||||
|
||||
if ( joystick ) {
|
||||
if ( joystick->joystickNames.count() > 0 ) {
|
||||
joystickNames = joystick->joystickNames;
|
||||
ui->joystickCB->setEnabled(true);
|
||||
ui->joystickcalButton->setEnabled(true);
|
||||
}
|
||||
joystick->close();
|
||||
}
|
||||
ui->joystickCB->clear();
|
||||
ui->joystickCB->insertItems(0, joystickNames);
|
||||
}
|
||||
else {
|
||||
ui->joystickCB->clear();
|
||||
ui->joystickCB->setDisabled(true);
|
||||
ui->joystickcalButton->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void preferencesDialog::on_joystickcalButton_clicked() {
|
||||
//QSettings settings;
|
||||
//settings.setValue("joystick-name",ui->joystickCB->currentText());
|
||||
joystickDialog * jd=new joystickDialog(this, ui->joystickCB->currentIndex());
|
||||
jd->exec();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void preferencesDialog::on_checkFWUpdates_clicked()
|
||||
{
|
||||
FirmwareVariant variant = getFirmwareVariant();
|
||||
if (ui->burnFirmware->isChecked()) {
|
||||
QSettings settings;
|
||||
current_firmware_variant = variant;
|
||||
settings.setValue("firmware", variant.id);
|
||||
}
|
||||
MainWindow * mw = (MainWindow *)this->parent();
|
||||
mw->checkForUpdates(true, variant.id);
|
||||
firmwareChanged();
|
||||
}
|
||||
|
||||
void preferencesDialog::shrink()
|
||||
{
|
||||
resize(0,0);
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
#ifndef PREFERENCESDIALOG_H
|
||||
#define PREFERENCESDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class preferencesDialog;
|
||||
}
|
||||
|
||||
class Joystick;
|
||||
|
||||
class preferencesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit preferencesDialog(QWidget *parent = 0);
|
||||
~preferencesDialog();
|
||||
Joystick *joystick;
|
||||
|
||||
private:
|
||||
Ui::preferencesDialog *ui;
|
||||
QList<QCheckBox *> optionsCheckBoxes;
|
||||
bool updateLock;
|
||||
|
||||
void populateLocale();
|
||||
void populateFirmwareOptions(const FirmwareInfo *);
|
||||
FirmwareVariant getFirmwareVariant();
|
||||
void initSettings();
|
||||
QCheckBox * voice;
|
||||
|
||||
|
||||
private slots:
|
||||
void shrink();
|
||||
void writeValues();
|
||||
void firmwareLangChanged();
|
||||
void baseFirmwareChanged();
|
||||
void firmwareOptionChanged(bool state);
|
||||
void firmwareChanged();
|
||||
void on_fw_dnld_clicked();
|
||||
void on_voice_dnld_clicked();
|
||||
void on_SplashSelect_clicked();
|
||||
void on_InvertPixels_clicked();
|
||||
void on_clearImageButton_clicked();
|
||||
void on_libraryPathButton_clicked();
|
||||
void on_snapshotPathButton_clicked();
|
||||
void on_snapshotClipboardCKB_clicked();
|
||||
void on_backupPathButton_clicked();
|
||||
void on_ge_pathButton_clicked();
|
||||
void on_sdPathButton_clicked();
|
||||
void on_splashLibraryButton_clicked();
|
||||
void on_checkFWUpdates_clicked();
|
||||
void on_ProfSlot_SB_valueChanged();
|
||||
void on_ProfSave_PB_clicked();
|
||||
void on_export_PB_clicked();
|
||||
void on_import_PB_clicked();
|
||||
#ifdef JOYSTICKS
|
||||
void on_joystickChkB_clicked();
|
||||
void on_joystickcalButton_clicked();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // PREFERENCESDIALOG_H
|
|
@ -3,6 +3,7 @@
|
|||
#include <iostream>
|
||||
#include "helpers.h"
|
||||
#include "simulatorinterface.h"
|
||||
#include "appdata.h"
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#endif
|
||||
|
@ -33,8 +34,8 @@ simulatorDialog::simulatorDialog(QWidget *parent) :
|
|||
beepShow = 0;
|
||||
|
||||
QSettings settings;
|
||||
backLight = settings.value("backLight",0).toInt();
|
||||
bool simuSW=settings.value("simuSW",false).toBool();
|
||||
backLight = glob.backLight();
|
||||
bool simuSW=glob.simuSW();
|
||||
switch (backLight) {
|
||||
case 1:
|
||||
ui->lcd->setBackgroundColor(166,247,159);
|
||||
|
@ -75,8 +76,8 @@ simulatorDialog::simulatorDialog(QWidget *parent) :
|
|||
}
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
bool js_enable=settings.value("js_support",false).toBool();
|
||||
int js_ctrl=settings.value("js_ctrl",-1).toInt();
|
||||
bool js_enable=glob.js_support();
|
||||
int js_ctrl=glob.js_ctrl();
|
||||
if (js_enable) {
|
||||
settings.beginGroup("JsCalibration");
|
||||
int count=0;
|
||||
|
@ -211,8 +212,7 @@ void simulatorDialog::setupTimer()
|
|||
void simulatorDialog::onButtonPressed(int value)
|
||||
{
|
||||
if (value==Qt::Key_Print) {
|
||||
QSettings settings;
|
||||
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
|
||||
bool toclipboard=glob.snapshot_to_clipboard();
|
||||
QString fileName ="";
|
||||
if (!toclipboard) {
|
||||
fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "splashlibrary.h"
|
||||
#include "ui_splashlibrary.h"
|
||||
|
||||
#include "appdata.h"
|
||||
#include <QtGui>
|
||||
#include "helpers.h"
|
||||
//#include "splashlabel.h"
|
||||
|
@ -61,9 +61,8 @@ void splashLibrary::setupPage(int page) {
|
|||
}
|
||||
|
||||
void splashLibrary::getFileList() {
|
||||
QSettings settings;
|
||||
imageList.clear();
|
||||
if (settings.value("embedded_splashes", 0).toInt() == 0) {
|
||||
if (glob.embedded_splashes() == 0) {
|
||||
QDir myRes(":/images/library");
|
||||
QStringList tmp = myRes.entryList();
|
||||
for (int i = 0; i < tmp.size(); i++) {
|
||||
|
@ -71,7 +70,7 @@ void splashLibrary::getFileList() {
|
|||
imageList.append(":/images/library/" + fileInfo.fileName());
|
||||
}
|
||||
}
|
||||
QString libraryPath = settings.value("libraryPath", "").toString();
|
||||
QString libraryPath = glob.libraryPath();
|
||||
if (!libraryPath.isEmpty()) {
|
||||
if (QDir(libraryPath).exists()) {
|
||||
QStringList supportedImageFormats;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <iostream>
|
||||
#include "helpers.h"
|
||||
#include "simulatorinterface.h"
|
||||
#include "appdata.h"
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#endif
|
||||
|
@ -179,8 +180,7 @@ void xsimulatorDialog::setupTimer()
|
|||
void xsimulatorDialog::onButtonPressed(int value)
|
||||
{
|
||||
if (value==Qt::Key_Print) {
|
||||
QSettings settings;
|
||||
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
|
||||
bool toclipboard=glob.snapshot_to_clipboard();
|
||||
QString fileName ="";
|
||||
if (!toclipboard) {
|
||||
fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue