magpie/qml/Application/Main.qml
2024-04-09 18:04:07 -03:00

128 lines
3.7 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.alignment: Qt.AlignTop
MenuItem {
width: Math.max(parent.implicitWidth, implicitWidth)
text: qsTr("Home")
icon.name: "home"
highlighted: currentPage === "home"
onTriggered: {
if (!highlighted)
content.replace(home)
}
}
MenuItem {
width: Math.max(parent.implicitWidth, implicitWidth)
text: qsTr("Assets")
icon.name: "document-properties"
highlighted: currentPage === "assets"
onTriggered: {
if (!highlighted)
content.replace(assets)
}
}
MenuItem {
width: Math.max(parent.implicitWidth, implicitWidth)
text: qsTr("Records")
icon.name: "system-search"
highlighted: currentPage === "records"
onTriggered: {
if (!highlighted)
content.replace(records)
}
}
MenuItem {
width: Math.max(parent.implicitWidth, implicitWidth)
text: qsTr("Currencies")
icon.name: "format-currency"
highlighted: currentPage === "currencies"
onTriggered: {
if (!highlighted)
content.replace(currencies)
}
}
}
StackView {
id: content
initialItem: home
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
Component {
id: home
Item {
StackView.onActivating: currentPage = "home"
Home {
anchors {
fill: parent
margins: 5
}
}
}
}
Component {
id: assets
Item {
StackView.onActivating: currentPage = "assets"
Assets {
anchors {
fill: parent
margins: 5
}
onAdd: addAsset()
onRemove: id => removeAsset(id)
onEdit: id => editAsset(id)
}
}
}
Component {
id: records
Item {
StackView.onActivating: currentPage = "records"
Records {
anchors {
fill: parent
margins: 5
}
}
}
}
Component {
id: currencies
Item {
StackView.onActivating: currentPage = "currencies"
Currencies {
anchors {
fill: parent
margins: 5
}
}
}
}
}
}
}