[Companion] Refactor settings system (CompStoreObj/AppData/etc):

~ All stored properties are fully dynamic, using an extended version of the Qt Property System;
 ~ CompStoreObj is now QObject subclass;
 + All properties now have change notifier signals;
 ~ Do not store default values in settings;
 + Add _reset() and _default() functions for each property;
 + Settings import now ignores all non-existent properties automatically;
 + Add settings export functions;
 + Add more version macros;
 ~ Remove template functions;
 ~ Move DownloadBranchType and create NewModelAction enums and register with Qt meta system;
 ~ Multiple efficiency and optimization changes (const functions, literals, etc).
This commit is contained in:
Max Paperno
2018-06-29 20:00:10 -04:00
parent 2869d8574d
commit 988c837011
13 changed files with 1087 additions and 1055 deletions
+21 -11
View File
@@ -103,14 +103,11 @@ MainWindow::MainWindow():
createMenus();
createToolBars();
retranslateUi();
updateMenus();
setIconThemeSize(g.iconSize());
restoreGeometry(g.mainWinGeo());
restoreState(g.mainWinState());
setTabbedWindows(g.tabbedMdi());
initWindowOptions();
connect(windowsListActions, &QActionGroup::triggered, this, &MainWindow::onChangeWindowAction);
connect(&g, &AppData::currentProfileChanged, this, &MainWindow::onCurrentProfileChanged);
// give time to the splash to disappear and main window to open before starting updates
int updateDelay = 1000;
@@ -181,6 +178,15 @@ MainWindow::~MainWindow()
}
}
void MainWindow::initWindowOptions()
{
updateMenus();
setIconThemeSize(g.iconSize());
restoreGeometry(g.mainWinGeo());
restoreState(g.mainWinState());
setTabbedWindows(g.tabbedMdi());
}
void MainWindow::displayWarnings()
{
using namespace AppMessages;
@@ -756,9 +762,6 @@ bool MainWindow::loadProfileId(const unsigned pid) // TODO Load all variables -
// Set the new profile number
g.id(pid);
Firmware::setCurrentVariant(newFw);
emit firmwareChanged();
updateMenus();
return true;
}
@@ -778,7 +781,7 @@ void MainWindow::appPrefs()
AppPreferencesDialog * dialog = new AppPreferencesDialog(this);
dialog->setMainWinHasDirtyChild(anyChildrenDirty());
connect(dialog, &AppPreferencesDialog::firmwareProfileAboutToChange, this, &MainWindow::saveAll);
connect(dialog, &AppPreferencesDialog::firmwareProfileChanged, this, &MainWindow::loadProfileId);
connect(dialog, &AppPreferencesDialog::firmwareProfileChanged, this, &MainWindow::onCurrentProfileChanged);
dialog->exec();
dialog->deleteLater();
}
@@ -1783,6 +1786,13 @@ void MainWindow::onChangeWindowAction(QAction * act)
mdiArea->setActiveSubWindow(win);
}
void MainWindow::onCurrentProfileChanged()
{
Firmware::setCurrentVariant(Firmware::getFirmwareForId(g.currentProfile().fwType()));
emit firmwareChanged();
updateMenus();
}
int MainWindow::newProfile(bool loadProfile)
{
int i;
@@ -1791,7 +1801,7 @@ int MainWindow::newProfile(bool loadProfile)
if (i == MAX_PROFILES) //Failed to find free slot
return -1;
g.profile[i].init(i);
g.profile[i].init();
g.profile[i].name(tr("New Radio"));
if (loadProfile) {
@@ -1835,7 +1845,7 @@ void MainWindow::deleteProfile(const int pid)
if (ret != QMessageBox::Yes)
return;
g.profile[pid].remove();
g.getProfile(pid).resetAll();
loadProfileId(0);
}