From 9b7cea725fea17af92d07a4ea6387916295a66b6 Mon Sep 17 00:00:00 2001 From: blue Date: Mon, 8 Apr 2024 19:46:26 -0300 Subject: [PATCH] experiments --- qml/Application/Assets.qml | 78 +++++++++++++++++++++++++++- qml/Application/CMakeLists.txt | 1 + qml/Application/Currencies.qml | 94 ++++++++++++++++++++++++++++++++++ qml/Application/Main.qml | 33 +++++++++--- qml/Forms/Asset.qml | 2 +- 5 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 qml/Application/Currencies.qml diff --git a/qml/Application/Assets.qml b/qml/Application/Assets.qml index fbfd17a..2c2d6ca 100644 --- a/qml/Application/Assets.qml +++ b/qml/Application/Assets.qml @@ -4,6 +4,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import Qt.labs.qmlmodels import magpie import magpie.Components as Components @@ -21,7 +22,8 @@ Item { Label { id: label - text: "This is Assets screen" + text: "Assets" + Layout.alignment: Qt.AlignHCenter font { pixelSize: 24 bold: true @@ -34,13 +36,85 @@ Item { Layout.fillWidth: true model: Magpie.assets spacing: 5 + delegate: Components.AssetLine { - height: 30 + height: 40 width: listView.width onRemove: id => item.remove(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" + // } + // } + // } + // } } } diff --git a/qml/Application/CMakeLists.txt b/qml/Application/CMakeLists.txt index bc7389b..870a43a 100644 --- a/qml/Application/CMakeLists.txt +++ b/qml/Application/CMakeLists.txt @@ -14,6 +14,7 @@ qt_add_qml_module(magpieApplication Home.qml Assets.qml Records.qml + Currencies.qml ) target_link_libraries(magpie PRIVATE magpieApplication) diff --git a/qml/Application/Currencies.qml b/qml/Application/Currencies.qml new file mode 100644 index 0000000..b02a089 --- /dev/null +++ b/qml/Application/Currencies.qml @@ -0,0 +1,94 @@ +// SPDX-FileCopyrightText: 2023 Yury Gubich +// 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 + } + } + } + } + } +} diff --git a/qml/Application/Main.qml b/qml/Application/Main.qml index c457263..901ee2c 100644 --- a/qml/Application/Main.qml +++ b/qml/Application/Main.qml @@ -16,10 +16,10 @@ Item { Column { id: menu - Layout.fillWidth: true - Layout.minimumWidth: 50 - Layout.preferredWidth: 100 - Layout.maximumWidth: 100 + // Layout.fillWidth: true + // Layout.minimumWidth: 50 + Layout.preferredWidth: children[3].implicitWidth + // Layout.maximumWidth: 100 Layout.alignment: Qt.AlignTop MenuItem { @@ -28,7 +28,7 @@ Item { icon.name: "home" highlighted: currentPage === "home" onTriggered: { - if (!this.highlighted) + if (!highlighted) content.replace(home) } } @@ -38,7 +38,7 @@ Item { icon.name: "document-properties" highlighted: currentPage === "assets" onTriggered: { - if (!this.highlighted) + if (!highlighted) content.replace(assets) } } @@ -48,12 +48,22 @@ Item { icon.name: "system-search" highlighted: currentPage === "records" onTriggered: { - if (!this.highlighted) + if (!highlighted) content.replace(records) } } - } + 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 @@ -84,6 +94,13 @@ Item { StackView.onActivating: currentPage = "records" } } + + Component { + id: currencies + Currencies { + StackView.onActivating: currentPage = "currencies" + } + } } } } diff --git a/qml/Forms/Asset.qml b/qml/Forms/Asset.qml index b642d30..e164a2b 100644 --- a/qml/Forms/Asset.qml +++ b/qml/Forms/Asset.qml @@ -79,7 +79,7 @@ Item { ComboBox { id: currencyField - textRole: "title" //"code" + textRole: "code" valueRole: "id" model: Magpie.currencies