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"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="ru_RU"> <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> <context>
<name>main</name> <name>main</name>
<message> <message>
@@ -9,18 +17,18 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="qml/main.qml" line="77"/> <location filename="qml/main.qml" line="66"/>
<source>BeerLog v0.1</source> <source>BeerLog v0.1</source>
<oldsource>BeerLog v1.0.0</oldsource> <oldsource>BeerLog v1.0.0</oldsource>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="qml/main.qml" line="82"/> <location filename="qml/main.qml" line="70"/>
<source>Settings</source> <source>Settings</source>
<translation>Настройки</translation> <translation>Настройки</translation>
</message> </message>
<message> <message>
<location filename="qml/main.qml" line="88"/> <location filename="qml/main.qml" line="74"/>
<source>Quit</source> <source>Quit</source>
<translation>Выход</translation> <translation>Выход</translation>
</message> </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 anchors.fill: parent
MenuBackButton { MenuBackButton {
state: "menu"//stackView.depth > 1 ? "back" : "menu" state: "menu"//stackView.depth > 1 ? "back" : "menu"
onClicked: drawer.open() onClicked: mainMenu.open()
onBack: { onBack: {
state = "menu" state = "menu"
} }
@@ -51,44 +51,31 @@ ApplicationWindow {
} }
} }
Drawer { MainMenu {
id: drawer id: mainMenu
readonly property var actions: {
"settings": () => { stackView.openPage("SettingsForm.qml") },
"quit": () => { Qt.quit() }
}
width: parent.width * 0.66 width: parent.width * 0.66
height: parent.height height: parent.height
Column { logo: "qrc:/logo.png"
anchors.fill: parent appName: qsTr("BeerLog v0.1")
Row { model: ListModel {
width: parent.width ListElement {
height: 100 title: qsTr("Settings")
action: "settings"
Image {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 10
source: "logo.png"
} }
ListElement {
Label { title: qsTr("Quit")
anchors.verticalCenter: parent.verticalCenter action: "quit"
font.pointSize: 20
text: qsTr("BeerLog v0.1")
} }
} }
ItemDelegate { onActionSelected: (action) => actions[action]()
text: qsTr("Settings")
width: parent.width
onClicked: stackView.openPage("SettingsForm.qml")
}
ItemDelegate {
text: qsTr("Quit")
width: parent.width
onClicked: Qt.quit()
}
}
} }
} }

View File

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