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

Changed every single QSetting in Companion.

Next step: Function renaming
This commit is contained in:
Kjell Kernen 2014-02-18 23:48:57 +01:00
parent f617ae1362
commit da68c593cf
28 changed files with 1048 additions and 924 deletions

File diff suppressed because it is too large Load diff

View file

@ -36,87 +36,87 @@ appPreferencesDialog::~appPreferencesDialog()
void appPreferencesDialog::writeValues() void appPreferencesDialog::writeValues()
{ {
glob.startup_check_companion(ui->startupCheck_companion9x->isChecked()); g.startup_check_companion(ui->startupCheck_companion9x->isChecked());
glob.startup_check_fw(ui->startupCheck_fw->isChecked()); g.startup_check_fw(ui->startupCheck_fw->isChecked());
glob.wizardEnable(ui->wizardEnable_ChkB->isChecked()); g.wizardEnable(ui->wizardEnable_ChkB->isChecked());
glob.show_splash(ui->showSplash->isChecked()); g.show_splash(ui->showSplash->isChecked());
glob.simuSW(ui->simuSW->isChecked()); g.simuSW(ui->simuSW->isChecked());
glob.history_size(ui->historySize->value()); g.history_size(ui->historySize->value());
glob.backLight(ui->backLightColor->currentIndex()); g.backLight(ui->backLightColor->currentIndex());
glob.libraryPath(ui->libraryPath->text()); g.libraryPath(ui->libraryPath->text());
glob.gePath(ui->ge_lineedit->text()); g.gePath(ui->ge_lineedit->text());
glob.embedded_splashes(ui->splashincludeCB->currentIndex()); g.embedded_splashes(ui->splashincludeCB->currentIndex());
glob.backupEnable(ui->backupEnable->isChecked()); g.backupEnable(ui->backupEnable->isChecked());
if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) { if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) {
glob.js_support(ui->joystickChkB ->isChecked()); g.js_support(ui->joystickChkB ->isChecked());
glob.js_ctrl(ui->joystickCB ->currentIndex()); g.js_ctrl(ui->joystickCB ->currentIndex());
} }
else { else {
glob.js_support(false); g.js_support(false);
glob.js_ctrl(0); g.js_ctrl(0);
} }
glob.profileId(ui->profileIndexLE->text().toInt()); g.id(ui->profileIndexLE->text().toInt());
glob.pro[glob.profileId()].default_channel_order(ui->channelorderCB->currentIndex()); g.profile[g.id()].default_channel_order(ui->channelorderCB->currentIndex());
glob.pro[glob.profileId()].default_mode(ui->stickmodeCB->currentIndex()); g.profile[g.id()].default_mode(ui->stickmodeCB->currentIndex());
glob.pro[glob.profileId()].rename_firmware_files(ui->renameFirmware->isChecked()); g.profile[g.id()].rename_firmware_files(ui->renameFirmware->isChecked());
glob.pro[glob.profileId()].burnFirmware(ui->burnFirmware->isChecked()); g.profile[g.id()].burnFirmware(ui->burnFirmware->isChecked());
glob.pro[glob.profileId()].Name(ui->profileNameLE->text()); g.profile[g.id()].Name(ui->profileNameLE->text());
glob.pro[glob.profileId()].sdPath(ui->sdPath->text()); g.profile[g.id()].sdPath(ui->sdPath->text());
glob.pro[glob.profileId()].SplashFileName(ui->SplashFileName->text()); g.profile[g.id()].SplashFileName(ui->SplashFileName->text());
glob.pro[glob.profileId()].firmware(ui->firmwareLE->text()); g.profile[g.id()].firmware(ui->firmwareLE->text());
saveProfile(); saveProfile();
} }
void appPreferencesDialog::on_snapshotPathButton_clicked() void appPreferencesDialog::on_snapshotPathButton_clicked()
{ {
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), glob.snapshotpath()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), g.snapshotpath());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.snapshotpath(fileName); g.snapshotpath(fileName);
glob.snapshot_to_clipboard(false); g.snapshot_to_clipboard(false);
ui->snapshotPath->setText(fileName); ui->snapshotPath->setText(fileName);
} }
} }
void appPreferencesDialog::initSettings() void appPreferencesDialog::initSettings()
{ {
ui->snapshotClipboardCKB->setChecked(glob.snapshot_to_clipboard()); ui->snapshotClipboardCKB->setChecked(g.snapshot_to_clipboard());
ui->burnFirmware->setChecked(glob.pro[glob.profileId()].burnFirmware()); ui->burnFirmware->setChecked(g.profile[g.id()].burnFirmware());
ui->snapshotPath->setText(glob.snapshotpath()); ui->snapshotPath->setText(g.snapshotpath());
ui->snapshotPath->setReadOnly(true); ui->snapshotPath->setReadOnly(true);
if (ui->snapshotClipboardCKB->isChecked()) if (ui->snapshotClipboardCKB->isChecked())
{ {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true); ui->snapshotPathButton->setDisabled(true);
} }
ui->startupCheck_companion9x->setChecked(glob.startup_check_companion()); ui->startupCheck_companion9x->setChecked(g.startup_check_companion());
ui->startupCheck_fw->setChecked(glob.startup_check_fw()); ui->startupCheck_fw->setChecked(g.startup_check_fw());
ui->wizardEnable_ChkB->setChecked(glob.wizardEnable()); ui->wizardEnable_ChkB->setChecked(g.wizardEnable());
ui->showSplash->setChecked(glob.show_splash()); ui->showSplash->setChecked(g.show_splash());
ui->historySize->setValue(glob.history_size()); ui->historySize->setValue(g.history_size());
ui->backLightColor->setCurrentIndex(glob.backLight()); ui->backLightColor->setCurrentIndex(g.backLight());
ui->simuSW->setChecked(glob.simuSW()); ui->simuSW->setChecked(g.simuSW());
ui->libraryPath->setText(glob.libraryPath()); ui->libraryPath->setText(g.libraryPath());
ui->ge_lineedit->setText(glob.gePath()); ui->ge_lineedit->setText(g.gePath());
if (!glob.backupPath().isEmpty()) { if (!g.backupPath().isEmpty()) {
if (QDir(glob.backupPath()).exists()) { if (QDir(g.backupPath()).exists()) {
ui->backupPath->setText(glob.backupPath()); ui->backupPath->setText(g.backupPath());
ui->backupEnable->setEnabled(true); ui->backupEnable->setEnabled(true);
ui->backupEnable->setChecked(glob.backupEnable()); ui->backupEnable->setChecked(g.backupEnable());
} else { } else {
ui->backupEnable->setDisabled(true); ui->backupEnable->setDisabled(true);
} }
} else { } else {
ui->backupEnable->setDisabled(true); ui->backupEnable->setDisabled(true);
} }
ui->splashincludeCB->setCurrentIndex(glob.embedded_splashes()); ui->splashincludeCB->setCurrentIndex(g.embedded_splashes());
#ifdef JOYSTICKS #ifdef JOYSTICKS
ui->joystickChkB->setChecked(glob.js_support()); ui->joystickChkB->setChecked(g.js_support());
if (ui->joystickChkB->isChecked()) { if (ui->joystickChkB->isChecked()) {
QStringList joystickNames; QStringList joystickNames;
joystickNames << tr("No joysticks found"); joystickNames << tr("No joysticks found");
@ -134,7 +134,7 @@ void appPreferencesDialog::initSettings()
} }
ui->joystickCB->clear(); ui->joystickCB->clear();
ui->joystickCB->insertItems(0, joystickNames); ui->joystickCB->insertItems(0, joystickNames);
ui->joystickCB->setCurrentIndex(glob.js_ctrl()); ui->joystickCB->setCurrentIndex(g.js_ctrl());
} }
else { else {
ui->joystickCB->clear(); ui->joystickCB->clear();
@ -143,22 +143,22 @@ void appPreferencesDialog::initSettings()
} }
#endif #endif
// Profile Tab Inits // Profile Tab Inits
ui->channelorderCB->setCurrentIndex(glob.pro[glob.profileId()].default_channel_order()); ui->channelorderCB->setCurrentIndex(g.profile[g.id()].default_channel_order());
ui->stickmodeCB->setCurrentIndex(glob.pro[glob.profileId()].default_mode()); ui->stickmodeCB->setCurrentIndex(g.profile[g.id()].default_mode());
ui->renameFirmware->setChecked(glob.pro[glob.profileId()].rename_firmware_files()); ui->renameFirmware->setChecked(g.profile[g.id()].rename_firmware_files());
ui->sdPath->setText(glob.pro[glob.profileId()].sdPath()); ui->sdPath->setText(g.profile[g.id()].sdPath());
ui->profileIndexLE->setText(QString("%1").arg(glob.profileId())); ui->profileIndexLE->setText(QString("%1").arg(g.id()));
ui->profileNameLE->setText(glob.pro[glob.profileId()].Name()); ui->profileNameLE->setText(g.profile[g.id()].Name());
ui->firmwareLE->setText(glob.pro[glob.profileId()].firmware()); ui->firmwareLE->setText(g.profile[g.id()].firmware());
ui->SplashFileName->setText(glob.pro[glob.profileId()].SplashFileName()); ui->SplashFileName->setText(g.profile[g.id()].SplashFileName());
displayImage( glob.pro[glob.profileId()].SplashFileName() ); displayImage( g.profile[g.id()].SplashFileName() );
} }
void appPreferencesDialog::on_libraryPathButton_clicked() void appPreferencesDialog::on_libraryPathButton_clicked()
{ {
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), glob.libraryPath()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), g.libraryPath());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.libraryPath(fileName); g.libraryPath(fileName);
ui->libraryPath->setText(fileName); ui->libraryPath->setText(fileName);
} }
} }
@ -168,20 +168,20 @@ void appPreferencesDialog::on_snapshotClipboardCKB_clicked()
if (ui->snapshotClipboardCKB->isChecked()) { if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true); ui->snapshotPathButton->setDisabled(true);
glob.snapshot_to_clipboard(true); g.snapshot_to_clipboard(true);
} else { } else {
ui->snapshotPath->setEnabled(true); ui->snapshotPath->setEnabled(true);
ui->snapshotPath->setReadOnly(true); ui->snapshotPath->setReadOnly(true);
ui->snapshotPathButton->setEnabled(true); ui->snapshotPathButton->setEnabled(true);
glob.snapshot_to_clipboard(false); g.snapshot_to_clipboard(false);
} }
} }
void appPreferencesDialog::on_backupPathButton_clicked() void appPreferencesDialog::on_backupPathButton_clicked()
{ {
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), glob.backupPath()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), g.backupPath());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.backupPath(fileName); g.backupPath(fileName);
ui->backupPath->setText(fileName); ui->backupPath->setText(fileName);
} }
ui->backupEnable->setEnabled(true); ui->backupEnable->setEnabled(true);
@ -232,7 +232,7 @@ void appPreferencesDialog::on_joystickcalButton_clicked() {
void appPreferencesDialog::on_sdPathButton_clicked() void appPreferencesDialog::on_sdPathButton_clicked()
{ {
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), glob.pro[glob.profileId()].sdPath()); QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), g.profile[g.id()].sdPath());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName); ui->sdPath->setText(fileName);
} }
@ -244,24 +244,24 @@ void appPreferencesDialog::saveProfile()
if (ui->profileNameLE->text().isEmpty()) if (ui->profileNameLE->text().isEmpty())
ui->profileNameLE->setText("----"); ui->profileNameLE->setText("----");
glob.pro[glob.profileId()].Name( ui->profileNameLE->text() ); g.profile[g.id()].Name( ui->profileNameLE->text() );
glob.pro[glob.profileId()].default_channel_order( ui->channelorderCB->currentIndex()); g.profile[g.id()].default_channel_order( ui->channelorderCB->currentIndex());
glob.pro[glob.profileId()].default_mode( ui->stickmodeCB->currentIndex()); g.profile[g.id()].default_mode( ui->stickmodeCB->currentIndex());
glob.pro[glob.profileId()].burnFirmware( ui->burnFirmware->isChecked()); g.profile[g.id()].burnFirmware( ui->burnFirmware->isChecked());
glob.pro[glob.profileId()].rename_firmware_files( ui->renameFirmware->isChecked()); g.profile[g.id()].rename_firmware_files( ui->renameFirmware->isChecked());
glob.pro[glob.profileId()].sdPath( ui->sdPath->text()); g.profile[g.id()].sdPath( ui->sdPath->text());
glob.pro[glob.profileId()].SplashFileName( ui->SplashFileName->text()); g.profile[g.id()].SplashFileName( ui->SplashFileName->text());
glob.pro[glob.profileId()].firmware( ui->firmwareLE->text()); g.profile[g.id()].firmware( ui->firmwareLE->text());
} }
void appPreferencesDialog::on_removeProfileButton_clicked() void appPreferencesDialog::on_removeProfileButton_clicked()
{ {
if ( glob.profileId() == 0 ) if ( g.id() == 0 )
QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed.")); QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
else else
{ {
glob.pro[glob.profileId()].remove(); g.profile[g.id()].remove();
glob.profileId( 0 ); g.id( 0 );
initSettings(); initSettings();
} }
} }
@ -277,7 +277,7 @@ bool appPreferencesDialog::displayImage( QString fileName )
// Use the firmware name to determine splash width // Use the firmware name to determine splash width
int width = SPLASH_WIDTH; int width = SPLASH_WIDTH;
if (glob.pro[glob.profileId()].firmware().contains("taranis")) if (g.profile[g.id()].firmware().contains("taranis"))
width = SPLASHX9D_WIDTH; width = SPLASHX9D_WIDTH;
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT))); ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT)));
@ -313,10 +313,10 @@ void appPreferencesDialog::on_SplashSelect_clicked()
} }
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats)); tr("Open Image to load"), g.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()){ if (!fileName.isEmpty()){
glob.lastImagesDir(QFileInfo(fileName).dir().absolutePath()); g.lastImagesDir(QFileInfo(fileName).dir().absolutePath());
displayImage(fileName); displayImage(fileName);
ui->SplashFileName->setText(fileName); ui->SplashFileName->setText(fileName);

View file

@ -3,6 +3,7 @@
#include "avroutputdialog.h" #include "avroutputdialog.h"
#include "eeprominterface.h" #include "eeprominterface.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QtGui> #include <QtGui>
#if !defined WIN32 && defined __GNUC__ #if !defined WIN32 && defined __GNUC__
@ -83,33 +84,42 @@ burnConfigDialog::~burnConfigDialog()
void burnConfigDialog::getSettings() void burnConfigDialog::getSettings()
{ {
QSettings settings; avrLoc = g.avrdude_location();
sambaLoc = g.samba_location();
dfuLoc = g.dfu_location();
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString(); avrLoc = QFileInfo("avrdude.exe").absoluteFilePath();
dfuLoc = settings.value("dfu_location", QFileInfo("dfu-util.exe").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = QFileInfo("sam-ba.exe").absoluteFilePath();
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("dfu-util.exe").absoluteFilePath();
#elif defined __APPLE__ #elif defined __APPLE__
avrLoc = settings.value("avrdude_location", "/usr/local/bin/avrdude").toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", "/usr/local/bin/sam-ba").toString(); avrLoc = "/usr/local/bin/avrdude";
dfuLoc = settings.value("dfu_location", QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = "/usr/local/bin/sam-ba";
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath();
#else #else
avrLoc = settings.value("avrdude_location", "/usr/bin/avrdude").toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", "/usr/bin/sam-ba").toString(); avrLoc = "/usr/bin/avrdude";
dfuLoc = settings.value("dfu_location", QFileInfo("/usr/bin/dfu-util").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = "/usr/bin/sam-ba";
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("/usr/bin/dfu-util").absoluteFilePath();
#endif #endif
QString str = settings.value("avr_arguments").toString();
avrArgs = str.split(" ", QString::SkipEmptyParts);
avrProgrammer = settings.value("programmer", QString("usbasp")).toString();
avrMCU = settings.value("mcu", QString("m64")).toString(); dfuArgs = g.dfu_arguments().split(" ", QString::SkipEmptyParts);
armMCU = settings.value("arm_mcu", QString("at91sam3s4-9x")).toString(); avrArgs = g.avr_arguments().split(" ", QString::SkipEmptyParts);
avrProgrammer = g.programmer();
avrPort = g.avr_port();
avrMCU = g.mcu();
armMCU = g.arm_mcu();
sambaPort = g.samba_port();
avrPort = settings.value("avr_port", "").toString();
sambaPort = settings.value("samba_port", "\\USBserial\\COM23").toString();
str = settings.value("dfu_arguments", "-a 0").toString();
dfuArgs = str.split(" ", QString::SkipEmptyParts);
ui->avrdude_location->setText(getAVRDUDE()); ui->avrdude_location->setText(getAVRDUDE());
ui->avrArgs->setText(getAVRArgs().join(" ")); ui->avrArgs->setText(getAVRArgs().join(" "));
@ -137,17 +147,16 @@ void burnConfigDialog::getSettings()
void burnConfigDialog::putSettings() void burnConfigDialog::putSettings()
{ {
QSettings settings; g.avrdude_location( avrLoc );
settings.setValue("avrdude_location", avrLoc); g.programmer( avrProgrammer);
settings.setValue("programmer", avrProgrammer); g.mcu( avrMCU );
settings.setValue("mcu", avrMCU); g.avr_port( avrPort );
settings.setValue("avr_port", avrPort); g.avr_arguments( avrArgs.join(" ") );
settings.setValue("avr_arguments", avrArgs.join(" ")); g.samba_location( sambaLoc );
settings.setValue("samba_location", sambaLoc); g.samba_port( sambaPort );
settings.setValue("samba_port", sambaPort); g.arm_mcu( armMCU );
settings.setValue("arm_mcu", armMCU); g.dfu_location( dfuLoc );
settings.setValue("dfu_location", dfuLoc); g.dfu_arguments( dfuArgs.join(" ") );
settings.setValue("dfu_arguments", dfuArgs.join(" "));
} }
void burnConfigDialog::populateProgrammers() void burnConfigDialog::populateProgrammers()

View file

@ -59,7 +59,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
else { else {
setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName)); setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
} }
ui->profile_label->setText(tr("Current profile")+QString(": ")+glob.pro[glob.profileId()].Name()); ui->profile_label->setText(tr("Current profile")+QString(": ")+g.profile[g.id()].Name());
} }
if (!hexfileName->isEmpty()) { if (!hexfileName->isEmpty()) {
ui->FWFileName->setText(*hexfileName); ui->FWFileName->setText(*hexfileName);
@ -69,19 +69,13 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
else { else {
burnraw=false; burnraw=false;
if (checkeEprom(*hexfileName)) { if (checkeEprom(*hexfileName)) {
QSettings settings; QString Name = g.profile[g.id()].Name();
settings.beginGroup("Profiles"); QString calib = g.profile[g.id()].StickPotCalib();
QString profile=QString("profile%1").arg(glob.profileId()); QString trainercalib = g.profile[g.id()].TrainerCalib();
settings.beginGroup(profile); QString DisplaySet = g.profile[g.id()].Display();
QString Name=settings.value("Name","").toString(); QString BeeperSet = g.profile[g.id()].Beeper();
QString calib=settings.value("StickPotCalib","").toString(); QString HapticSet = g.profile[g.id()].Haptic();
QString trainercalib=settings.value("TrainerCalib","").toString(); QString SpeakerSet = g.profile[g.id()].Speaker();
QString DisplaySet=settings.value("Display","").toString();
QString BeeperSet=settings.value("Beeper","").toString();
QString HapticSet=settings.value("Haptic","").toString();
QString SpeakerSet=settings.value("Speaker","").toString();
settings.endGroup();
settings.endGroup();
if (!Name.isEmpty()) { if (!Name.isEmpty()) {
ui->profile_label->show(); ui->profile_label->show();
ui->patchcalib_CB->show(); ui->patchcalib_CB->show();
@ -112,7 +106,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
} }
else if (Type==2) { else if (Type==2) {
QString FileName; QString FileName;
FileName = glob.lastFw(); FileName = g.lastFw();
QFile file(FileName); QFile file(FileName);
if (file.exists()) { if (file.exists()) {
checkFw(FileName); checkFw(FileName);
@ -146,11 +140,11 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->EEbackupCB->hide(); ui->EEbackupCB->hide();
QTimer::singleShot(0, this, SLOT(shrink())); QTimer::singleShot(0, this, SLOT(shrink()));
if (hexType==2) { if (hexType==2) {
fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastFlashDir(), FLASH_FILES_FILTER); fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.lastFlashDir(), FLASH_FILES_FILTER);
checkFw(fileName); checkFw(fileName);
} }
else { else {
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), glob.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), g.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (checkeEprom(fileName)) { if (checkeEprom(fileName)) {
if (burnraw==false) { if (burnraw==false) {
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
@ -206,8 +200,8 @@ void burnDialog::checkFw(QString fileName)
ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight()); ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
ui->FwImage->show(); ui->FwImage->show();
ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash())); ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash()));
QString ImageStr = glob.pro[glob.profileId()].SplashFileName(); QString ImageStr = g.profile[g.id()].SplashFileName();
bool PatchFwCB = glob.pro[glob.profileId()].patchImage(); bool PatchFwCB = g.profile[g.id()].patchImage();
if (!ImageStr.isEmpty()) { if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr); QImage Image = qstring2image(ImageStr);
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat()))); ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat())));
@ -250,7 +244,7 @@ void burnDialog::checkFw(QString fileName)
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
} }
QTimer::singleShot(0, this, SLOT(shrink())); QTimer::singleShot(0, this, SLOT(shrink()));
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() ); g.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
} }
bool burnDialog::checkeEprom(QString fileName) bool burnDialog::checkeEprom(QString fileName)
@ -351,10 +345,10 @@ void burnDialog::on_ImageLoadButton_clicked()
} }
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats)); tr("Open Image to load"), g.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastImagesDir( QFileInfo(fileName).dir().absolutePath() ); g.lastImagesDir( QFileInfo(fileName).dir().absolutePath() );
QImage image(fileName); QImage image(fileName);
if (image.isNull()) { if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
@ -431,10 +425,10 @@ void burnDialog::on_BurnFlashButton_clicked()
if (hexType==2) { if (hexType==2) {
QString fileName=ui->FWFileName->text(); QString fileName=ui->FWFileName->text();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() ); g.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
glob.lastFw( fileName ); g.lastFw( fileName );
if (ui->PatchFWCB->isChecked()) { if (ui->PatchFWCB->isChecked()) {
glob.pro[glob.profileId()].patchImage( true ); g.profile[g.id()].patchImage( true );
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height()); QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height());
if (!image.isNull()) { if (!image.isNull()) {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
@ -457,7 +451,7 @@ void burnDialog::on_BurnFlashButton_clicked()
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found")); QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
} }
} else { } else {
glob.pro[glob.profileId()].patchImage( false ); g.profile[g.id()].patchImage( false );
hexfileName->clear(); hexfileName->clear();
hexfileName->append(fileName); hexfileName->append(fileName);
} }
@ -467,26 +461,19 @@ void burnDialog::on_BurnFlashButton_clicked()
} }
} }
if (hexType==1) { if (hexType==1) {
QSettings settings; QString calib = g.profile[g.id()].StickPotCalib();
int profileid=glob.profileId(); QString trainercalib = g.profile[g.id()].TrainerCalib();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
settings.beginGroup(profile);
QString calib=settings.value("StickPotCalib","").toString();
QString trainercalib=settings.value("TrainerCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", radioData.generalSettings.vBatCalib).toInt(); int8_t vBatCalib=(int8_t) g.profile[g.id()].VbatCalib();
int8_t currentCalib=(int8_t)settings.value("currentCalib", radioData.generalSettings.currentCalib).toInt(); int8_t currentCalib=(int8_t) g.profile[g.id()].currentCalib();
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", radioData.generalSettings.PPM_Multiplier).toInt(); int8_t PPM_Multiplier=(int8_t) g.profile[g.id()].PPM_Multiplier();
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", radioData.generalSettings.stickMode).toUInt(); uint8_t GSStickMode=(uint8_t) g.profile[g.id()].GSStickMode();
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",radioData.generalSettings.vBatWarn).toUInt(); uint8_t vBatWarn=(uint8_t) g.profile[g.id()].vBatWarn();
QString DisplaySet=settings.value("Display","").toString(); QString DisplaySet= g.profile[g.id()].Display();
QString BeeperSet=settings.value("Beeper","").toString(); QString BeeperSet= g.profile[g.id()].Beeper();
QString HapticSet=settings.value("Haptic","").toString(); QString HapticSet= g.profile[g.id()].Haptic();
QString SpeakerSet=settings.value("Speaker","").toString(); QString SpeakerSet= g.profile[g.id()].Speaker();
settings.endGroup();
settings.endGroup();
bool patch=false; bool patch=false;
if (ui->patchcalib_CB->isChecked()) { if (ui->patchcalib_CB->isChecked()) {
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
@ -644,7 +631,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked)
{ {
QString tmpFileName; QString tmpFileName;
if (checked) { if (checked) {
QString ImageStr = glob.pro[glob.profileId()].SplashFileName(); QString ImageStr = g.profile[g.id()].SplashFileName();
if (!ImageStr.isEmpty()) { if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr); QImage Image = qstring2image(ImageStr);
if (ui->imageLabel->width()!=128) { if (ui->imageLabel->width()!=128) {

View file

@ -46,7 +46,7 @@ bool Side::displayImage( QString fileName, Source pictSource )
if (pictSource== PICT) if (pictSource== PICT)
*format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X; *format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X;
else if (pictSource == PROFILE) else if (pictSource == PROFILE)
*format = (glob.pro[glob.profileId()].firmware().contains("taranis")) ? LCDTARANIS : LCD9X; *format = (g.profile[g.id()].firmware().contains("taranis")) ? LCDTARANIS : LCD9X;
} }
if (image.isNull()) { if (image.isNull()) {
return false; return false;
@ -115,7 +115,7 @@ bool Side::saveImage()
} }
QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) { if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) {
glob.lastFlashDir( QFileInfo(*saveToFileName).dir().absolutePath() ); g.lastFlashDir( QFileInfo(*saveToFileName).dir().absolutePath() );
} }
else { else {
return false; return false;
@ -124,7 +124,7 @@ bool Side::saveImage()
else if (*source == PICT) { else if (*source == PICT) {
QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
if (image.save(*saveToFileName)) { if (image.save(*saveToFileName)) {
glob.lastImagesDir( QFileInfo(*saveToFileName).dir().absolutePath() ); g.lastImagesDir( QFileInfo(*saveToFileName).dir().absolutePath() );
} }
else { else {
return false; return false;
@ -181,12 +181,12 @@ void customizeSplashDialog::on_leftLoadFwButton_clicked() {loadFirmware(left);}
void customizeSplashDialog::on_rightLoadFwButton_clicked() {loadFirmware(right);} void customizeSplashDialog::on_rightLoadFwButton_clicked() {loadFirmware(right);}
void customizeSplashDialog::loadFirmware(Side side) void customizeSplashDialog::loadFirmware(Side side)
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastFlashDir(), FLASH_FILES_FILTER); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.lastFlashDir(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, FW )) if (!side.displayImage( fileName, FW ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName));
else else
glob.lastFlashDir( QFileInfo(fileName).dir().absolutePath() ); g.lastFlashDir( QFileInfo(fileName).dir().absolutePath() );
} }
} }
@ -199,13 +199,13 @@ void customizeSplashDialog::loadPicture(Side side)
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats)); tr("Open Image to load"), g.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PICT )) if (!side.displayImage( fileName, PICT ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName));
else else
glob.lastImagesDir( QFileInfo(fileName).dir().absolutePath() ); g.lastImagesDir( QFileInfo(fileName).dir().absolutePath() );
} }
} }
@ -213,7 +213,7 @@ void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left
void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);} void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);}
void customizeSplashDialog::loadProfile(Side side) void customizeSplashDialog::loadProfile(Side side)
{ {
QString fileName=glob.pro[glob.profileId()].SplashFileName(); QString fileName=g.profile[g.id()].SplashFileName();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PROFILE )) if (!side.displayImage( fileName, PROFILE ))

