Переход на использование модуля с компонентами
This commit is contained in:
73
main.qml
73
main.qml
@@ -2,6 +2,8 @@ import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
import ru.ded.components 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
|
||||
@@ -34,13 +36,10 @@ ApplicationWindow {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
state: stackView.depth > 1 ? "back" : "menu"
|
||||
|
||||
onClicked: {
|
||||
drawer.open()
|
||||
mainMenu.open()
|
||||
}
|
||||
|
||||
onBack: {
|
||||
@@ -54,56 +53,34 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Drawer {
|
||||
id: drawer
|
||||
width: window.width * 0.66
|
||||
height: window.height
|
||||
MainMenu {
|
||||
id: mainMenu
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
readonly property var actions: {
|
||||
"service": () => { stackView.openPage("ServiceForm.qml") },
|
||||
"settings": () => { stackView.openPage("SettingsForm.qml") },
|
||||
"quit": () => { Qt.quit() }
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
height: 100
|
||||
logo: "qrc:/lamp.png"
|
||||
appName: qsTr("nooLight v1.0")
|
||||
|
||||
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")
|
||||
}
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
title: qsTr("Service")
|
||||
action: "service"
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Service")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
stackView.openPage("ServiceForm.qml")
|
||||
}
|
||||
ListElement {
|
||||
title: qsTr("Settings")
|
||||
action: "settings"
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Settings")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
stackView.openPage("SettingsForm.qml")
|
||||
}
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
text: qsTr("Quit")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
Qt.quit()
|
||||
}
|
||||
ListElement {
|
||||
title: qsTr("Quit")
|
||||
action: "quit"
|
||||
}
|
||||
}
|
||||
|
||||
onActionSelected: (action) => actions[action]()
|
||||
}
|
||||
|
||||
StackView {
|
||||
@@ -117,7 +94,7 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
push(page)
|
||||
drawer.close()
|
||||
mainMenu.close()
|
||||
}
|
||||
|
||||
function showError(text) {
|
||||
|
||||
Reference in New Issue
Block a user