MainMenu component was added

This commit is contained in:
2023-03-30 11:01:39 +02:00
parent 44dd3cdb58
commit b0646ff112
4 changed files with 80 additions and 35 deletions

View File

@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
<name>MainMenu</name>
<message>
<location filename="qml/Components/MainMenu.qml" line="34"/>
<source>BeerLog v0.1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>main</name>
<message>
@@ -9,18 +17,18 @@
<translation></translation>
</message>
<message>
<location filename="qml/main.qml" line="77"/>
<location filename="qml/main.qml" line="66"/>
<source>BeerLog v0.1</source>
<oldsource>BeerLog v1.0.0</oldsource>
<translation></translation>
</message>
<message>
<location filename="qml/main.qml" line="82"/>
<location filename="qml/main.qml" line="70"/>
<source>Settings</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="qml/main.qml" line="88"/>
<location filename="qml/main.qml" line="74"/>
<source>Quit</source>
<translation>Выход</translation>
</message>

View File

@@ -0,0 +1,49 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
Drawer {
property alias logo: logoImage.source
property alias appName: appNameLabel.text
property alias model: menuRepeater.model
signal actionSelected(var action)
width: parent.width * 0.66
height: parent.height
Column {
anchors.fill: parent
Row {
width: parent.width
height: 100
Image {
id: logoImage
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 10
}
Label {
id: appNameLabel
anchors.verticalCenter: parent.verticalCenter
font.pointSize: 20
text: qsTr("BeerLog v0.1")
}
}
Repeater {
id: menuRepeater
delegate: ItemDelegate {
width: parent.width
text: model.title
onClicked: actionSelected(model.action)
}
}
}
}

View File

@@ -18,7 +18,7 @@ ApplicationWindow {
anchors.fill: parent
MenuBackButton {
state: "menu"//stackView.depth > 1 ? "back" : "menu"
onClicked: drawer.open()
onClicked: mainMenu.open()
onBack: {
state = "menu"
}
@@ -51,44 +51,31 @@ ApplicationWindow {
}
}
Drawer {
id: drawer
MainMenu {
id: mainMenu
readonly property var actions: {
"settings": () => { stackView.openPage("SettingsForm.qml") },
"quit": () => { Qt.quit() }
}
width: parent.width * 0.66
height: parent.height
Column {
anchors.fill: parent
logo: "qrc:/logo.png"
appName: qsTr("BeerLog v0.1")
Row {
width: parent.width
height: 100
Image {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 10
source: "logo.png"
}
Label {
anchors.verticalCenter: parent.verticalCenter
font.pointSize: 20
text: qsTr("BeerLog v0.1")
}
model: ListModel {
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]()
}
}

View File

@@ -5,5 +5,6 @@
<file>qtquickcontrols2.conf</file>
<file>logo.png</file>
<file>beerlog_ru_RU.qm</file>
<file>Components/MainMenu.qml</file>
</qresource>
</RCC>