View file

@ -6,7 +6,6 @@
#include "firmwares/gruvin9x/gruvin9xinterface.h" #include "firmwares/gruvin9x/gruvin9xinterface.h"
#include "firmwares/opentx/opentxinterface.h" #include "firmwares/opentx/opentxinterface.h"
#include "firmwares/ersky9x/ersky9xinterface.h" #include "firmwares/ersky9x/ersky9xinterface.h"
#include "qsettings.h"
#include "appdata.h" #include "appdata.h"
#include "helpers.h" #include "helpers.h"
@ -732,34 +731,25 @@ GeneralSettings::GeneralSettings()
calibSpanNeg[i] = 0x180; calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180; calibSpanPos[i] = 0x180;
} }
QSettings settings; templateSetup = g.profile[g.id()].default_channel_order();
templateSetup = settings.value("default_channel_order", 0).toInt(); stickMode = g.profile[g.id()].default_mode();
stickMode = settings.value("default_mode", 1).toInt();
int profile_id = glob.profileId(); QString t_calib=g.profile[g.id()].StickPotCalib();
if (profile_id>-1) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id);
settings.beginGroup(profile);
QString t_calib=settings.value("StickPotCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) { if (t_calib.isEmpty()) {
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString t_trainercalib=settings.value("TrainerCalib","").toString(); QString t_trainercalib=g.profile[g.id()].TrainerCalib();
int8_t t_vBatCalib=(int8_t)settings.value("VbatCalib", vBatCalib).toInt(); int8_t t_vBatCalib=(int8_t)g.profile[g.id()].VbatCalib();
int8_t t_currentCalib=(int8_t)settings.value("currentCalib", currentCalib).toInt(); int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", PPM_Multiplier).toInt(); int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].PPM_Multiplier();
uint8_t t_stickMode=(uint8_t)settings.value("GSStickMode", stickMode).toUInt(); uint8_t t_stickMode=(uint8_t)g.profile[g.id()].GSStickMode();
uint8_t t_vBatWarn=(uint8_t)settings.value("vBatWarn",vBatWarn).toUInt(); uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=settings.value("Display","").toString(); QString t_DisplaySet=g.profile[g.id()].Display();
QString t_BeeperSet=settings.value("Beeper","").toString(); QString t_BeeperSet=g.profile[g.id()].Beeper();
QString t_HapticSet=settings.value("Haptic","").toString(); QString t_HapticSet=g.profile[g.id()].Haptic();
QString t_SpeakerSet=settings.value("Speaker","").toString(); QString t_SpeakerSet=g.profile[g.id()].Speaker();
QString t_CountrySet=settings.value("countryCode","").toString(); QString t_CountrySet=g.profile[g.id()].countryCode();
settings.endGroup();
settings.endGroup();
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) { if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte; QString Byte;
@ -841,7 +831,7 @@ GeneralSettings::GeneralSettings()
} }
} }
} }
}
} }
ModelData::ModelData() ModelData::ModelData()
@ -996,7 +986,7 @@ void RegisterEepromInterfaces()
eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X)); eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS)); eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS));
if (glob.rev4asupport()) if (g.rev4asupport())
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a)); eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X));

