Menu {
id: menu
content: MenuLayout {
+
MenuItem {
text: qsTr("Update Periodically")
Switch {
right: parent.right
rightMargin: UiConstants.DefaultMargin
}
+ checked: settings.autoUpdate
}
+ onClicked: settings.autoUpdate ^= true
}
MenuItem {
text: qsTr("About Quando Parte")
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
- }
- }
- }
- }
- }
}
#include "settings.h"
+#include <QApplication>
#include <QDebug>
#include <QSettings>
#include <QStringList>
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;
qDebug() << "StationListSortingMode set to" << mode;
emit stationListSortingModeChanged();
}
+
+QString Settings::versionString()
+{
+ return qApp->applicationVersion();
+}
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();
int checkingInterval();
void setCheckingInterval(int);
+ bool autoUpdate();
+ void setAutoUpdate(bool);
+
bool stationViewPreferred();
void setStationViewPreferred(bool);
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();