Implemented AutoUpdate
authorLuciano Montanaro <mikelima@cirulla.net>
Mon, 9 Jan 2012 00:41:33 +0000 (01:41 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Mon, 9 Jan 2012 00:41:33 +0000 (01:41 +0100)
application/resources/harmattan/qml/StationListPage.qml
application/settings.cpp
application/settings.h

index c676d1b..4f1244a 100644 (file)
@@ -16,6 +16,7 @@ Page {
     Menu {
         id: menu
         content: MenuLayout {
+
             MenuItem {
                 text: qsTr("Update Periodically")
                 Switch {
@@ -25,7 +26,9 @@ Page {
                         right: parent.right
                         rightMargin: UiConstants.DefaultMargin
                     }
+                    checked: settings.autoUpdate
                 }
+                onClicked: settings.autoUpdate ^= true
             }
             MenuItem {
                 text: qsTr("About Quando Parte")
@@ -134,38 +137,5 @@ Page {
             flickableItem: stationListView
         }
     }
-
-    Sheet {
-        id: settingsSheet
-        acceptButtonText: qsTr("Save")
-        rejectButtonText: qsTr("Cancel")
-        content: Item {
-            x: 16
-            y: 16
-            width: parent.width - 32
-            height: parent.height - 32
-            Column {
-                spacing: 16
-                anchors.fill: parent
-                Item {
-                    height: 40
-                    anchors.leftMargin: UiConstants.DefaultMargin
-                    anchors.left: parent.left
-                    anchors.right: parent.right
-                    Label {
-                        font.bold: true
-                        text: qsTr("Show Last Station on Startup")
-                        anchors.verticalCenter: parent.verticalCenter
-                        anchors.left: parent.left
-                    }
-                    Switch {
-                        anchors.verticalCenter: parent.verticalCenter
-                        id: showLastStationSwitch
-                        anchors.right: parent.right
-                    }
-                }
-            }
-        }
-    }
 }
 
index 20c6597..42d7663 100644 (file)
@@ -21,6 +21,7 @@ Boston, MA 02110-1301, USA.
 
 #include "settings.h"
 
+#include <QApplication>
 #include <QDebug>
 #include <QSettings>
 #include <QStringList>
@@ -99,6 +100,24 @@ void Settings::setCheckingInterval(int interval)
     emit checkingIntervalChanged();
 }
 
+bool Settings::autoUpdate()
+{
+    QSettings settings;
+
+    bool current = settings.value("AutoUpdate", false).toBool();
+    qDebug() << "AutoUpdate is" << current;
+    return current;
+}
+
+void Settings::setAutoUpdate(bool preference)
+{
+    QSettings settings;
+
+    settings.setValue("AutoUpdate", preference);
+    qDebug() << "AutoUpdate set to" << preference;
+    emit autoUpdateChanged();
+}
+
 bool Settings::stationViewPreferred()
 {
     QSettings settings;
@@ -146,3 +165,8 @@ void Settings::setStationListSortingMode(StationListProxyModel::SortingMode mode
     qDebug() << "StationListSortingMode set to" << mode;
     emit stationListSortingModeChanged();
 }
+
+QString Settings::versionString()
+{
+    return qApp->applicationVersion();
+}
index 67e4963..450268a 100644 (file)
@@ -40,16 +40,19 @@ class Settings : public QObject
     Q_PROPERTY(int checkingInterval
                READ checkingInterval WRITE setCheckingInterval
                NOTIFY checkingIntervalChanged)
+    Q_PROPERTY(bool autoUpdate
+               READ autoUpdate WRITE setAutoUpdate
+               NOTIFY autoUpdateChanged)
     Q_PROPERTY(bool stationViewPreferred
                READ stationViewPreferred WRITE setStationViewPreferred
                NOTIFY stationViewPreferredChanged)
     Q_PROPERTY(bool showArrivalsPreferred
                READ showArrivalsPreferred WRITE setShowArrivalsPreferred
                NOTIFY showArrivalsPreferredChanged)
-
     Q_PROPERTY(StationListProxyModel::SortingMode stationListSortingMode
                READ stationListSortingMode WRITE setStationListSortingMode
                NOTIFY stationListSortingModeChanged)
+    Q_PROPERTY(QString versionString READ versionString CONSTANT)
 public:
     explicit Settings(QObject *parent = 0);
     ~Settings();
@@ -66,6 +69,9 @@ public:
     int checkingInterval();
     void setCheckingInterval(int);
 
+    bool autoUpdate();
+    void setAutoUpdate(bool);
+
     bool stationViewPreferred();
     void setStationViewPreferred(bool);
 
@@ -75,10 +81,13 @@ public:
     StationListProxyModel::SortingMode stationListSortingMode();
     void setStationListSortingMode(StationListProxyModel::SortingMode mode);
 
+    QString versionString(void);
+
 signals:
     void queryBaseUrlChanged();
     void recentStationsChanged();
     void checkingIntervalChanged();
+    void autoUpdateChanged();
     void stationViewPreferredChanged();
     void showArrivalsPreferredChanged();
     void stationListSortingModeChanged();