Advertisement
Guest User

Untitled

a guest
Oct 4th, 2014
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.0
  2. import Sailfish.Silica 1.0
  3.  
  4.  
  5. Dialog {
  6. id: inputDialog
  7. canAccept: !title.errorHighlight && !description.errorHighlight
  8.  
  9. property string m_title
  10. property string m_description
  11. property string m_date
  12.  
  13. Column {
  14. anchors.fill: parent
  15.  
  16. DialogHeader {}
  17.  
  18. ValueButton {
  19. id: date
  20. label: "Date:"
  21. value: new Date()
  22. description: "Default value: ..."
  23.  
  24. onClicked: {
  25. var dialog = pageStack.push(pickerComponent, {
  26. date: new Date()
  27. })
  28. dialog.accepted.connect(function() {
  29. date.value = dialog.dateText
  30. })
  31. }
  32.  
  33. Component {
  34. id: pickerComponent
  35. DatePickerDialog {}
  36. }
  37. }
  38.  
  39. TextField {
  40. id: title
  41. width: inputDialog.width
  42. placeholderText: qsTr("Enter title")
  43. description: qsTr("Title")
  44. errorHighlight: text.length == 0
  45. EnterKey.enabled: text || inputMethodComposing
  46. EnterKey.iconSource: "image://theme/icon-m-enter-next"
  47. EnterKey.onClicked: description.focus = true
  48. }
  49.  
  50. TextField {
  51. id: description
  52. width: inputDialog.width
  53. placeholderText: qsTr("Enter description")
  54. description: qsTr("Description")
  55. errorHighlight: text.length == 0
  56. EnterKey.enabled: text || inputMethodComposing
  57. EnterKey.highlighted: !errorHighlight
  58. EnterKey.iconSource: "image://theme/icon-m-enter-next"
  59. EnterKey.onClicked: {
  60. if (!inputDialog.canAccept)
  61. title.focus = true
  62. else
  63. inputDialog.accept()
  64. }
  65. }
  66. }
  67.  
  68. onDone: {
  69. if (result == DialogResult.Accepted) {
  70. m_title = title.text
  71. console.log(m_title)
  72. m_description = description.text
  73. console.log(m_description)
  74. m_date = date.value
  75. console.log(m_date)
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement