diff --git a/CMakeLists.txt b/CMakeLists.txt index 40fe706..c918edc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ project(magpie set(PROJECT_LICENSE "GPL-3.0") set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) +# set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -61,6 +61,7 @@ add_subdirectory(qml) add_subdirectory(API) add_subdirectory(models) add_subdirectory(utils) +add_subdirectory(resources) target_include_directories(magpie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(magpie PRIVATE diff --git a/draw/wallet.odg b/draw/wallet.odg new file mode 100644 index 0000000..b65780d Binary files /dev/null and b/draw/wallet.odg differ diff --git a/qml/Components/CMakeLists.txt b/qml/Components/CMakeLists.txt index 2ddc094..452683c 100644 --- a/qml/Components/CMakeLists.txt +++ b/qml/Components/CMakeLists.txt @@ -11,6 +11,7 @@ qt_add_qml_module(magpieComponents QML_FILES Modal.qml AssetLine.qml + IconPicker.qml ) target_link_libraries(magpie PRIVATE magpieComponents) diff --git a/qml/Components/IconPicker.qml b/qml/Components/IconPicker.qml new file mode 100644 index 0000000..dba8ff0 --- /dev/null +++ b/qml/Components/IconPicker.qml @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: 2023 Yury Gubich +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls + +ComboBox { + property string icon: "" + + id: box + model: ["wallet", "whatever"] + delegate: MenuItem { + required property string modelData + required property int index + + width: parent.width + highlighted: box.highlightedIndex === index + contentItem: View { + icon: modelData + } + } + contentItem: View { + icon: currentText + padding: 5 + } + + component View: Row { + required property string icon + property int iconSize: 20 + + spacing: 5 + IconImage { + id: image + anchors.verticalCenter: parent.verticalCenter + color: palette.text + source: "qrc:/icons/" + icon + ".svg" + height: parent.iconSize + width: parent.iconSize + + IconImage { + id: fallback + anchors.fill: parent + source: "qrc:/icons/wallet.svg" + visible: parent.status == Image.Error + color: palette.text + } + } + + Label { + anchors.verticalCenter: parent.verticalCenter + text: icon + } + } +} diff --git a/qml/Forms/AddAsset.qml b/qml/Forms/AddAsset.qml index e35283d..eaaf4c9 100644 --- a/qml/Forms/AddAsset.qml +++ b/qml/Forms/AddAsset.qml @@ -36,15 +36,16 @@ Item { TextField { id: titleField + text: "New Asset" } Label { text: qsTr("Icon") + ":"; } - TextField { + Components.IconPicker { id: iconField - text: "list-add" + icon: "list-add" } Label { @@ -66,7 +67,7 @@ Item { Button { text: qsTr("Create") - onClicked: inner.send(titleField.text, iconField.text, colorField.text) + onClicked: inner.confirm() } } @@ -74,12 +75,17 @@ Item { id: modal } + function confirm () { + //TODO validation + send(titleField.text, iconField.icon, colorField.text); + } + function send (title, icon, color) { if (modal.inProgress) return; titleField.text = title; - iconField.text = icon; + iconField.icon = icon; colorField.text = color; modal.inProgress = true; diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt new file mode 100644 index 0000000..a0f6187 --- /dev/null +++ b/resources/CMakeLists.txt @@ -0,0 +1,5 @@ +qt_add_resources(magpie "magpieIcons" + PREFIX "/" + FILES + icons/wallet.svg +) diff --git a/resources/icons/unknown.svg b/resources/icons/unknown.svg new file mode 100644 index 0000000..49ae7b8 --- /dev/null +++ b/resources/icons/unknown.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/icons/wallet.svg b/resources/icons/wallet.svg new file mode 100644 index 0000000..ed2841a --- /dev/null +++ b/resources/icons/wallet.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file