# HG changeset patch # User Matti Hamalainen # Date 1503565941 -10800 # Node ID d5d1549e47fb4436ae683f890295e538b2c93ff6 # Parent 5e6bcabfa380b4873cd72d6dc04020d35134705a Change how settings are restored and saved. diff -r 5e6bcabfa380 -r d5d1549e47fb src/main.cpp --- a/src/main.cpp Thu Aug 24 11:39:34 2017 +0300 +++ b/src/main.cpp Thu Aug 24 12:12:21 2017 +0300 @@ -24,8 +24,13 @@ // struct { + QPoint uiPos; + QSize uiSize; double uiScale; // Global UI scale factor + QString dataPath; // Application data path/directory + QString dbBackupURL; + QString dbBackupSecret; } settings; @@ -235,6 +240,14 @@ int main(int argc, char *argv[]) { QApplication sapp(argc, argv); + QSettings tmpst(APP_VENDOR, APP_ID); + + // Read configuration settings + settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint(); + settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize(); + settings.uiScale = tmpst.value("scale", 1.0f).toDouble(); + settings.dbBackupURL = tmpst.value("dbBackupURL", "").toString(); + settings.dbBackupSecret = tmpst.value("dbBackupSecret", "").toString(); // // Create logfile and data directory @@ -306,9 +319,11 @@ { // Setup UI ui->setupUi(this); + backupDialog = NULL; - // Read config - readSettings(); + // Restore window size and position + move(settings.uiPos); + resize(settings.uiSize); // Setup application icon and window title setWindowIcon(QIcon(QPixmap(":/img/icon-64.png"))); @@ -397,9 +412,18 @@ // SyntilistaMainWindow::~SyntilistaMainWindow() { - // Save current settings and free resources - saveSettings(); + QSettings tmpst(APP_VENDOR, APP_ID); + + // Save window size and position + tmpst.setValue("pos", pos()); + tmpst.setValue("size", size()); + // Other settings + tmpst.setValue("scale", settings.uiScale); + tmpst.setValue("dbBackupURL", settings.dbBackupURL); + tmpst.setValue("dbBackupSecret", settings.dbBackupSecret); + + // Free resources delete ui; delete model_People; delete model_Latest; @@ -421,35 +445,6 @@ // -// Restoring and saving of current settings -// -void SyntilistaMainWindow::readSettings() -{ - QSettings tmpst(APP_VENDOR, APP_ID); - - // Restore window size and position - move(tmpst.value("pos", QPoint(100, 100)).toPoint()); - resize(tmpst.value("size", QSize(1000, 600)).toSize()); - - // Other settings - settings.uiScale = tmpst.value("scale", 1.0f).toDouble(); -} - - -void SyntilistaMainWindow::saveSettings() -{ - QSettings tmpst(APP_VENDOR, APP_ID); - - // Save window size and position - tmpst.setValue("pos", pos()); - tmpst.setValue("size", size()); - - // Other settings - tmpst.setValue("scale", settings.uiScale); -} - - -// // Window scale / zoom changing // void SyntilistaMainWindow::changeUIZoomIn()