Warning, /office/klevernotes/src/contents/ui/painting/ColorBar.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com> 0003 0004 import QtQuick 2.15 0005 import QtQuick.Layouts 1.15 0006 0007 import org.kde.kirigami 2.19 as Kirigami 0008 0009 import "qrc:/contents/ui/dialogs/colorDialog" 0010 0011 Kirigami.ShadowedRectangle { 0012 id: root 0013 0014 readonly property var colorsList: [ 0015 "#000000", "#808080", "#FFFFFF", "#FF0000", "#FF8000", 0016 "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF" 0017 ] 0018 0019 property color primaryColor: "black" 0020 property color secondaryColor: "white" 0021 0022 Kirigami.Theme.colorSet: Kirigami.Theme.Header 0023 Kirigami.Theme.inherit: false 0024 0025 color: Kirigami.Theme.backgroundColor 0026 radius: Kirigami.Units.smallSpacing 0027 0028 RowLayout { 0029 anchors.fill: parent 0030 0031 spacing: Kirigami.Units.smallSpacing 0032 0033 Rectangle { 0034 width: Kirigami.Units.gridUnit * 2.5 0035 height: Kirigami.Units.gridUnit * 2.5 0036 0037 color: Qt.rgba(1, 1, 1, 0.2) 0038 radius: Kirigami.Units.smallSpacing 0039 0040 Layout.leftMargin: Kirigami.Units.smallSpacing 0041 0042 ColorButton { 0043 id: secondaryButton 0044 0045 x: parent.width - width - Kirigami.Units.smallSpacing 0046 y: parent.height - height - Kirigami.Units.smallSpacing 0047 width: Kirigami.Units.gridUnit * 1.5 0048 height: Kirigami.Units.gridUnit * 1.5 0049 0050 color: root.secondaryColor 0051 border { 0052 color: "black" 0053 width: 1 0054 } 0055 0056 multicolor: true 0057 0058 onOpenColorPicker: { 0059 colorDialog.caller = secondaryButton 0060 colorDialog.open() 0061 } 0062 } 0063 ColorButton { 0064 id: primaryButton 0065 0066 x: Kirigami.Units.smallSpacing 0067 y: Kirigami.Units.smallSpacing 0068 width: Kirigami.Units.gridUnit * 1.5 0069 height: Kirigami.Units.gridUnit * 1.5 0070 0071 color: root.primaryColor 0072 border { 0073 color: "black" 0074 width: 1 0075 } 0076 multicolor: true 0077 0078 onOpenColorPicker: { 0079 colorDialog.caller = primaryButton 0080 colorDialog.open() 0081 } 0082 } 0083 } 0084 0085 Repeater { 0086 model: colorsList 0087 ColorButton { 0088 color: modelData 0089 0090 onPrimaryColorChanged: { 0091 root.primaryColor = color 0092 } 0093 onSecondaryColorChanged: { 0094 root.secondaryColor = color 0095 } 0096 } 0097 } 0098 } 0099 0100 ColorDialog { 0101 id: colorDialog 0102 0103 property QtObject caller 0104 0105 selectedColor: caller ? caller.color : "black" 0106 0107 onApplied: { 0108 colorDialog.close() 0109 if (caller.color === root.primaryColor) { 0110 root.primaryColor = selectedColor 0111 return 0112 } 0113 root.secondaryColor = selectedColor 0114 } 0115 } 0116 }