magpie/qml/Application/Main.qml

107 lines
3.0 KiB
QML
Raw Normal View History

// 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)
2024-01-17 21:57:34 +00:00
property string currentPage: "home"
RowLayout {
anchors.fill: parent
Column {
id: menu
2024-04-08 22:46:26 +00:00
// Layout.fillWidth: true
// Layout.minimumWidth: 50
Layout.preferredWidth: children[3].implicitWidth
// Layout.maximumWidth: 100
Layout.alignment: Qt.AlignTop
MenuItem {
width: parent.width
text: qsTr("Home")
icon.name: "home"
highlighted: currentPage === "home"
onTriggered: {
2024-04-08 22:46:26 +00:00
if (!highlighted)
content.replace(home)
}
}
MenuItem {
width: parent.width
text: qsTr("Assets")
icon.name: "document-properties"
highlighted: currentPage === "assets"
onTriggered: {
2024-04-08 22:46:26 +00:00
if (!highlighted)
content.replace(assets)
}
}
MenuItem {
width: parent.width
text: qsTr("Records")
icon.name: "system-search"
highlighted: currentPage === "records"
onTriggered: {
2024-04-08 22:46:26 +00:00
if (!highlighted)
content.replace(records)
}
}
2024-04-08 22:46:26 +00:00
MenuItem {
width: parent.width
text: qsTr("Currencies")
icon.name: "format-currency"
highlighted: currentPage === "currencies"
onTriggered: {
if (!highlighted)
content.replace(currencies)
}
}
}
StackView {
id: content
initialItem: home
2024-01-17 21:57:34 +00:00
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
Component {
id: home
Home {
StackView.onActivating: currentPage = "home"
}
}
Component {
id: assets
Assets {
StackView.onActivating: currentPage = "assets"
2024-01-17 21:57:34 +00:00
onAdd: addAsset()
onRemove: id => removeAsset(id)
onEdit: id => editAsset(id)
}
}
Component {
id: records
Records {
StackView.onActivating: currentPage = "records"
}
}
2024-04-08 22:46:26 +00:00
Component {
id: currencies
Currencies {
StackView.onActivating: currentPage = "currencies"
}
}
}
}
}