added functionality to show gps location on first start
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Tue, 25 May 2010 07:43:24 +0000 (10:43 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Tue, 25 May 2010 07:43:24 +0000 (10:43 +0300)
src/engine/engine.cpp
src/engine/engine.h

index 2df601f..cc24ab5 100644 (file)
@@ -80,19 +80,7 @@ SituareEngine::SituareEngine(QMainWindow *parent)
     m_mapEngine->init();
     m_ui->show();
 
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
-    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
-
-    // set features on / off based on settings
-    changeAutoCenteringSetting(autoCenteringEnabled.toBool());
-    enableGPS(gpsEnabled.toBool());
-
-    // show messages at startup if features are enabled automatically
-    if (gpsEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("GPS enabled"));
-    if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+    initializeGpsAndAutocentering();
 
     m_facebookAuthenticator->start();
 }
@@ -167,6 +155,38 @@ void SituareEngine::fetchUsernameFromSettings()
     m_ui->setUsername(m_facebookAuthenticator->loadUsername());
 }
 
+void SituareEngine::initializeGpsAndAutocentering()
+{
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
+    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
+
+    qWarning() << "State of GPS: " << gpsEnabled.toString() << "boolina: " << gpsEnabled.toBool();
+
+     // set features on / off based on settings
+
+    if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
+        changeAutoCenteringSetting(true);
+        enableGPS(true);
+        m_ui->showMaemoInformationBox(tr("GPS enabled"));
+        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+        //settings.setValue(SETTINGS_GPS_ENABLED, true);
+        //settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, true);
+        //set zoom level
+        qWarning() << "first start";
+    }
+
+    else { // Normal start
+        changeAutoCenteringSetting(autoCenteringEnabled.toBool());
+        enableGPS(gpsEnabled.toBool());
+        if (gpsEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("GPS enabled"));
+        if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+        qWarning() << "normal start";
+    } 
+}
+
 void SituareEngine::loginOk(bool freshLogin)
 {
     qDebug() << __PRETTY_FUNCTION__;
index d0cfa69..73aa802 100644 (file)
@@ -124,6 +124,7 @@ public slots:
     void userDataChanged(User *user, QList<User *> &friendsList);
 
 private:
+    void initializeGpsAndAutocentering();
     /**
       * @brief Connect signals coming from Facdebook authenticator
       */