View file

@ -19,6 +19,7 @@
#include "er9xeeprom.h" #include "er9xeeprom.h"
#include "er9xsimulator.h" #include "er9xsimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -44,8 +45,7 @@ const char * Er9xInterface::getName()
const int Er9xInterface::getEEpromSize() const int Er9xInterface::getEEpromSize()
{ {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;
} }

View file

@ -18,6 +18,7 @@
#include "gruvin9xinterface.h" #include "gruvin9xinterface.h"
#include "gruvin9xeeprom.h" #include "gruvin9xeeprom.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -47,8 +48,7 @@ const char * Gruvin9xInterface::getName()
const int Gruvin9xInterface::getEEpromSize() const int Gruvin9xInterface::getEEpromSize()
{ {
if (board == BOARD_STOCK) { if (board == BOARD_STOCK) {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return EESIZE_STOCK*2; return EESIZE_STOCK*2;
} }

View file

@ -16,6 +16,7 @@
#include "opentxSky9xsimulator.h" #include "opentxSky9xsimulator.h"
#include "opentxinterface.h" #include "opentxinterface.h"
#include "appdata.h"
#define SIMU #define SIMU
#define SIMU_EXCEPTIONS #define SIMU_EXCEPTIONS
@ -135,8 +136,7 @@ using namespace Open9xSky9x;
Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface): Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
QSettings settings; QString path=g.profile[g.id()].sdPath()+"/";
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii(); simuSdDirectory[i]=path.at(i).toAscii();

View file

@ -16,6 +16,7 @@
#include "opentxTaranisSimulator.h" #include "opentxTaranisSimulator.h"
#include "opentxinterface.h" #include "opentxinterface.h"
#include "appdata.h"
#define SIMU #define SIMU
#define SIMU_EXCEPTIONS #define SIMU_EXCEPTIONS
@ -181,8 +182,7 @@ OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
taranisSimulatorBoard = GetEepromInterface()->getBoard(); taranisSimulatorBoard = GetEepromInterface()->getBoard();
QSettings settings; QString path=g.profile[g.id()].sdPath()+"/";
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii(); simuSdDirectory[i]=path.at(i).toAscii();

View file

@ -26,6 +26,7 @@
#include "opentxSky9xsimulator.h" #include "opentxSky9xsimulator.h"
#include "opentxTaranisSimulator.h" #include "opentxTaranisSimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -933,9 +934,11 @@ bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esiz
QString geturl( int board) QString geturl( int board)
{ {
QSettings settings; QString url = g.compilationServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compilationServer(url);
}
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
case BOARD_M128: case BOARD_M128:
@ -956,8 +959,11 @@ QString geturl( int board)
QString getstamp( int board) QString getstamp( int board)
{ {
QSettings settings; QString url = g.compilationServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compilationServer(url);
}
url.append("/stamp-opentx-"); url.append("/stamp-opentx-");
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -985,8 +991,11 @@ QString getstamp( int board)
QString getrnurl( int board) QString getrnurl( int board)
{ {
QSettings settings; QString url = g.compilationServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compilationServer(url);
}
url.append("/releasenotes-"); url.append("/releasenotes-");
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -1212,9 +1221,7 @@ void RegisterOpen9xFirmwares()
open9x->addOptions(fai_options); open9x->addOptions(fai_options);
firmwares.push_back(open9x); firmwares.push_back(open9x);
QSettings settings; if (g.rev4asupport()) {
int rev4a = settings.value("rev4asupport",0).toInt();
if (rev4a) {
open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));

View file

@ -19,6 +19,7 @@
#include "th9xeeprom.h" #include "th9xeeprom.h"
#include "th9xsimulator.h" #include "th9xsimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -44,8 +45,7 @@ const char * Th9xInterface::getName()
const int Th9xInterface::getEEpromSize() const int Th9xInterface::getEEpromSize()
{ {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;
} }

View file

@ -188,11 +188,8 @@ void fwPreferencesDialog::firmwareChanged()
ui->CPU_ID_LE->hide(); ui->CPU_ID_LE->hide();
ui->CPU_ID_LABEL->hide(); ui->CPU_ID_LABEL->hide();
} }
QSettings settings; int fwrev = g.fwRev.get(variant.id);
settings.beginGroup("FwRevisions"); if (fwrev != 0) {
int fwrev = settings.value(variant.id, -1).toInt();
settings.endGroup();
if (fwrev != -1) {
ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev)); ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev));
if (!stamp.isEmpty()) { if (!stamp.isEmpty()) {
ui->checkFWUpdates->show(); ui->checkFWUpdates->show();
@ -214,9 +211,9 @@ void fwPreferencesDialog::firmwareChanged()
void fwPreferencesDialog::writeValues() void fwPreferencesDialog::writeValues()
{ {
glob.cpu_id( ui->CPU_ID_LE->text() ); g.cpu_id( ui->CPU_ID_LE->text() );
current_firmware_variant = getFirmwareVariant(); current_firmware_variant = getFirmwareVariant();
glob.pro[glob.profileId()].firmware( current_firmware_variant.id ); g.profile[g.id()].firmware( current_firmware_variant.id );
} }
void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
@ -274,7 +271,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
void fwPreferencesDialog::initSettings() void fwPreferencesDialog::initSettings()
{ {
ui->CPU_ID_LE->setText(glob.cpu_id()); ui->CPU_ID_LE->setText(g.cpu_id());
FirmwareInfo * current_firmware = GetCurrentFirmware(); FirmwareInfo * current_firmware = GetCurrentFirmware();
foreach(FirmwareInfo * firmware, firmwares) { foreach(FirmwareInfo * firmware, firmwares) {
@ -291,9 +288,9 @@ void fwPreferencesDialog::initSettings()
void fwPreferencesDialog::on_checkFWUpdates_clicked() void fwPreferencesDialog::on_checkFWUpdates_clicked()
{ {
FirmwareVariant variant = getFirmwareVariant(); FirmwareVariant variant = getFirmwareVariant();
if (glob.pro[glob.profileId()].burnFirmware()) { if (g.profile[g.id()].burnFirmware()) {
current_firmware_variant = variant; current_firmware_variant = variant;
glob.pro[glob.profileId()].firmware( variant.id ); g.profile[g.id()].firmware( variant.id );
} }
MainWindow * mw = (MainWindow *)this->parent(); MainWindow * mw = (MainWindow *)this->parent();
mw->checkForUpdates(true, variant.id); mw->checkForUpdates(true, variant.id);
@ -306,9 +303,9 @@ void fwPreferencesDialog::on_fw_dnld_clicked()
FirmwareVariant variant = getFirmwareVariant(); FirmwareVariant variant = getFirmwareVariant();
writeValues(); writeValues();
if (!variant.firmware->getUrl(variant.id).isNull()) { if (!variant.firmware->getUrl(variant.id).isNull()) {
if (glob.pro[glob.profileId()].burnFirmware()) { if (g.profile[g.id()].burnFirmware()) {
current_firmware_variant = getFirmwareVariant(); current_firmware_variant = getFirmwareVariant();
glob.pro[glob.profileId()].firmware( current_firmware_variant.id ); g.profile[g.id()].firmware( current_firmware_variant.id );
} }
mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id); mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id);
} }

View file

@ -1,9 +1,9 @@
#include "generaledit.h" #include "generaledit.h"
#include "ui_generaledit.h" #include "ui_generaledit.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QtGui> #include <QtGui>
#define MAX_PROFILES 10
#define BIT_WARN_THR ( 0x01 ) #define BIT_WARN_THR ( 0x01 )
#define BIT_WARN_SW ( 0x02 ) #define BIT_WARN_SW ( 0x02 )
#define BIT_WARN_MEM ( 0x04 ) #define BIT_WARN_MEM ( 0x04 )
@ -20,18 +20,12 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(QIcon(":/icon.png")); this->setWindowIcon(QIcon(":/icon.png"));
QSettings settings; QString firmware_id = g.profile[g.id()].firmware();
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); ui->tabWidget->setCurrentIndex( g.generalEditTab() );
ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); QString name=g.profile[g.id()].Name();
int profile_id=settings.value("profileId", 0).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (name.isEmpty()) { if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true); ui->calstore_PB->setDisabled(true);
} }
settings.endGroup();
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
QLabel * pmsl[] = {ui->ro_label,ui->ro1_label,ui->ro2_label,ui->ro3_label,ui->ro4_label,ui->ro5_label,ui->ro6_label,ui->ro7_label,ui->ro8_label, NULL}; QLabel * pmsl[] = {ui->ro_label,ui->ro1_label,ui->ro2_label,ui->ro3_label,ui->ro4_label,ui->ro5_label,ui->ro6_label,ui->ro7_label,ui->ro8_label, NULL};
QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL}; QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL};
@ -76,18 +70,14 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
} }
ui->profile_CB->clear(); ui->profile_CB->clear();
for ( int i = 0; i < MAX_PROFILES; ++i) { for ( int i = 0; i < MAX_PROFILES; ++i) {
QString profile=QString("profile%1").arg(i+1); QString name=g.profile[i].Name();
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) { if (!name.isEmpty()) {
ui->profile_CB->addItem(name, i+1); ui->profile_CB->addItem(name, i);
if ((i+1)==profile_id) { if (i==g.id()) {
ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1); ui->profile_CB->setCurrentIndex(ui->profile_CB->count());
} }
} }
settings.endGroup();
} }
settings.endGroup();
QRegExp rx(CHAR_FOR_NAMES_REGEX); QRegExp rx(CHAR_FOR_NAMES_REGEX);
ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this)); ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this));
@ -970,9 +960,7 @@ void GeneralEdit::on_PPM4_editingFinished()
void GeneralEdit::on_tabWidget_currentChanged(int index) void GeneralEdit::on_tabWidget_currentChanged(int index)
{ {
// TODO why er9x here g.generalEditTab(index);
QSettings settings;
settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex());
} }
@ -1220,31 +1208,23 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int )
void GeneralEdit::on_calretrieve_PB_clicked() void GeneralEdit::on_calretrieve_PB_clicked()
{ {
QSettings settings;
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles"); QString calib=g.profile[profile_id].StickPotCalib();
QString profile=QString("profile%1").arg(profile_id);
settings.beginGroup(profile);
QString calib=settings.value("StickPotCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (calib.isEmpty()) { if (calib.isEmpty()) {
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString trainercalib=settings.value("TrainerCalib","").toString(); QString trainercalib = g.profile[profile_id].TrainerCalib();
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", g_eeGeneral.vBatCalib).toInt(); int8_t vBatCalib = (int8_t)g.profile[profile_id].VbatCalib();
int8_t currentCalib=(int8_t)settings.value("currentCalib", g_eeGeneral.currentCalib).toInt(); int8_t currentCalib = (int8_t)g.profile[profile_id].currentCalib();
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", g_eeGeneral.PPM_Multiplier).toInt(); int8_t PPM_Multiplier = (int8_t)g.profile[profile_id].PPM_Multiplier();
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", g_eeGeneral.stickMode).toUInt(); uint8_t GSStickMode = (uint8_t)g.profile[profile_id].GSStickMode();
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",g_eeGeneral.vBatWarn).toUInt(); uint8_t vBatWarn = (uint8_t)g.profile[profile_id].vBatWarn();
QString DisplaySet=settings.value("Display","").toString(); QString DisplaySet = g.profile[profile_id].Display();
QString BeeperSet=settings.value("Beeper","").toString(); QString BeeperSet = g.profile[profile_id].Beeper();
QString HapticSet=settings.value("Haptic","").toString(); QString HapticSet = g.profile[profile_id].Haptic();
QString SpeakerSet=settings.value("Speaker","").toString(); QString SpeakerSet = g.profile[profile_id].Speaker();
QString CountrySet=settings.value("countryCode","").toString(); QString CountrySet = g.profile[profile_id].countryCode();
settings.endGroup();
settings.endGroup();
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
QString Byte; QString Byte;
@ -1337,27 +1317,20 @@ void GeneralEdit::on_calretrieve_PB_clicked()
void GeneralEdit::on_calstore_PB_clicked() void GeneralEdit::on_calstore_PB_clicked()
{ {
QSettings settings;
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id); QString name=g.profile[profile_id].Name();
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (name.isEmpty()) { if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true); ui->calstore_PB->setDisabled(true);
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString calib=settings.value("StickPotCalib","").toString(); QString calib=g.profile[profile_id].StickPotCalib();
if (!(calib.isEmpty())) { if (!(calib.isEmpty())) {
int ret = QMessageBox::question(this, "Companion", int ret = QMessageBox::question(this, "Companion",
tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) , tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) ,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No) { if (ret == QMessageBox::No) {
settings.endGroup();
settings.endGroup();
return; return;
} }
} }
@ -1367,24 +1340,22 @@ void GeneralEdit::on_calstore_PB_clicked()
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanNeg[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanNeg[i], 4, 16, QChar('0')));
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanPos[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanPos[i], 4, 16, QChar('0')));
} }
settings.setValue("StickPotCalib",calib); g.profile[profile_id].StickPotCalib( calib );
calib.clear(); calib.clear();
for (int i=0; i< 4; i++) { for (int i=0; i< 4; i++) {
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0')));
} }
settings.setValue("TrainerCalib",calib); g.profile[profile_id].TrainerCalib( calib );
settings.setValue("VbatCalib",g_eeGeneral.vBatCalib); g.profile[profile_id].VbatCalib( g_eeGeneral.vBatCalib );
settings.setValue("currentCalib",g_eeGeneral.currentCalib); g.profile[profile_id].currentCalib( g_eeGeneral.currentCalib );
settings.setValue("vBatWarn",g_eeGeneral.vBatWarn); g.profile[profile_id].vBatWarn( g_eeGeneral.vBatWarn );
settings.setValue("PPM_Multiplier",g_eeGeneral.PPM_Multiplier); g.profile[profile_id].PPM_Multiplier( g_eeGeneral.PPM_Multiplier );
settings.setValue("GSStickMode",g_eeGeneral.stickMode); g.profile[profile_id].GSStickMode( g_eeGeneral.stickMode );
settings.setValue("Display",QString("%1%2%3").arg((g_eeGeneral.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.contrast, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.backlightBright, 2, 16, QChar('0'))); g.profile[profile_id].Display( QString("%1%2%3").arg((g_eeGeneral.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.contrast, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.backlightBright, 2, 16, QChar('0')) );
settings.setValue("Beeper",QString("%1%2").arg(((uint8_t)g_eeGeneral.beeperMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.beeperLength, 2, 16, QChar('0'))); g.profile[profile_id].Beeper( QString("%1%2").arg(((uint8_t)g_eeGeneral.beeperMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.beeperLength, 2, 16, QChar('0')));
settings.setValue("Haptic",QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0'))); g.profile[profile_id].Haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0')));
settings.setValue("Speaker",QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0'))); g.profile[profile_id].Speaker( QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0')));
settings.setValue("countryCode",QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage)); g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage));
settings.endGroup();
settings.endGroup();
QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved.")); QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved."));
} }
} }

