1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Material
import Main
Drawer {
id: drawer
width: Math.min(0.66 * parent.width, 200)
height: parent.height
interactive: inPortrait || parent.width < 600
modal: interactive
position: initialPosition
visible: !interactive
CustomListView {
id: drawerListView
anchors.fill: parent
currentIndex: pageStack.currentIndex
footer: ColumnLayout {
spacing: 0
width: parent.width
ItemDelegate {
Layout.fillWidth: true
text: Qt.application.version
icon.source: App.faUrlBase + "info-circle"
icon.width: App.iconWidthDelegate
icon.height: App.iconSize
onClicked: aboutDialog.visible = true
}
ItemDelegate {
Layout.fillWidth: true
text: qsTr("Quit")
icon.source: App.faUrlBase + "power-off"
icon.width: App.iconWidthDelegate
icon.height: App.iconSize
onClicked: closeDialog.visible = true
}
}
model: ListModel {
ListElement {
name: qsTr("Start")
iconName: "home"
}
ListElement {
name: qsTr("Folders")
iconName: "folder"
}
ListElement {
name: qsTr("Devices")
iconName: "sitemap"
}
ListElement {
name: qsTr("Recent changes")
iconName: "history"
}
ListElement {
name: qsTr("Advanced")
iconName: "cogs"
}
ListElement {
name: qsTr("App settings")
iconName: "cog"
}
}
delegate: ItemDelegate {
id: drawerDelegate
text: name
activeFocusOnTab: true
highlighted: ListView.isCurrentItem
icon.source: App.faUrlBase + iconName
icon.width: App.iconWidthDelegate
icon.height: App.iconSize
width: drawerListView.width
onClicked: {
pageStack.setCurrentIndex(index);
drawer.position = drawer.initialPosition;
}
required property int index
required property string iconName
required property string name
}
}
required property PageStack pageStack
required property AboutDialog aboutDialog
required property CloseDialog closeDialog
readonly property bool inPortrait: parent.width < parent.height
readonly property double initialPosition: interactive ? 0 : 1
readonly property int effectiveWidth: !interactive ? width : 0
property alias currentItem: drawerListView.currentItem
}
|