diff --git a/draw/coin.odg b/draw/coin.odg new file mode 100644 index 0000000..3b38f3b Binary files /dev/null and b/draw/coin.odg differ diff --git a/draw/paper.odg b/draw/paper.odg new file mode 100644 index 0000000..1fb2357 Binary files /dev/null and b/draw/paper.odg differ diff --git a/draw/unknown.odg b/draw/unknown.odg new file mode 100644 index 0000000..59b56f5 Binary files /dev/null and b/draw/unknown.odg differ diff --git a/draw/wallet.odg b/draw/wallet.odg index b65780d..4d1f8eb 100644 Binary files a/draw/wallet.odg and b/draw/wallet.odg differ diff --git a/qml/Components/AssetLine.qml b/qml/Components/AssetLine.qml index 0a40b6f..4c0a580 100644 --- a/qml/Components/AssetLine.qml +++ b/qml/Components/AssetLine.qml @@ -29,13 +29,10 @@ Item { height: parent.iconSize color: line.color - IconLabel { + Icon { anchors.fill: parent - icon { - name: line.icon - width: width - height: height - } + iconName: line.icon + color: pickColor(line.color) } } diff --git a/qml/Components/CMakeLists.txt b/qml/Components/CMakeLists.txt index 452683c..edc1a39 100644 --- a/qml/Components/CMakeLists.txt +++ b/qml/Components/CMakeLists.txt @@ -12,6 +12,7 @@ qt_add_qml_module(magpieComponents Modal.qml AssetLine.qml IconPicker.qml + Icon.qml ) target_link_libraries(magpie PRIVATE magpieComponents) diff --git a/qml/Components/Icon.qml b/qml/Components/Icon.qml new file mode 100644 index 0000000..406911f --- /dev/null +++ b/qml/Components/Icon.qml @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: 2023 Yury Gubich +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls + +IconImage { + required property string iconName + property int iconSize: 20 + + id: image + source: "qrc:/icons/" + iconName + ".svg" + height: iconSize + width: iconSize + + sourceSize.width: iconSize + sourceSize.height: iconSize + + IconImage { + id: fallback + anchors.fill: parent + source: "qrc:/icons/unknown.svg" + visible: parent.status == Image.Error + color: image.color + + sourceSize.width: iconSize + sourceSize.height: iconSize + } + + function pickColor (color: color) { + const text = palette.text; + const base = palette.base; + const t = brightness(text) + const b = brightness(base) + + let l = text, r = base; + if (t > b) { + l = base; + r = text; + } + + const s = (t + b) / 2; + if (brightness(color) - s > 0) + return l; + else + return r; + } + + function brightness (color: color) { + return Math.sqrt(0.2126 * color.r * color.r + 0.7152 * color.g * color.g + 0.0722 * color.b * color.b); + } +} diff --git a/qml/Components/IconPicker.qml b/qml/Components/IconPicker.qml index dba8ff0..99a1e74 100644 --- a/qml/Components/IconPicker.qml +++ b/qml/Components/IconPicker.qml @@ -8,7 +8,7 @@ ComboBox { property string icon: "" id: box - model: ["wallet", "whatever"] + model: ["wallet", "coin", "paper"] delegate: MenuItem { required property string modelData required property int index @@ -26,24 +26,12 @@ ComboBox { component View: Row { required property string icon - property int iconSize: 20 spacing: 5 - IconImage { - id: image + Icon { anchors.verticalCenter: parent.verticalCenter + iconName: icon 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 { diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index a0f6187..58e7957 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -2,4 +2,7 @@ qt_add_resources(magpie "magpieIcons" PREFIX "/" FILES icons/wallet.svg + icons/coin.svg + icons/paper.svg + icons/unknown.svg ) diff --git a/resources/icons/coin.svg b/resources/icons/coin.svg new file mode 100644 index 0000000..2272df5 --- /dev/null +++ b/resources/icons/coin.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/icons/paper.svg b/resources/icons/paper.svg new file mode 100644 index 0000000..b5fd280 --- /dev/null +++ b/resources/icons/paper.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/icons/unknown.svg b/resources/icons/unknown.svg index 49ae7b8..c5dbd71 100644 --- a/resources/icons/unknown.svg +++ b/resources/icons/unknown.svg @@ -1,5 +1,75 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/icons/wallet.svg b/resources/icons/wallet.svg index ed2841a..d1c2671 100644 --- a/resources/icons/wallet.svg +++ b/resources/icons/wallet.svg @@ -56,28 +56,28 @@ - + - - + + + + + + + + - - - - - - - - + + - - + +