changeset 139:d5d1549e47fb

Change how settings are restored and saved.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 Aug 2017 12:12:21 +0300
parents 5e6bcabfa380
children 783417da6da3
files src/main.cpp
diffstat 1 files changed, 28 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- 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()