106 lines
2.2 KiB
QML
106 lines
2.2 KiB
QML
import QtQuick 2.9
|
|
import QtQuick.Controls 2.2
|
|
|
|
import ru.ded.noolight 1.0
|
|
import ru.ded.components 1.0
|
|
|
|
ApplicationWindow {
|
|
id: window
|
|
|
|
visible: true
|
|
width: 640
|
|
height: 480
|
|
title: qsTr("Stack")
|
|
|
|
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
|
|
|
|
state: stackView.depth > 1 ? "back" : "menu"
|
|
|
|
onClicked: {
|
|
mainMenu.open()
|
|
}
|
|
|
|
onBack: {
|
|
stackView.pop()
|
|
}
|
|
}
|
|
|
|
Label {
|
|
text: stackView.currentItem.title
|
|
anchors.centerIn: parent
|
|
}
|
|
}
|
|
|
|
MainMenu {
|
|
id: mainMenu
|
|
|
|
readonly property var actions: {
|
|
"service": () => { stackView.openPage("ServiceForm.qml") },
|
|
"settings": () => { stackView.openPage("SettingsForm.qml") },
|
|
"quit": () => { Qt.quit() }
|
|
}
|
|
|
|
logo: "/images/lamp.png"
|
|
appName: qsTr("nooLight v1.0")
|
|
|
|
model: ListModel {
|
|
ListElement {
|
|
title: qsTr("Service")
|
|
action: "service"
|
|
}
|
|
ListElement {
|
|
title: qsTr("Settings")
|
|
action: "settings"
|
|
}
|
|
ListElement {
|
|
title: qsTr("Quit")
|
|
action: "quit"
|
|
}
|
|
}
|
|
|
|
onActionSelected: (action) => actions[action]()
|
|
}
|
|
|
|
StackView {
|
|
id: stackView
|
|
initialItem: "HomeForm.qml"
|
|
anchors.fill: parent
|
|
|
|
function openPage(page) {
|
|
if (depth > 1) {
|
|
pop()
|
|
}
|
|
|
|
push(page)
|
|
mainMenu.close()
|
|
}
|
|
|
|
function showError(text) {
|
|
ToolTip.show(text, 1000)
|
|
}
|
|
}
|
|
|
|
onClosing: (close) => {
|
|
if (stackView.depth > 1) {
|
|
close.accepted = false
|
|
stackView.pop()
|
|
}
|
|
}
|
|
}
|