Changed every single QSetting in Companion.
Next step: Function renaming
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "generaledit.h"
|
||||
#include "ui_generaledit.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include <QtGui>
|
||||
|
||||
#define MAX_PROFILES 10
|
||||
#define BIT_WARN_THR ( 0x01 )
|
||||
#define BIT_WARN_SW ( 0x02 )
|
||||
#define BIT_WARN_MEM ( 0x04 )
|
||||
@@ -20,18 +20,12 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
this->setWindowIcon(QIcon(":/icon.png"));
|
||||
|
||||
QSettings settings;
|
||||
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
|
||||
ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt());
|
||||
int profile_id=settings.value("profileId", 0).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profile_id);
|
||||
settings.beginGroup(profile);
|
||||
QString name=settings.value("Name","").toString();
|
||||
QString firmware_id = g.profile[g.id()].firmware();
|
||||
ui->tabWidget->setCurrentIndex( g.generalEditTab() );
|
||||
QString name=g.profile[g.id()].Name();
|
||||
if (name.isEmpty()) {
|
||||
ui->calstore_PB->setDisabled(true);
|
||||
}
|
||||
settings.endGroup();
|
||||
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};
|
||||
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();
|
||||
for ( int i = 0; i < MAX_PROFILES; ++i) {
|
||||
QString profile=QString("profile%1").arg(i+1);
|
||||
settings.beginGroup(profile);
|
||||
QString name=settings.value("Name","").toString();
|
||||
QString name=g.profile[i].Name();
|
||||
if (!name.isEmpty()) {
|
||||
ui->profile_CB->addItem(name, i+1);
|
||||
if ((i+1)==profile_id) {
|
||||
ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1);
|
||||
ui->profile_CB->addItem(name, i);
|
||||
if (i==g.id()) {
|
||||
ui->profile_CB->setCurrentIndex(ui->profile_CB->count());
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this));
|
||||
@@ -970,9 +960,7 @@ void GeneralEdit::on_PPM4_editingFinished()
|
||||
|
||||
void GeneralEdit::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
// TODO why er9x here
|
||||
QSettings settings;
|
||||
settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex());
|
||||
g.generalEditTab(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1220,31 +1208,23 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int )
|
||||
|
||||
void GeneralEdit::on_calretrieve_PB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profile_id);
|
||||
settings.beginGroup(profile);
|
||||
QString calib=settings.value("StickPotCalib","").toString();
|
||||
QString calib=g.profile[profile_id].StickPotCalib();
|
||||
int potsnum=GetEepromInterface()->getCapability(Pots);
|
||||
if (calib.isEmpty()) {
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
return;
|
||||
} else {
|
||||
QString trainercalib=settings.value("TrainerCalib","").toString();
|
||||
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", g_eeGeneral.vBatCalib).toInt();
|
||||
int8_t currentCalib=(int8_t)settings.value("currentCalib", g_eeGeneral.currentCalib).toInt();
|
||||
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", g_eeGeneral.PPM_Multiplier).toInt();
|
||||
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", g_eeGeneral.stickMode).toUInt();
|
||||
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",g_eeGeneral.vBatWarn).toUInt();
|
||||
QString DisplaySet=settings.value("Display","").toString();
|
||||
QString BeeperSet=settings.value("Beeper","").toString();
|
||||
QString HapticSet=settings.value("Haptic","").toString();
|
||||
QString SpeakerSet=settings.value("Speaker","").toString();
|
||||
QString CountrySet=settings.value("countryCode","").toString();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
QString trainercalib = g.profile[profile_id].TrainerCalib();
|
||||
int8_t vBatCalib = (int8_t)g.profile[profile_id].VbatCalib();
|
||||
int8_t currentCalib = (int8_t)g.profile[profile_id].currentCalib();
|
||||
int8_t PPM_Multiplier = (int8_t)g.profile[profile_id].PPM_Multiplier();
|
||||
uint8_t GSStickMode = (uint8_t)g.profile[profile_id].GSStickMode();
|
||||
uint8_t vBatWarn = (uint8_t)g.profile[profile_id].vBatWarn();
|
||||
QString DisplaySet = g.profile[profile_id].Display();
|
||||
QString BeeperSet = g.profile[profile_id].Beeper();
|
||||
QString HapticSet = g.profile[profile_id].Haptic();
|
||||
QString SpeakerSet = g.profile[profile_id].Speaker();
|
||||
QString CountrySet = g.profile[profile_id].countryCode();
|
||||
|
||||
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
|
||||
QString Byte;
|
||||
@@ -1337,27 +1317,20 @@ void GeneralEdit::on_calretrieve_PB_clicked()
|
||||
|
||||
void GeneralEdit::on_calstore_PB_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profile_id);
|
||||
settings.beginGroup(profile);
|
||||
QString name=settings.value("Name","").toString();
|
||||
|
||||
QString name=g.profile[profile_id].Name();
|
||||
int potsnum=GetEepromInterface()->getCapability(Pots);
|
||||
if (name.isEmpty()) {
|
||||
ui->calstore_PB->setDisabled(true);
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
return;
|
||||
} else {
|
||||
QString calib=settings.value("StickPotCalib","").toString();
|
||||
QString calib=g.profile[profile_id].StickPotCalib();
|
||||
if (!(calib.isEmpty())) {
|
||||
int ret = QMessageBox::question(this, "Companion",
|
||||
tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) ,
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::No) {
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
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.calibSpanPos[i], 4, 16, QChar('0')));
|
||||
}
|
||||
settings.setValue("StickPotCalib",calib);
|
||||
g.profile[profile_id].StickPotCalib( calib );
|
||||
calib.clear();
|
||||
for (int i=0; i< 4; i++) {
|
||||
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0')));
|
||||
}
|
||||
settings.setValue("TrainerCalib",calib);
|
||||
settings.setValue("VbatCalib",g_eeGeneral.vBatCalib);
|
||||
settings.setValue("currentCalib",g_eeGeneral.currentCalib);
|
||||
settings.setValue("vBatWarn",g_eeGeneral.vBatWarn);
|
||||
settings.setValue("PPM_Multiplier",g_eeGeneral.PPM_Multiplier);
|
||||
settings.setValue("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')));
|
||||
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')));
|
||||
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')));
|
||||
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')));
|
||||
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));
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
g.profile[profile_id].TrainerCalib( calib );
|
||||
g.profile[profile_id].VbatCalib( g_eeGeneral.vBatCalib );
|
||||
g.profile[profile_id].currentCalib( g_eeGeneral.currentCalib );
|
||||
g.profile[profile_id].vBatWarn( g_eeGeneral.vBatWarn );
|
||||
g.profile[profile_id].PPM_Multiplier( g_eeGeneral.PPM_Multiplier );
|
||||
g.profile[profile_id].GSStickMode( g_eeGeneral.stickMode );
|
||||
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')) );
|
||||
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')));
|
||||
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')));
|
||||
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')));
|
||||
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));
|
||||
QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved."));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user