| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2024 ivan tkachenko <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
pragma ComponentBehavior: Bound |
| 8 |
|
| 9 |
import QtQuick |
| 10 |
import QtQuick.Layouts |
| 11 |
import org.kde.kirigami as Kirigami |
| 12 |
|
| 13 |
RowLayout { |
| 14 |
id: root |
| 15 |
|
| 16 |
required property color color |
| 17 |
|
| 18 |
property bool showLabel: true |
| 19 |
|
| 20 |
default property alias __contentData: contentWrapper.data |
| 21 |
|
| 22 |
Layout.fillWidth: false |
| 23 |
Layout.fillHeight: false |
| 24 |
|
| 25 |
Rectangle { |
| 26 |
id: borderGraphics |
| 27 |
|
| 28 |
Layout.alignment: Qt.AlignVCenter | (root.showLabel ? Qt.AlignLeft : Qt.AlignHCenter) |
| 29 |
Layout.fillWidth: !root.showLabel |
| 30 |
Layout.fillHeight: !root.showLabel |
| 31 |
|
| 32 |
implicitWidth: 32 |
| 33 |
implicitHeight: 32 |
| 34 |
|
| 35 |
border.width: 1 |
| 36 |
border.color: Kirigami.Theme.textColor |
| 37 |
color: "transparent" |
| 38 |
radius: Kirigami.Units.cornerRadius + border.width |
| 39 |
|
| 40 |
Rectangle { |
| 41 |
id: contentWrapper |
| 42 |
z: -1 |
| 43 |
anchors.fill: parent |
| 44 |
anchors.margins: borderGraphics.border.width |
| 45 |
border.width: 2 |
| 46 |
border.color: Kirigami.Theme.backgroundColor |
| 47 |
color: root.color |
| 48 |
radius: Kirigami.Units.cornerRadius |
| 49 |
} |
| 50 |
|
| 51 |
Image { |
| 52 |
z: -2 |
| 53 |
anchors.fill: contentWrapper |
| 54 |
anchors.margins: contentWrapper.border.width |
| 55 |
source: Qt.resolvedUrl("checkerboard.svg") |
| 56 |
fillMode: Image.Tile |
| 57 |
visible: root.color.a < 1.0 |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
Kirigami.SelectableLabel { |
| 62 |
Layout.fillWidth: true |
| 63 |
Layout.fillHeight: true |
| 64 |
visible: root.showLabel |
| 65 |
verticalAlignment: TextEdit.AlignVCenter |
| 66 |
text: root.color.toString() |
| 67 |
} |
| 68 |
} |
| 69 |
|