magpie/qml/Application/Main.qml

90 lines
2.4 KiB
QML

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item {
signal addAsset()
signal removeAsset(id: int)
signal editAsset(id: int)
property string currentPage: "home"
RowLayout {
anchors.fill: parent
Column {
id: menu
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.preferredWidth: 100
Layout.maximumWidth: 100
Layout.alignment: Qt.AlignTop
MenuItem {
width: parent.width
text: qsTr("Home")
icon.name: "home"
highlighted: currentPage === "home"
onTriggered: {
if (!this.highlighted)
content.replace(home)
}
}
MenuItem {
width: parent.width
text: qsTr("Assets")
icon.name: "document-properties"
highlighted: currentPage === "assets"
onTriggered: {
if (!this.highlighted)
content.replace(assets)
}
}
MenuItem {
width: parent.width
text: qsTr("Records")
icon.name: "system-search"
highlighted: currentPage === "records"
onTriggered: {
if (!this.highlighted)
content.replace(records)
}
}
}
StackView {
id: content
initialItem: home
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
Component {
id: home
Home {
StackView.onActivating: currentPage = "home"
}
}
Component {
id: assets
Assets {
StackView.onActivating: currentPage = "assets"
onAdd: addAsset()
onRemove: id => removeAsset(id)
onEdit: id => editAsset(id)
}
}
Component {
id: records
Records {
StackView.onActivating: currentPage = "records"
}
}
}
}
}