Almost all global settings wrapped in protective object to guarantee type safety and protect against tag spelling errors (I have found and corrected a lot of those!).
Joystick settings and burner configuration is not yet within the global object.
This commit is contained in:
+17
-27
@@ -53,6 +53,7 @@
|
||||
#include "printdialog.h"
|
||||
#include "burndialog.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include <QFileInfo>
|
||||
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
@@ -179,8 +180,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
|
||||
}
|
||||
if (isNew && !wizard) {
|
||||
int ret;
|
||||
QSettings settings;
|
||||
bool wizardEnable=settings.value("wizardEnable", true).toBool();
|
||||
bool wizardEnable=glob.wizardEnable();
|
||||
if (wizardEnable) {
|
||||
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::Yes) {
|
||||
@@ -189,7 +189,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
|
||||
qSleep(500);
|
||||
ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret == QMessageBox::No) {
|
||||
settings.setValue("wizardEnable", false);
|
||||
glob.wizardEnable( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,34 +346,33 @@ bool MdiChild::save()
|
||||
|
||||
bool MdiChild::saveAs(bool isNew)
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName;
|
||||
if (GetEepromInterface()->getBoard() == BOARD_SKY9X) {
|
||||
curFile.replace(".eepe", ".bin");
|
||||
QFileInfo fi(curFile);
|
||||
#ifdef __APPLE__
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName());
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName());
|
||||
#else
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(BIN_FILES_FILTER));
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
QFileInfo fi(curFile);
|
||||
#ifdef __APPLE__
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName());
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName());
|
||||
#else
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER));
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER));
|
||||
#endif
|
||||
}
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
if (fileName.contains("rev4a")) {
|
||||
settings.setValue("rev4asupport", 1);
|
||||
glob.rev4asupport( true );
|
||||
}
|
||||
if (fileName.contains("norev4a")) {
|
||||
settings.setValue("rev4asupport", 0);
|
||||
glob.rev4asupport( false );
|
||||
}
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir( QFileInfo(fileName).dir().absolutePath() );
|
||||
if (isNew)
|
||||
return saveFile(fileName);
|
||||
else
|
||||
@@ -490,15 +489,14 @@ void MdiChild::setCurrentFile(const QString &fileName)
|
||||
fileChanged = false;
|
||||
setWindowModified(false);
|
||||
updateTitle();
|
||||
QSettings settings;
|
||||
int MaxRecentFiles =settings.value("history_size",10).toInt();
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
int MaxRecentFiles = glob.history_size();
|
||||
QStringList files = glob.recentFileList();
|
||||
files.removeAll(fileName);
|
||||
files.prepend(fileName);
|
||||
while (files.size() > MaxRecentFiles)
|
||||
files.removeLast();
|
||||
|
||||
settings.setValue("recentFileList", files);
|
||||
glob.recentFileList( files );
|
||||
}
|
||||
|
||||
QString MdiChild::strippedName(const QString &fullFileName)
|
||||
@@ -508,9 +506,8 @@ QString MdiChild::strippedName(const QString &fullFileName)
|
||||
|
||||
void MdiChild::writeEeprom() // write to Tx
|
||||
{
|
||||
QSettings settings;
|
||||
bool backupEnable=settings.value("backupEnable", true).toBool();
|
||||
QString backupPath=settings.value("backupPath", "").toString();
|
||||
bool backupEnable=glob.backupEnable();
|
||||
QString backupPath=glob.backupPath();
|
||||
if (!backupPath.isEmpty()) {
|
||||
if (!QDir(backupPath).exists()) {
|
||||
if (backupEnable) {
|
||||
@@ -521,13 +518,7 @@ void MdiChild::writeEeprom() // write to Tx
|
||||
} else {
|
||||
backupEnable=false;
|
||||
}
|
||||
int profileid=settings.value("profileId", 1).toInt();
|
||||
settings.beginGroup("Profiles");
|
||||
QString profile=QString("profile%1").arg(profileid);
|
||||
settings.beginGroup(profile);
|
||||
QString stickCal=settings.value("StickPotCalib","").toString();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
QString stickCal=glob.pro[glob.profileId()].StickPotCalib();
|
||||
burnConfigDialog bcd;
|
||||
QString tempDir = QDir::tempPath();
|
||||
QString tempFile = tempDir + "/temp.bin";
|
||||
@@ -690,8 +681,7 @@ void MdiChild::setEEpromAvail(int eavail)
|
||||
|
||||
bool MdiChild::loadBackup()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastDir(),tr(EEPROM_FILES_FILTER));
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
QFile file(fileName);
|
||||
|
||||
Reference in New Issue
Block a user