View file

@ -914,7 +914,7 @@ QString getCenterBeep(ModelData * g_model)
QString getTheme() QString getTheme()
{ {
int theme_set = glob.theme(); int theme_set = g.theme();
QString Theme; QString Theme;
switch(theme_set) { switch(theme_set) {
case 0: case 0:

View file

@ -1,5 +1,6 @@
#include "joystickdialog.h" #include "joystickdialog.h"
#include "ui_joystickdialog.h" #include "ui_joystickdialog.h"
#include "appdata.h"
#include <QtGui> #include <QtGui>
joystickDialog::joystickDialog(QWidget *parent, int stick) : joystickDialog::joystickDialog(QWidget *parent, int stick) :
@ -130,27 +131,20 @@ void joystickDialog::on_okButton_clicked() {
return; return;
} }
joystick->close(); joystick->close();
QSettings settings;
settings.beginGroup("JsCalibration");
for (int i=0; i<8;i++) { for (int i=0; i<8;i++) {
settings.remove(QString("stick%1_axe").arg(i)); g.joystick[i].remove();
settings.remove(QString("stick%1_max").arg(i));
settings.remove(QString("stick%1_med").arg(i));
settings.remove(QString("stick%1_min").arg(i));
settings.remove(QString("stick%1_inv").arg(i));
} }
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8}; QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) { foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1; int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1;
int stick=cb->currentIndex(); int stick=cb->currentIndex();
if (stick>0) { if (stick > 0) {
settings.setValue(QString("stick%1_axe").arg(stick),axe); g.joystick[stick].stick_axe( axe );
settings.setValue(QString("stick%1_max").arg(stick),jscal[axe][2]); g.joystick[stick].stick_max( jscal[axe][2] );
settings.setValue(QString("stick%1_med").arg(stick),jscal[axe][1]); g.joystick[stick].stick_med( jscal[axe][1] );
settings.setValue(QString("stick%1_min").arg(stick),jscal[axe][0]); g.joystick[stick].stick_min( jscal[axe][0] );
settings.setValue(QString("stick%1_inv").arg(stick),ib[axe]->isChecked() ? 1 : 0); g.joystick[stick].stick_inv( ib[axe]->isChecked() ? 1 : 0 );
} }
} }
settings.endGroup();
this->close(); this->close();
} }

