Advertisement
Guest User

Routes.qml

a guest
Jul 21st, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
q/kdb+ 3.63 KB | None | 0 0
  1. import QtQuick 2.0
  2. import Sailfish.Silica 1.0
  3.  
  4.  
  5. Page {
  6.     id: page
  7.  
  8.     SilicaFlickable {
  9.         anchors.fill: parent
  10.         contentHeight: column.height
  11.  
  12.         Column {
  13.             id: column
  14.  
  15.             width: page.width
  16.             spacing: Theme.paddingLarge
  17.             PageHeader {
  18.                 title: qsTr("Routes")
  19.             }
  20.             TextField {
  21.                 id: from
  22.                 focus: true
  23.                 width: parent.width
  24.                 label: "From"
  25.                 placeholderText: "From"
  26.                 EnterKey.onClicked: {
  27.                     to.focus = true;
  28.                 }
  29.             }
  30.             IconButton {
  31.                 function swapFromAndTo() {
  32.                     var fromText = from.text
  33.                     from.text = to.text
  34.                     to.text = fromText
  35.                 }
  36.  
  37.                 id: swap
  38.                 anchors.horizontalCenter: parent.horizontalCenter
  39.                 icon.source: "image://theme/icon-m-pause"
  40.                 onClicked: swapFromAndTo()
  41.             }
  42.             TextField {
  43.                 id: to
  44.                 width: parent.width
  45.                 label: "To"
  46.                 placeholderText: "To"
  47.                 EnterKey.onClicked: {
  48.                     timePicker.focus = true;
  49.                 }
  50.             }
  51.  
  52.             Row {
  53.                 id: dateTime
  54.                 spacing: Theme.paddingLarge
  55.                 anchors.horizontalCenter: parent.horizontalCenter
  56.  
  57.                 ValueButton {
  58.                     id: datePicker
  59.                     label: "Date"
  60.                     width: dateTime.width/2
  61.                     value: Qt.formatDate( new Date(), 'dd/M/yyyy')
  62.  
  63.                     onClicked: {
  64.                         var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", {
  65.                             date: value
  66.                         })
  67.                         dialog.accepted.connect(function() {
  68.                             value = dialog.dateText
  69.                         })
  70.                     }
  71.                 }
  72.  
  73.                 ValueButton {
  74.                     id: timePicker
  75.                     label: "Time"
  76.                     width: dateTime.width/2
  77.                     value: Qt.formatTime( new Date(), 'hh:mm')
  78.  
  79.                     onClicked: {
  80.                         var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", {
  81.                             hour: Qt.formatTime( new Date(), 'hh'),
  82.                             minute: Qt.formatTime( new Date(), 'mm'),
  83.                             hourMode: DateTime.TwentyFourHours
  84.                         })
  85.                         dialog.accepted.connect(function() {
  86.                             value = dialog.timeText
  87.                         })
  88.                     }
  89.                 }
  90.             }
  91.  
  92.             Row {
  93.                 id: arrivalToggle
  94.                 spacing: Theme.paddingLarge
  95.                 anchors.horizontalCenter: parent.horizontalCenter
  96.  
  97.                 Button {
  98.                     id: departure
  99.                     text: "Departure"
  100.  
  101.                     onClicked: {
  102.                         arrival.down = false;
  103.                     }
  104.                 }
  105.  
  106.                 Button {
  107.                     id: arrival
  108.                     text: "Arrival"
  109.  
  110.                     onClicked: {
  111.                         departure.down = false;
  112.                     }
  113.                 }
  114.             }
  115.             Button {
  116.                 id: search
  117.                 anchors.horizontalCenter: parent.horizontalCenter
  118.                 text: "Search"
  119.             }
  120.         }
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement