| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import QtQuick 2.9
- import QtQuick.Controls 2.2
- import Qt.labs.settings 1.0
- ApplicationWindow {
- id: window
- visible: true
- width: 640
- height: 480
- title: qsTr("Stack")
- Settings {
- id: settings
- property string serviceUrl: ""
- }
- LightsModel {
- id: lightsModel
- serviceUrl: settings.serviceUrl
- onError: (text) => stackView.showError(text)
- }
- header: ToolBar {
- contentHeight: 36
- MenuBackButton {
- id: menuButton
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- anchors.leftMargin: 8
- width: 24
- height: 24
- state: stackView.depth > 1 ? "back" : "menu"
- onClicked: {
- drawer.open()
- }
- onBack: {
- stackView.pop()
- }
- }
- Label {
- text: stackView.currentItem.title
- anchors.centerIn: parent
- }
- }
- Drawer {
- id: drawer
- width: window.width * 0.66
- height: window.height
- Column {
- anchors.fill: parent
- Row {
- width: parent.width
- height: 100
- Image {
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.margins: 10
- source: "lamp.png"
- }
- Label {
- anchors.verticalCenter: parent.verticalCenter
- font.pointSize: 20
- text: qsTr("nooLight v0.1")
- }
- }
- ItemDelegate {
- text: qsTr("Service")
- width: parent.width
- onClicked: {
- stackView.openPage("ServiceForm.qml")
- }
- }
- ItemDelegate {
- text: qsTr("Settings")
- width: parent.width
- onClicked: {
- stackView.openPage("SettingsForm.qml")
- }
- }
- ItemDelegate {
- text: qsTr("Quit")
- width: parent.width
- onClicked: {
- Qt.quit()
- }
- }
- }
- }
- StackView {
- id: stackView
- initialItem: "HomeForm.qml"
- anchors.fill: parent
- function openPage(page) {
- if (depth > 1) {
- pop()
- }
- push(page)
- drawer.close()
- }
- function showError(text) {
- ToolTip.show(text, 1000)
- }
- }
- onClosing: {
- if (stackView.depth > 1) {
- close.accepted = false
- stackView.pop()
- }
- }
- }
|