Advertisement
Guest User

[Sailfishos] Dialog

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