View file

@ -49,9 +49,9 @@ class lcdWidget : public QWidget {
void setBackgroundColor(int red, int green, int blue) void setBackgroundColor(int red, int green, int blue)
{ {
r = red; _r = red;
g = green; _g = green;
b = blue; _b = blue;
} }
void makeScreenshot(const QString & fileName) void makeScreenshot(const QString & fileName)
@ -59,10 +59,10 @@ class lcdWidget : public QWidget {
QPixmap buffer(2*lcdWidth, 2*lcdHeight); QPixmap buffer(2*lcdWidth, 2*lcdHeight);
QPainter p(&buffer); QPainter p(&buffer);
doPaint(p); doPaint(p);
bool toclipboard=glob.snapshot_to_clipboard(); bool toclipboard=g.snapshot_to_clipboard();
QApplication::clipboard()->setPixmap( buffer ); QApplication::clipboard()->setPixmap( buffer );
if (!toclipboard) { if (!toclipboard) {
QString Path=glob.snapshotpath(); QString Path=g.snapshotpath();
if (Path.isEmpty() || !QDir(Path).exists()) { if (Path.isEmpty() || !QDir(Path).exists()) {
Path="."; Path=".";
} }
@ -98,14 +98,14 @@ class lcdWidget : public QWidget {
unsigned char *previousBuf; unsigned char *previousBuf;
bool lightEnable; bool lightEnable;
int r, g, b; int _r, _g, _b;
inline void doPaint(QPainter & p) inline void doPaint(QPainter & p)
{ {
QRgb rgb; QRgb rgb;
if (lightEnable) if (lightEnable)
rgb = qRgb(r, g, b); rgb = qRgb(_r, _g, _b);
else else
rgb = qRgb(161, 161, 161); rgb = qRgb(161, 161, 161);
@ -136,7 +136,7 @@ class lcdWidget : public QWidget {
if (z != previousDepth) { if (z != previousDepth) {
previousDepth = z; previousDepth = z;
if (lightEnable) if (lightEnable)
rgb = qRgb(r-(z*r)/15, g-(z*g)/15, b-(z*b)/15); rgb = qRgb(_r-(z*_r)/15, _g-(z*_g)/15, _b-(z*_b)/15);
else else
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15); rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
p.setPen(rgb); p.setPen(rgb);

View file

@ -39,7 +39,7 @@ logsDialog::logsDialog(QWidget *parent) :
ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectedFont(legendFont);
ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items
ui->customPlot->legend->setVisible(false); ui->customPlot->legend->setVisible(false);
QString Path=glob.gePath(); QString Path=g.gePath();
if (Path.isEmpty() || !QFile(Path).exists()) { if (Path.isEmpty() || !QFile(Path).exists()) {
ui->mapsButton->hide(); ui->mapsButton->hide();
} }
@ -202,7 +202,7 @@ void logsDialog::on_mapsButton_clicked() {
,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\ ,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\
,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F}; ,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F};
QString gePath=glob.gePath(); QString gePath=g.gePath();
if (gePath.isEmpty() || !QFile(gePath).exists()) { if (gePath.isEmpty() || !QFile(gePath).exists()) {
ui->FieldsTW->setDisabled(false); ui->FieldsTW->setDisabled(false);
ui->logTable->setDisabled(false); ui->logTable->setDisabled(false);
@ -584,9 +584,9 @@ void logsDialog::moveLegend()
void logsDialog::on_fileOpen_BT_clicked() void logsDialog::on_fileOpen_BT_clicked()
{ {
QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), glob.lastLogDir()); QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), g.lastLogDir());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastLogDir( fileName ); g.lastLogDir( fileName );
ui->FileName_LE->setText(fileName); ui->FileName_LE->setText(fileName);
if (cvsFileParse()) { if (cvsFileParse()) {
ui->FieldsTW->clear(); ui->FieldsTW->clear();

View file

@ -75,7 +75,7 @@ class MyProxyStyle : public QProxyStyle
#endif #endif
// Global data and storge object // Global data and storge object
AppData glob; AppData g;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -90,26 +90,26 @@ int main(int argc, char *argv[])
#endif #endif
QTranslator companionTranslator; QTranslator companionTranslator;
companionTranslator.load(":/companion_" + glob.locale()); companionTranslator.load(":/companion_" + g.locale());
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load((QString)"qt_" + glob.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&companionTranslator); app.installTranslator(&companionTranslator);
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
if (glob.pro[glob.profileId()].firmware().isEmpty()) if (g.profile[g.id()].firmware().isEmpty())
glob.pro[glob.profileId()].firmware(default_firmware_variant.id); g.profile[g.id()].firmware(default_firmware_variant.id);
QPixmap pixmap = QPixmap(glob.pro[glob.profileId()].firmware().contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png"); QPixmap pixmap = QPixmap(g.profile[g.id()].firmware().contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png");
QSplashScreen *splash = new QSplashScreen(pixmap); QSplashScreen *splash = new QSplashScreen(pixmap);
RegisterFirmwares(); RegisterFirmwares();
current_firmware_variant = GetFirmwareVariant(glob.pro[glob.profileId()].firmware()); current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware());
MainWindow *mainWin = new MainWindow(); MainWindow *mainWin = new MainWindow();
if (glob.show_splash()) { if (g.show_splash()) {
splash->show(); splash->show();
QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));

View file

@ -100,7 +100,7 @@ MainWindow::MainWindow():
createStatusBar(); createStatusBar();
updateMenus(); updateMenus();
restoreState(glob.mainWindowState()); restoreState(g.mainWindowState());
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
this->setWindowIcon(QIcon(":/icon.png")); this->setWindowIcon(QIcon(":/icon.png"));
@ -110,7 +110,7 @@ MainWindow::MainWindow():
// give time to the splash to disappear and main window to open before starting updates // give time to the splash to disappear and main window to open before starting updates
int updateDelay = 1000; int updateDelay = 1000;
bool showSplash = glob.show_splash(); bool showSplash = g.show_splash();
if (showSplash) { if (showSplash) {
updateDelay += (SPLASH_TIME*1000); updateDelay += (SPLASH_TIME*1000);
} }
@ -163,7 +163,7 @@ MainWindow::MainWindow():
void MainWindow::displayWarnings() void MainWindow::displayWarnings()
{ {
int warnId=glob.warningId(); int warnId=g.warningId();
if (warnId<WARNING_ID && warnId!=0) { if (warnId<WARNING_ID && warnId!=0) {
int res=0; int res=0;
if (WARNING_LEVEL>0) { if (WARNING_LEVEL>0) {
@ -174,10 +174,10 @@ void MainWindow::displayWarnings()
res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No); res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No);
} }
if (res == QMessageBox::No) { if (res == QMessageBox::No) {
glob.warningId(WARNING_ID); g.warningId(WARNING_ID);
} }
} else if (warnId==0) { } else if (warnId==0) {
glob.warningId(WARNING_ID); g.warningId(WARNING_ID);
} }
} }
@ -200,7 +200,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
QString stamp = GetFirmware(fwToUpdate)->stamp; QString stamp = GetFirmware(fwToUpdate)->stamp;
if (!stamp.isEmpty()) { if (!stamp.isEmpty()) {
if (glob.startup_check_fw() || ignoreSettings) { if (g.startup_check_fw() || ignoreSettings) {
check1done=false; check1done=false;
manager1 = new QNetworkAccessManager(this); manager1 = new QNetworkAccessManager(this);
connect(manager1, SIGNAL(finished(QNetworkReply*)), this, SLOT(reply1Finished(QNetworkReply*))); connect(manager1, SIGNAL(finished(QNetworkReply*)), this, SLOT(reply1Finished(QNetworkReply*)));
@ -211,7 +211,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
} }
} }
if (glob.startup_check_companion() || ignoreSettings) { if (g.startup_check_companion() || ignoreSettings) {
check2done = false; check2done = false;
manager2 = new QNetworkAccessManager(this); manager2 = new QNetworkAccessManager(this);
connect(manager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForUpdateFinished(QNetworkReply*))); connect(manager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForUpdateFinished(QNetworkReply*)));
@ -263,12 +263,12 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply)
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
#if defined __APPLE__ #if defined __APPLE__
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version)); QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version));
#else #else
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)")); QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)"));
#endif #endif
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastUpdatesDir(QFileInfo(fileName).dir().absolutePath()); g.lastUpdatesDir(QFileInfo(fileName).dir().absolutePath());
downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName); downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName);
installer_fileName = fileName; installer_fileName = fileName;
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
@ -302,9 +302,9 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
{ {
QString url, ext, cpuid; QString url, ext, cpuid;
url = firmware->getUrl(firmwareId); url = firmware->getUrl(firmwareId);
cpuid=glob.cpu_id(); cpuid=g.cpu_id();
ext = url.mid(url.lastIndexOf(".")); ext = url.mid(url.lastIndexOf("."));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + firmwareId + ext); QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastFlashDir() + "/" + firmwareId + ext);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
downloadedFW = firmwareId; downloadedFW = firmwareId;
needRename=true; needRename=true;
@ -313,7 +313,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
url.append("&cpuid="); url.append("&cpuid=");
url.append(cpuid); url.append(cpuid);
} }
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath()); g.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
downloadDialog * dd = new downloadDialog(this, url, fileName); downloadDialog * dd = new downloadDialog(this, url, fileName);
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
dd->exec(); dd->exec();
@ -323,8 +323,6 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
void MainWindow::reply1Accepted() void MainWindow::reply1Accepted()
{ {
QString errormsg; QString errormsg;
QSettings settings;
settings.beginGroup("FwRevisions");
if (downloadedFWFilename.isEmpty()) { if (downloadedFWFilename.isEmpty()) {
if (!(downloadedFW.isEmpty())) { if (!(downloadedFW.isEmpty())) {
QFile file(downloadedFW); QFile file(downloadedFW);
@ -359,12 +357,11 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
QMessageBox::critical(this, tr("Error"), errormsg); QMessageBox::critical(this, tr("Error"), errormsg);
settings.endGroup();
return; return;
} }
file.close(); file.close();
currentFWrev = currentFWrev_temp; currentFWrev = currentFWrev_temp;
settings.setValue(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
} }
} else { } else {
QFile file(downloadedFWFilename); QFile file(downloadedFWFilename);
@ -399,7 +396,6 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
QMessageBox::critical(this, tr("Error"), errormsg); QMessageBox::critical(this, tr("Error"), errormsg);
settings.endGroup();
return; return;
} }
file.close(); file.close();
@ -408,7 +404,7 @@ void MainWindow::reply1Accepted()
int pos=rev.lastIndexOf("-r"); int pos=rev.lastIndexOf("-r");
if (pos>0) { if (pos>0) {
currentFWrev=rev.mid(pos+2).toInt(); currentFWrev=rev.mid(pos+2).toInt();
if (glob.pro[glob.profileId()].rename_firmware_files() && needRename) { if (g.profile[g.id()].rename_firmware_files() && needRename) {
QFileInfo fi(downloadedFWFilename); QFileInfo fi(downloadedFWFilename);
QString path=fi.path()+QDir::separator (); QString path=fi.path()+QDir::separator ();
path.append(fi.completeBaseName()); path.append(fi.completeBaseName());
@ -420,8 +416,8 @@ void MainWindow::reply1Accepted()
qd.rename(downloadedFWFilename,path); qd.rename(downloadedFWFilename,path);
downloadedFWFilename=path; downloadedFWFilename=path;
} }
settings.setValue(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
if (glob.pro[glob.profileId()].burnFirmware()) { if (g.profile[g.id()].burnFirmware()) {
int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the transmitter now ?"), QMessageBox::Yes | QMessageBox::No); 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) { if (ret == QMessageBox::Yes) {
writeFlash(downloadedFWFilename); writeFlash(downloadedFWFilename);
@ -429,7 +425,6 @@ void MainWindow::reply1Accepted()
} }
} }
} }
settings.endGroup();
} }
void MainWindow::reply1Finished(QNetworkReply * reply) void MainWindow::reply1Finished(QNetworkReply * reply)
@ -445,8 +440,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
// TODO delete downloadDialog_forWait? // TODO delete downloadDialog_forWait?
} }
QSettings settings; cpuid=g.cpu_id();
cpuid=glob.cpu_id();
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
int i = qba.indexOf("SVN_VERS"); int i = qba.indexOf("SVN_VERS");
int warning = qba.indexOf("WARNING"); int warning = qba.indexOf("WARNING");
@ -460,15 +454,13 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
if(!cres) { if(!cres) {
QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
glob.fwserver(glob.fwserver()+1); g.fwserver(g.fwserver()+1);
return; return;
} }
if(rev>0) { if(rev>0) {
NewFwRev=rev; NewFwRev=rev;
settings.beginGroup("FwRevisions"); OldFwRev = g.fwRev.get(fwToUpdate);
OldFwRev = settings.value(fwToUpdate, 0).toInt();
settings.endGroup();
QMessageBox msgBox; QMessageBox msgBox;
QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout* layout = (QGridLayout*)msgBox.layout(); QGridLayout* layout = (QGridLayout*)msgBox.layout();
@ -539,9 +531,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
if (ignore) { if (ignore) {
int res = QMessageBox::question(this, "Companion",tr("Ignore this version (r%1)?").arg(rev), QMessageBox::Yes | QMessageBox::No); int res = QMessageBox::question(this, "Companion",tr("Ignore this version (r%1)?").arg(rev), QMessageBox::Yes | QMessageBox::No);
if (res==QMessageBox::Yes) { if (res==QMessageBox::Yes) {
settings.beginGroup("FwRevisions"); g.fwRev.set(fwToUpdate, NewFwRev);
settings.setValue(fwToUpdate, NewFwRev);
settings.endGroup();
} }
} else if (download == true) { } else if (download == true) {
if (warning>0) { if (warning>0) {
@ -558,12 +548,12 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate); QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate);
QString ext = url.mid(url.lastIndexOf(".")); QString ext = url.mid(url.lastIndexOf("."));
needRename=false; needRename=false;
bool addversion=glob.pro[glob.profileId()].rename_firmware_files(); bool addversion=g.profile[g.id()].rename_firmware_files();
QString fileName; QString fileName;
if (addversion) { if (addversion) {
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + fwToUpdate + newrev + ext); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastFlashDir() + "/" + fwToUpdate + newrev + ext);
} else { } else {
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + fwToUpdate + ext); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastFlashDir() + "/" + fwToUpdate + ext);
} }
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!cpuid.isEmpty()) { if (!cpuid.isEmpty()) {
@ -571,7 +561,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
url.append(cpuid); url.append(cpuid);
} }
downloadedFWFilename = fileName; downloadedFWFilename = fileName;
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath()); g.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
downloadDialog * dd = new downloadDialog(this, url, fileName); downloadDialog * dd = new downloadDialog(this, url, fileName);
currentFWrev_temp = NewFwRev; currentFWrev_temp = NewFwRev;
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
@ -585,7 +575,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
} else { } else {
if(check1done && check2done) { if(check1done && check2done) {
QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
glob.fwserver(glob.fwserver()+1); g.fwserver(g.fwserver()+1);
return; return;
} }
} }
@ -593,8 +583,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
glob.mainWindowGeometry(saveGeometry()); g.mainWindowGeometry(saveGeometry());
glob.mainWindowState(saveState()); g.mainWindowState(saveState());
mdiArea->closeAllSubWindows(); mdiArea->closeAllSubWindows();
if (mdiArea->currentSubWindow()) { if (mdiArea->currentSubWindow()) {
event->ignore(); event->ignore();
@ -606,7 +596,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::setLanguage(QString langString) void MainWindow::setLanguage(QString langString)
{ {
glob.locale( langString ); g.locale( langString );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The selected language will be used the next time you start Companion.")); msgBox.setText(tr("The selected language will be used the next time you start Companion."));
@ -617,7 +607,7 @@ void MainWindow::setLanguage(QString langString)
void MainWindow::setTheme(int index) void MainWindow::setTheme(int index)
{ {
glob.theme( index ); g.theme( index );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The new theme will be loaded the next time you start Companion.")); msgBox.setText(tr("The new theme will be loaded the next time you start Companion."));
@ -628,7 +618,7 @@ void MainWindow::setTheme(int index)
void MainWindow::setIconThemeSize(int index) void MainWindow::setIconThemeSize(int index)
{ {
glob.icon_size( index ); g.icon_size( index );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The icon size will be used the next time you start Companion.")); msgBox.setText(tr("The icon size will be used the next time you start Companion."));
@ -652,9 +642,9 @@ void MainWindow::openDocURL()
void MainWindow::openFile() void MainWindow::openFile()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastDir(), tr(EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.lastDir(), tr(EEPROM_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastDir(QFileInfo(fileName).dir().absolutePath()); g.lastDir(QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) { if (existing) {
@ -709,10 +699,10 @@ void MainWindow::loadProfile() //TODO Load all variables - Also HW!
if (action) { if (action) {
// Set the new profile number // Set the new profile number
int profnum=action->data().toInt(); int profnum=action->data().toInt();
glob.profileId( profnum ); g.id( profnum );
// TODO Get rid of this global variable - The profile.firmware is the real source // TODO Get rid of this global variable - The profile.firmware is the real source
current_firmware_variant = GetFirmwareVariant(glob.pro[glob.profileId()].firmware()); current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware());
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget()); MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
@ -1065,14 +1055,14 @@ void MainWindow::writeFileToEeprom()
burnDialog *cd = new burnDialog(this, 1, &fileName, &backup); burnDialog *cd = new burnDialog(this, 1, &fileName, &backup);
cd->exec(); cd->exec();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.lastDir(QFileInfo(fileName).dir().absolutePath()); g.lastDir(QFileInfo(fileName).dir().absolutePath());
int ret = QMessageBox::question(this, "Companion", tr("Write Models and settings from %1 to the Tx?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No); int ret = QMessageBox::question(this, "Companion", tr("Write Models and settings from %1 to the Tx?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No);
if (ret != QMessageBox::Yes) return; if (ret != QMessageBox::Yes) return;
if (!isValidEEPROM(fileName)) if (!isValidEEPROM(fileName))
ret = QMessageBox::question(this, "Companion", tr("The file %1\nhas not been recognized as a valid Models and Settings file\nWrite anyway ?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No); ret = QMessageBox::question(this, "Companion", tr("The file %1\nhas not been recognized as a valid Models and Settings file\nWrite anyway ?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No);
if (ret != QMessageBox::Yes) return; if (ret != QMessageBox::Yes) return;
bool backupEnable = glob.backupEnable(); bool backupEnable = g.backupEnable();
QString backupPath = glob.backupPath(); QString backupPath = g.backupPath();
if (!backupPath.isEmpty()) { if (!backupPath.isEmpty()) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -1314,7 +1304,7 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
void MainWindow::writeFlash(QString fileToFlash) void MainWindow::writeFlash(QString fileToFlash)
{ {
QString fileName; QString fileName;
bool backup = glob.backupOnFlash(); bool backup = g.backupOnFlash();
if(!fileToFlash.isEmpty()) if(!fileToFlash.isEmpty())
fileName = fileToFlash; fileName = fileToFlash;
burnDialog *cd = new burnDialog(this, 2, &fileName, &backup); burnDialog *cd = new burnDialog(this, 2, &fileName, &backup);
@ -1322,12 +1312,12 @@ void MainWindow::writeFlash(QString fileToFlash)
if (IS_TARANIS(GetEepromInterface()->getBoard())) if (IS_TARANIS(GetEepromInterface()->getBoard()))
backup=false; backup=false;
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
glob.backupOnFlash(backup); g.backupOnFlash(backup);
if (backup) { if (backup) {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString backupFile = tempDir + "/backup.bin"; QString backupFile = tempDir + "/backup.bin";
bool backupEnable=glob.backupEnable(); bool backupEnable=g.backupEnable();
QString backupPath=glob.backupPath(); QString backupPath=g.backupPath();
if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) { if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -1381,8 +1371,8 @@ void MainWindow::writeFlash(QString fileToFlash)
} }
} }
else { else {
bool backupEnable=glob.backupEnable(); bool backupEnable=g.backupEnable();
QString backupPath=glob.backupPath(); QString backupPath=g.backupPath();
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
QMessageBox::warning(this, tr("Backup is impossible"), tr("The backup dir set in preferences does not exist")); QMessageBox::warning(this, tr("Backup is impossible"), tr("The backup dir set in preferences does not exist"));
@ -1411,7 +1401,7 @@ void MainWindow::writeFlash(QString fileToFlash)
void MainWindow::readEepromToFile() void MainWindow::readEepromToFile()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), glob.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), g.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_TARANIS(eepromInterface->getBoard())) { if (IS_TARANIS(eepromInterface->getBoard())) {
@ -1430,7 +1420,7 @@ void MainWindow::readEepromToFile()
} }
} }
else { else {
glob.lastDir(QFileInfo(fileName).dir().absolutePath()); g.lastDir(QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveEEpromCommand(fileName); QStringList str = GetReceiveEEpromCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx"));
ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
@ -1442,13 +1432,13 @@ void MainWindow::readEepromToFile()
void MainWindow::readFlash() void MainWindow::readFlash()
{ {
QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), glob.lastFlashDir(),tr(FLASH_FILES_FILTER)); QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), g.lastFlashDir(),tr(FLASH_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QFile file(fileName); QFile file(fileName);
if (file.exists()) { if (file.exists()) {
file.remove(); file.remove();
} }
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath()); g.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveFlashCommand(fileName); QStringList str = GetReceiveFlashCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx");
ad->setWindowIcon(CompanionIcon("read_flash.png")); ad->setWindowIcon(CompanionIcon("read_flash.png"));
@ -1527,7 +1517,7 @@ void MainWindow::updateMenus()
updateIconSizeActions(); updateIconSizeActions();
updateIconThemeActions(); updateIconThemeActions();
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( glob.pro[glob.profileId()].Name() )); setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( g.profile[g.id()].Name() ));
} }
MdiChild *MainWindow::createMdiChild() MdiChild *MainWindow::createMdiChild()
@ -1780,7 +1770,7 @@ QMenu *MainWindow::createProfilesMenu()
void MainWindow::createToolBars() void MainWindow::createToolBars()
{ {
QSize size; QSize size;
switch(glob.icon_size()) { switch(g.icon_size()) {
case 0: case 0:
size=QSize(16,16); size=QSize(16,16);
break; break;
@ -1896,12 +1886,12 @@ void MainWindow::updateRecentFileActions()
int i, numRecentFiles; int i, numRecentFiles;
// Hide all document slots // Hide all document slots
for ( i=0 ; i < glob.history_size(); i++) for ( i=0 ; i < g.history_size(); i++)
recentFileActs[i]->setVisible(false); recentFileActs[i]->setVisible(false);
// Fill slots with content and unhide them // Fill slots with content and unhide them
QStringList files = glob.recentFileList(); QStringList files = g.recentFileList();
numRecentFiles = qMin(files.size(), glob.history_size()); numRecentFiles = qMin(files.size(), g.history_size());
for ( i = 0; i < numRecentFiles; i++) { for ( i = 0; i < numRecentFiles; i++) {
QString text = strippedName(files[i]); QString text = strippedName(files[i]);
@ -1916,7 +1906,7 @@ void MainWindow::updateRecentFileActions()
void MainWindow::updateIconSizeActions() void MainWindow::updateIconSizeActions()
{ {
switch (glob.icon_size()) switch (g.icon_size())
{ {
case 0: smallIconAct->setChecked(true); break; case 0: smallIconAct->setChecked(true); break;
case 1: normalIconAct->setChecked(true); break; case 1: normalIconAct->setChecked(true); break;
@ -1927,7 +1917,7 @@ void MainWindow::updateIconSizeActions()
void MainWindow::updateLanguageActions() void MainWindow::updateLanguageActions()
{ {
QString langId = glob.locale(); QString langId = g.locale();
if (langId=="") if (langId=="")
sysLangAct->setChecked(true); sysLangAct->setChecked(true);
@ -1957,7 +1947,7 @@ void MainWindow::updateLanguageActions()
void MainWindow::updateIconThemeActions() void MainWindow::updateIconThemeActions()
{ {
switch (glob.theme()) switch (g.theme())
{ {
case 0: classicThemeAct->setChecked(true); break; case 0: classicThemeAct->setChecked(true); break;
case 1: newThemeAct->setChecked(true); break; case 1: newThemeAct->setChecked(true); break;
@ -1971,13 +1961,13 @@ void MainWindow::updateProfilesActions()
{ {
for (int i=0; i<MAX_PROFILES; i++) for (int i=0; i<MAX_PROFILES; i++)
{ {
if (!glob.pro[i].Name().isEmpty()) if (!g.profile[i].Name().isEmpty())
{ {
QString text = tr("&%1: %2").arg(i).arg(glob.pro[i].Name()); QString text = tr("&%1: %2").arg(i).arg(g.profile[i].Name());
profileActs[i]->setText(text); profileActs[i]->setText(text);
profileActs[i]->setData(i); profileActs[i]->setData(i);
profileActs[i]->setVisible(true); profileActs[i]->setVisible(true);
if (i == glob.profileId()) if (i == g.id())
profileActs[i]->setChecked(true); profileActs[i]->setChecked(true);
} }
else else
@ -1989,14 +1979,14 @@ void MainWindow::updateProfilesActions()
void MainWindow::createProfile() void MainWindow::createProfile()
{ int i; { int i;
for (i=0; i<MAX_PROFILES && !glob.pro[i].Name().isEmpty(); i++) for (i=0; i<MAX_PROFILES && !g.profile[i].Name().isEmpty(); i++)
; ;
if (i==MAX_PROFILES) //Failed to find free slot if (i==MAX_PROFILES) //Failed to find free slot
return; return;
// Create profile name and force a flush to file // Create profile name and force a flush to file
glob.pro[i].Name( QString("profile%1").arg(i)); g.profile[i].Name( QString("profile%1").arg(i));
glob.pro[i].flush(); g.profile[i].flush();
updateMenus(); updateMenus();
} }
@ -2098,7 +2088,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QString fileName = urls.first().toLocalFile(); QString fileName = urls.first().toLocalFile();
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
glob.lastDir(QFileInfo(fileName).dir().absolutePath()); g.lastDir(QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) { if (existing) {

View file

@ -180,7 +180,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
} }
if (isNew && !wizard) { if (isNew && !wizard) {
int ret; int ret;
bool wizardEnable=glob.wizardEnable(); bool wizardEnable=g.wizardEnable();
if (wizardEnable) { if (wizardEnable) {
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
@ -189,7 +189,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
qSleep(500); qSleep(500);
ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No); ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No) { if (ret == QMessageBox::No) {
glob.wizardEnable( false ); g.wizardEnable( false );
} }
} }
} }
@ -351,28 +351,28 @@ bool MdiChild::saveAs(bool isNew)
curFile.replace(".eepe", ".bin"); curFile.replace(".eepe", ".bin");
QFileInfo fi(curFile); QFileInfo fi(curFile);
#ifdef __APPLE__ #ifdef __APPLE__
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName()); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastDir() + "/" +fi.fileName());
#else #else
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER)); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER));
#endif #endif
} }
else { else {
QFileInfo fi(curFile); QFileInfo fi(curFile);
#ifdef __APPLE__ #ifdef __APPLE__
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName()); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastDir() + "/" +fi.fileName());
#else #else
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER)); fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.lastDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER));
#endif #endif
} }
if (fileName.isEmpty()) if (fileName.isEmpty())
return false; return false;
if (fileName.contains("rev4a")) { if (fileName.contains("rev4a")) {
glob.rev4asupport( true ); g.rev4asupport( true );
} }
if (fileName.contains("norev4a")) { if (fileName.contains("norev4a")) {
glob.rev4asupport( false ); g.rev4asupport( false );
} }
glob.lastDir( QFileInfo(fileName).dir().absolutePath() ); g.lastDir( QFileInfo(fileName).dir().absolutePath() );
if (isNew) if (isNew)
return saveFile(fileName); return saveFile(fileName);
else else
@ -489,14 +489,14 @@ void MdiChild::setCurrentFile(const QString &fileName)
fileChanged = false; fileChanged = false;
setWindowModified(false); setWindowModified(false);
updateTitle(); updateTitle();
int MaxRecentFiles = glob.history_size(); int MaxRecentFiles = g.history_size();
QStringList files = glob.recentFileList(); QStringList files = g.recentFileList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
while (files.size() > MaxRecentFiles) while (files.size() > MaxRecentFiles)
files.removeLast(); files.removeLast();
glob.recentFileList( files ); g.recentFileList( files );
} }
QString MdiChild::strippedName(const QString &fullFileName) QString MdiChild::strippedName(const QString &fullFileName)
@ -506,8 +506,8 @@ QString MdiChild::strippedName(const QString &fullFileName)
void MdiChild::writeEeprom() // write to Tx void MdiChild::writeEeprom() // write to Tx
{ {
bool backupEnable=glob.backupEnable(); bool backupEnable=g.backupEnable();
QString backupPath=glob.backupPath(); QString backupPath=g.backupPath();
if (!backupPath.isEmpty()) { if (!backupPath.isEmpty()) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -518,7 +518,7 @@ void MdiChild::writeEeprom() // write to Tx
} else { } else {
backupEnable=false; backupEnable=false;
} }
QString stickCal=glob.pro[glob.profileId()].StickPotCalib(); QString stickCal=g.profile[g.id()].StickPotCalib();
burnConfigDialog bcd; burnConfigDialog bcd;
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString tempFile = tempDir + "/temp.bin"; QString tempFile = tempDir + "/temp.bin";
@ -681,7 +681,7 @@ void MdiChild::setEEpromAvail(int eavail)
bool MdiChild::loadBackup() bool MdiChild::loadBackup()
{ {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastDir(),tr(EEPROM_FILES_FILTER)); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.lastDir(),tr(EEPROM_FILES_FILTER));
if (fileName.isEmpty()) if (fileName.isEmpty())
return false; return false;
QFile file(fileName); QFile file(fileName);

View file

@ -75,7 +75,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
} }
} }
QString path = glob.pro[glob.profileId()].sdPath(); QString path = g.profile[g.id()].sdPath();
path.append("/SOUNDS/"); path.append("/SOUNDS/");
QString lang = generalSettings.ttsLanguage; QString lang = generalSettings.ttsLanguage;
if (lang.isEmpty()) if (lang.isEmpty())
@ -225,7 +225,7 @@ void CustomFunctionsPanel::playMusic()
QPushButton *playButton = qobject_cast<QPushButton*>(sender()); QPushButton *playButton = qobject_cast<QPushButton*>(sender());
int index=playButton->objectName().mid(5,2).toInt(); int index=playButton->objectName().mid(5,2).toInt();
QString function=playButton->objectName().left(4); QString function=playButton->objectName().left(4);
QString path = glob.pro[glob.profileId()].sdPath(); QString path = g.profile[g.id()].sdPath();
QDir qd(path); QDir qd(path);
QString track; QString track;
if (qd.exists()) { if (qd.exists()) {

View file

@ -22,7 +22,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
generalSettings(radioData.generalSettings) generalSettings(radioData.generalSettings)
{ {
ui->setupUi(this); ui->setupUi(this);
restoreGeometry(glob.modelEditGeometry()); restoreGeometry(g.modelEditGeometry());
ui->pushButton->setIcon(CompanionIcon("simulate.png")); ui->pushButton->setIcon(CompanionIcon("simulate.png"));
addTab(new Setup(this, model), tr("Setup")); addTab(new Setup(this, model), tr("Setup"));
addTab(new HeliPanel(this, model), tr("Heli")); addTab(new HeliPanel(this, model), tr("Heli"));
@ -45,7 +45,7 @@ ModelEdit::~ModelEdit()
void ModelEdit::closeEvent(QCloseEvent *event) void ModelEdit::closeEvent(QCloseEvent *event)
{ {
glob.modelEditGeometry( saveGeometry() ); g.modelEditGeometry( saveGeometry() );
} }
class VerticalScrollArea : public QScrollArea class VerticalScrollArea : public QScrollArea

View file

@ -348,7 +348,7 @@ Setup::Setup(QWidget *parent, ModelData & model):
if (GetEepromInterface()->getCapability(ModelImage)) { if (GetEepromInterface()->getCapability(ModelImage)) {
QStringList items; QStringList items;
items.append(""); items.append("");
QString path = glob.pro[glob.profileId()].sdPath(); QString path = g.profile[g.id()].sdPath();
path.append("/BMP/"); path.append("/BMP/");
QDir qd(path); QDir qd(path);
int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4; int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4;
@ -515,7 +515,7 @@ void Setup::on_image_currentIndexChanged(int index)
{ {
if (!lock) { if (!lock) {
strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength));
QString path=glob.pro[glob.profileId()].sdPath(); QString path=g.profile[g.id()].sdPath();
path.append("/BMP/"); path.append("/BMP/");
QDir qd(path); QDir qd(path);
if (qd.exists()) { if (qd.exists()) {

View file

@ -457,7 +457,7 @@ TelemetryPanel::~TelemetryPanel()
void TelemetryPanel::setup() void TelemetryPanel::setup()
{ {
QString firmware_id = glob.pro[glob.profileId()].firmware(); QString firmware_id = g.profile[g.id()].firmware();
lock=true; lock=true;

View file

@ -33,9 +33,8 @@ simulatorDialog::simulatorDialog(QWidget *parent) :
beepVal = 0; beepVal = 0;
beepShow = 0; beepShow = 0;
QSettings settings; backLight = g.backLight();
backLight = glob.backLight(); bool simuSW=g.simuSW();
bool simuSW=glob.simuSW();
switch (backLight) { switch (backLight) {
case 1: case 1:
ui->lcd->setBackgroundColor(166,247,159); ui->lcd->setBackgroundColor(166,247,159);
@ -76,23 +75,21 @@ simulatorDialog::simulatorDialog(QWidget *parent) :
} }
#ifdef JOYSTICKS #ifdef JOYSTICKS
bool js_enable=glob.js_support(); bool js_enable=g.js_support();
int js_ctrl=glob.js_ctrl(); int js_ctrl=g.js_ctrl();
if (js_enable) { if (js_enable) {
settings.beginGroup("JsCalibration");
int count=0; int count=0;
for (int j=0; j<8;j++){ for (int j=0; j<8;j++){
int axe=settings.value(QString("stick%1_axe").arg(j),-1).toInt(); int axe = g.joystick[j].stick_axe();
if (axe>=0 && axe<8) { if (axe>=0 && axe<8) {
jsmap[axe]=j; jsmap[axe]=j;
jscal[axe][0]=settings.value(QString("stick%1_min").arg(j),-32767).toInt(); jscal[axe][0]=g.joystick[j].stick_min();
jscal[axe][1]=settings.value(QString("stick%1_med").arg(j),0).toInt(); jscal[axe][1]=g.joystick[j].stick_med();
jscal[axe][2]=settings.value(QString("stick%1_max").arg(j),0).toInt(); jscal[axe][2]=g.joystick[j].stick_max();
jscal[axe][3]=settings.value(QString("stick%1_inv").arg(j),0).toInt(); jscal[axe][3]=g.joystick[j].stick_inv();
count++; count++;
} }
} }
settings.endGroup();
if (count<3) { if (count<3) {
QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly")); QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly"));
} }
@ -212,7 +209,7 @@ void simulatorDialog::setupTimer()
void simulatorDialog::onButtonPressed(int value) void simulatorDialog::onButtonPressed(int value)
{ {
if (value==Qt::Key_Print) { if (value==Qt::Key_Print) {
bool toclipboard=glob.snapshot_to_clipboard(); bool toclipboard=g.snapshot_to_clipboard();
QString fileName =""; QString fileName ="";
if (!toclipboard) { if (!toclipboard) {
fileName = QString("screenshot-%1.png").arg(++screenshotIdx); fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
@ -493,6 +490,7 @@ void simulatorDialog::on_trimVRight_valueChanged(int value)
simulator->setTrim(2, value); simulator->setTrim(2, value);
} }
void simulatorDialog::setValues() void simulatorDialog::setValues()
{ {
TxOutputs outputs; TxOutputs outputs;
@ -667,6 +665,7 @@ void simulatorDialog::on_holdRightX_clicked(bool checked)
void simulatorDialog::on_holdRightY_clicked(bool checked) void simulatorDialog::on_holdRightY_clicked(bool checked)
{ {
nodeRight->setCenteringY(!checked); nodeRight->setCenteringY(!checked);
} }

View file

@ -62,7 +62,7 @@ void splashLibrary::setupPage(int page) {
void splashLibrary::getFileList() { void splashLibrary::getFileList() {
imageList.clear(); imageList.clear();
if (glob.embedded_splashes() == 0) { if (g.embedded_splashes() == 0) {
QDir myRes(":/images/library"); QDir myRes(":/images/library");
QStringList tmp = myRes.entryList(); QStringList tmp = myRes.entryList();
for (int i = 0; i < tmp.size(); i++) { for (int i = 0; i < tmp.size(); i++) {
@ -70,7 +70,7 @@ void splashLibrary::getFileList() {
imageList.append(":/images/library/" + fileInfo.fileName()); imageList.append(":/images/library/" + fileInfo.fileName());
} }
} }
QString libraryPath = glob.libraryPath(); QString libraryPath = g.libraryPath();
if (!libraryPath.isEmpty()) { if (!libraryPath.isEmpty()) {
if (QDir(libraryPath).exists()) { if (QDir(libraryPath).exists()) {
QStringList supportedImageFormats; QStringList supportedImageFormats;

View file

@ -31,30 +31,27 @@ xsimulatorDialog::xsimulatorDialog(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
ui->lcd->setFocus(); ui->lcd->setFocus();
QSettings settings;
ui->lcd->setBackgroundColor(47, 123, 227); ui->lcd->setBackgroundColor(47, 123, 227);
setupSticks(); setupSticks();
resize(0, 0); // to force min height, min width resize(0, 0); // to force min height, min width
this->setFixedSize(this->width(), this->height()); this->setFixedSize(this->width(), this->height());
bool simuSW=settings.value("simuSW",false).toBool(); bool simuSW = g.simuSW();
#ifdef JOYSTICKS #ifdef JOYSTICKS
bool js_enable=settings.value("js_support",false).toBool(); int js_ctrl = g.js_ctrl();
int js_ctrl=settings.value("js_ctrl",-1).toInt();
if (js_enable) { if (g.js_support()) {
settings.beginGroup("JsCalibration");
int count=0; int count=0;
for (int j=0; j<8;j++){ for (int j=0; j<8;j++){
int axe=settings.value(QString("stick%1_axe").arg(j),-1).toInt(); int axe=g.joystick[j].stick_axe();
if (axe>=0 && axe<8) { if (axe>=0 && axe<8) {
jsmap[axe]=j; jsmap[axe]=j;
jscal[axe][0]=settings.value(QString("stick%1_min").arg(j),-32767).toInt(); jscal[axe][0]=g.joystick[j].stick_min();
jscal[axe][1]=settings.value(QString("stick%1_med").arg(j),0).toInt(); jscal[axe][1]=g.joystick[j].stick_med();
jscal[axe][2]=settings.value(QString("stick%1_max").arg(j),0).toInt(); jscal[axe][2]=g.joystick[j].stick_max();
jscal[axe][3]=settings.value(QString("stick%1_inv").arg(j),0).toInt(); jscal[axe][3]=g.joystick[j].stick_inv();
count++; count++;
} }
} }
settings.endGroup();
if (count<3) { if (count<3) {
QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly")); QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly"));
} }
@ -180,7 +177,7 @@ void xsimulatorDialog::setupTimer()
void xsimulatorDialog::onButtonPressed(int value) void xsimulatorDialog::onButtonPressed(int value)
{ {
if (value==Qt::Key_Print) { if (value==Qt::Key_Print) {
bool toclipboard=glob.snapshot_to_clipboard(); bool toclipboard=g.snapshot_to_clipboard();
QString fileName =""; QString fileName ="";
if (!toclipboard) { if (!toclipboard) {
fileName = QString("screenshot-%1.png").arg(++screenshotIdx); fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
@ -287,6 +284,7 @@ void xsimulatorDialog::loadParams(RadioData &radioData, const int model_idx)
setupTimer(); setupTimer();
} }
void xsimulatorDialog::setTrims() void xsimulatorDialog::setTrims()
{ {
Trims trims; Trims trims;
@ -460,6 +458,7 @@ void xsimulatorDialog::setValues()
ui->labelCSW_24->setStyleSheet(outputs.vsw[23] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_24->setStyleSheet(outputs.vsw[23] ? CSWITCH_ON : CSWITCH_OFF);
ui->labelCSW_25->setStyleSheet(outputs.vsw[24] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_25->setStyleSheet(outputs.vsw[24] ? CSWITCH_ON : CSWITCH_OFF);
ui->labelCSW_26->setStyleSheet(outputs.vsw[25] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_26->setStyleSheet(outputs.vsw[25] ? CSWITCH_ON : CSWITCH_OFF);
ui->labelCSW_27->setStyleSheet(outputs.vsw[26] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_27->setStyleSheet(outputs.vsw[26] ? CSWITCH_ON : CSWITCH_OFF);
ui->labelCSW_28->setStyleSheet(outputs.vsw[27] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_28->setStyleSheet(outputs.vsw[27] ? CSWITCH_ON : CSWITCH_OFF);
ui->labelCSW_29->setStyleSheet(outputs.vsw[28] ? CSWITCH_ON : CSWITCH_OFF); ui->labelCSW_29->setStyleSheet(outputs.vsw[28] ? CSWITCH_ON : CSWITCH_OFF);