experiments

This commit is contained in:
Blue 2024-04-08 19:46:26 -03:00
parent 4ed280a550
commit 9b7cea725f
Signed by: blue
GPG Key ID: 9B203B252A63EE38
5 changed files with 197 additions and 11 deletions

View File

@ -4,6 +4,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Qt.labs.qmlmodels
import magpie import magpie
import magpie.Components as Components import magpie.Components as Components
@ -21,7 +22,8 @@ Item {
Label { Label {
id: label id: label
text: "This is Assets screen" text: "Assets"
Layout.alignment: Qt.AlignHCenter
font { font {
pixelSize: 24 pixelSize: 24
bold: true bold: true
@ -34,13 +36,85 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
model: Magpie.assets model: Magpie.assets
spacing: 5 spacing: 5
delegate: Components.AssetLine { delegate: Components.AssetLine {
height: 30 height: 40
width: listView.width width: listView.width
onRemove: id => item.remove(id) onRemove: id => item.remove(id)
onEdit: id => item.edit(id) onEdit: id => item.edit(id)
} }
// model: TableModel {
// TableModelColumn { display: "icon"; decoration: "color" }
// TableModelColumn { display: "title" }
// TableModelColumn { display: "balance" }
// TableModelColumn { display: "currency" }
// TableModelColumn { display: "assetID" }
// TableModelColumn { display: "assetID" }
// }
// delegate: DelegateChooser {
// property int iconSize: 40
// DelegateChoice {
// column: 0
// delegate: Rectangle {
// implicitWidth: iconSize
// implicitHeight: iconSize
// color: model.decoration
// Components.Icon {
// anchors.fill: parent
// anchors.margins: 2
// iconName: model.display
// color: pickColor(model.decoration)
// }
// }
// }
// DelegateChoice {
// column: 1
// delegate: Label {
// text: model.display
// verticalAlignment: Text.AlignVCenter
// font.bold: true
// }
// }
// DelegateChoice {
// column: 2
// delegate: Label {
// text: model.display
// verticalAlignment: Text.AlignVCenter
// }
// }
// DelegateChoice {
// column: 3
// delegate: Label {
// text: model.display
// verticalAlignment: Text.AlignVCenter
// }
// }
// DelegateChoice {
// column: 4
// delegate: Button {
// text: qsTr("Edit")
// icon.name: "entry-edit"
// flat: true
// onClicked: edit(model.display)
// }
// }
// DelegateChoice {
// column: 5
// delegate: Button {
// text: qsTr("Delete")
// icon.name: "delete"
// onClicked: remove(model.display)
// palette { //unfortunately doesn't work anymore
// button: "red"
// }
// }
// }
// }
} }
} }

View File

@ -14,6 +14,7 @@ qt_add_qml_module(magpieApplication
Home.qml Home.qml
Assets.qml Assets.qml
Records.qml Records.qml
Currencies.qml
) )
target_link_libraries(magpie PRIVATE magpieApplication) target_link_libraries(magpie PRIVATE magpieApplication)

View File

@ -0,0 +1,94 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import magpie
import magpie.Components as Components
Item {
ColumnLayout {
id: column
anchors.fill: parent
Label {
id: label
text: "Currencies"
Layout.alignment: Qt.AlignHCenter
font {
pixelSize: 24
bold: true
}
}
RowLayout {
spacing: 5
Label {
text: "Main currency:"
Layout.alignment: Qt.AlignVCenter
}
ComboBox {
property int currency: 1
id: currencyField
textRole: "code"
valueRole: "id"
model: Magpie.currencies
Component.onCompleted: currentIndex = indexOfValue(currency)
onActivated: index => currency = currentValue
}
}
ListView {
id: listView
Layout.fillHeight: true
Layout.fillWidth: true
model: Magpie.currencies
spacing: 5
delegate: Item {
required property string title
required property string code
required property double value
id: line
height: 40
width: listView.width
RowLayout {
anchors.fill: parent
Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: code
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.bold: true
}
Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: value
verticalAlignment: Text.AlignVCenter
font.bold: true
font.underline: true
}
Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: title
verticalAlignment: Text.AlignVCenter
}
}
}
}
}
}

View File

@ -16,10 +16,10 @@ Item {
Column { Column {
id: menu id: menu
Layout.fillWidth: true // Layout.fillWidth: true
Layout.minimumWidth: 50 // Layout.minimumWidth: 50
Layout.preferredWidth: 100 Layout.preferredWidth: children[3].implicitWidth
Layout.maximumWidth: 100 // Layout.maximumWidth: 100
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
MenuItem { MenuItem {
@ -28,7 +28,7 @@ Item {
icon.name: "home" icon.name: "home"
highlighted: currentPage === "home" highlighted: currentPage === "home"
onTriggered: { onTriggered: {
if (!this.highlighted) if (!highlighted)
content.replace(home) content.replace(home)
} }
} }
@ -38,7 +38,7 @@ Item {
icon.name: "document-properties" icon.name: "document-properties"
highlighted: currentPage === "assets" highlighted: currentPage === "assets"
onTriggered: { onTriggered: {
if (!this.highlighted) if (!highlighted)
content.replace(assets) content.replace(assets)
} }
} }
@ -48,12 +48,22 @@ Item {
icon.name: "system-search" icon.name: "system-search"
highlighted: currentPage === "records" highlighted: currentPage === "records"
onTriggered: { onTriggered: {
if (!this.highlighted) if (!highlighted)
content.replace(records) content.replace(records)
} }
} }
}
MenuItem {
width: parent.width
text: qsTr("Currencies")
icon.name: "format-currency"
highlighted: currentPage === "currencies"
onTriggered: {
if (!highlighted)
content.replace(currencies)
}
}
}
StackView { StackView {
id: content id: content
initialItem: home initialItem: home
@ -84,6 +94,13 @@ Item {
StackView.onActivating: currentPage = "records" StackView.onActivating: currentPage = "records"
} }
} }
Component {
id: currencies
Currencies {
StackView.onActivating: currentPage = "currencies"
}
}
} }
} }
} }

View File

@ -79,7 +79,7 @@ Item {
ComboBox { ComboBox {
id: currencyField id: currencyField
textRole: "title" //"code" textRole: "code"
valueRole: "id" valueRole: "id"
model: Magpie.currencies model: Magpie.currencies