Permalink
Browse files

Added Settings Page. All it contains for now is an experimental "Defa…

…ult Line" selector.

Added U1DB persistence for the default line.
  • Loading branch information...
Aaron Hastings
Aaron Hastings committed Dec 18, 2014
1 parent d0ed98f commit f9dc00a3a26e98bc88067f39734c876682368c6f
Showing with 80 additions and 24 deletions.
  1. +10 −0 uLuas.qml
  2. +1 −0 ui/AboutPopover.qml
  3. +17 −24 ui/LinePage.qml
  4. +52 −0 ui/SettingsPage.qml
@@ -38,6 +38,16 @@ MainView {
path: "uluas.u1db"
}

U1db.Document {
id: defaultLine
database: db
docId: "defaultLine"
create: true
defaults: {
lineName: "Red Line"
}
}

U1db.Document {
id: redLineLastStop
database: db
@@ -63,6 +63,7 @@ Component {
}

text: "uLuas logo by Sam Hewitt (<a href=\"http://snwh.org\">snwh</a>)"
color: "#000000"

onLinkActivated: Qt.openUrlExternally(link)
}
@@ -12,14 +12,20 @@ Page {
Component.onCompleted: {
// For each tab, load the appropriate model and U1DB database.
if (parent.objectName === "redLineTab") {
lineModel = redLineModel;
lastStop = redLineLastStop;
lineModel = redLineModel
lastStop = redLineLastStop
}
else if (parent.objectName === "greenLineTab") {
lineModel = greenLineModel;
lastStop = greenLineLastStop;
lineModel = greenLineModel
lastStop = greenLineLastStop
}

// Start by loading the tab based on the user's selected default line.
if (defaultLine.contents.lineName === "Green Line")
tabs.selectedTabIndex = 1
else
tabs.selectedTabIndex = 0

// Always begin by loading the selected stop.
activityIndicator.running = true
stopSelector.selectedIndex = getLastStopIndex(lastStop.contents.stopName, lineModel)
@@ -69,18 +75,18 @@ Page {
}
},
Action {
id: aboutAction
id: settingsAction

iconName: "help"
text: "About"
iconName: "settings"
text: "Settings"

onTriggered: PopupUtils.open(aboutPopover)
onTriggered: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
},
Action {
id: settingsAction
id: aboutAction

iconName: "settings"
text: "Settings"
iconName: "help"
text: "About"

onTriggered: PopupUtils.open(aboutPopover)
}
@@ -445,17 +451,4 @@ Page {
ListElement { name: "Cherrywood"; description: ""; image: "../img/blank.png" }
ListElement { name: "Brides Glen"; description: ""; image: "../img/blank.png" }
}

// tools: GlobalTools {
// ToolbarButton {
// id: reloadButton

// text: "Reload"
// iconSource: "../img/reload.png"
// onTriggered: {
// activityIndicator.running = true
// queryStopTimesWorker.sendMessage({'stop': lineModel.get(stopSelector.selectedIndex).name})
// }
// }
// }
}
@@ -0,0 +1,52 @@
import QtQuick 2.0
import Ubuntu.Components 1.1

Page {
id: settingsPage

title: i18n.tr("Settings")

// Default to Red Line on initial startup.
property string defaultLineSelection: "Red Line"

Column {
id: settingsColumn

anchors {
top: parent.top
left: parent.left
right: parent.right

topMargin: units.gu(4)
margins: units.gu(2)
}

Label {
id: selectStopLabel

text: "<b>Default Line:</b>"
}

OptionSelector {
id: defaultLineSelector

anchors {
topMargin: units.gu(1)
}

containerHeight: units.gu(21.5)
expanded: true
model: ["Red Line", "Green Line"]

onSelectedIndexChanged: {
if (selectedIndex === 1)
defaultLineSelection = "Green Line"
else
defaultLineSelection = "Red Line"

// Save stop to U1DB backend for persistence.
defaultLine.contents = {lineName: defaultLineSelection}
}
}
}
}

0 comments on commit f9dc00a

Please sign in to comment.