main.qml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import QtQuick 2.9
  2. import QtQuick.Controls 2.2
  3. import Qt.labs.settings 1.0
  4. ApplicationWindow {
  5. id: window
  6. visible: true
  7. width: 640
  8. height: 480
  9. title: qsTr("Stack")
  10. Settings {
  11. id: settings
  12. property string serviceUrl: ""
  13. }
  14. header: ToolBar {
  15. contentHeight: 36
  16. MenuBackButton {
  17. id: menuButton
  18. anchors.verticalCenter: parent.verticalCenter
  19. anchors.left: parent.left
  20. anchors.leftMargin: 8
  21. width: 24
  22. height: 24
  23. state: stackView.depth > 1 ? "back" : "menu"
  24. onClicked: {
  25. drawer.open()
  26. }
  27. onBack: {
  28. stackView.pop()
  29. }
  30. }
  31. Label {
  32. text: stackView.currentItem.title
  33. anchors.centerIn: parent
  34. }
  35. }
  36. Drawer {
  37. id: drawer
  38. width: window.width * 0.66
  39. height: window.height
  40. Column {
  41. anchors.fill: parent
  42. Row {
  43. width: parent.width
  44. height: 100
  45. Image {
  46. anchors.top: parent.top
  47. anchors.bottom: parent.bottom
  48. anchors.margins: 10
  49. source: "lamp.png"
  50. }
  51. Label {
  52. anchors.verticalCenter: parent.verticalCenter
  53. font.pointSize: 20
  54. text: qsTr("nooLight v0.1")
  55. }
  56. }
  57. ItemDelegate {
  58. text: qsTr("Settings")
  59. width: parent.width
  60. onClicked: {
  61. if (stackView.depth > 1) {
  62. stackView.pop()
  63. }
  64. stackView.push("SettingsForm.qml")
  65. drawer.close()
  66. }
  67. }
  68. }
  69. }
  70. StackView {
  71. id: stackView
  72. initialItem: "HomeForm.qml"
  73. anchors.fill: parent
  74. }
  75. onClosing: {
  76. if (stackView.depth > 1) {
  77. close.accepted = false
  78. stackView.pop()
  79. }
  80. }
  81. }