Warning, /office/klevernotes/src/contents/ui/settings/SettingsColorButton.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 import QtQuick.Controls 2.15 as Controls
0007 
0008 import org.kde.kirigami 2.19 as Kirigami
0009 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0010 
0011 FormCard.AbstractFormDelegate {
0012     id: root
0013 
0014     readonly property alias colorButton: colorButton
0015     required property string name
0016     required property string color
0017 
0018     property alias title: title.text
0019 
0020     contentItem: ColumnLayout {
0021         id: holder
0022 
0023         Controls.Label {
0024             id: title
0025 
0026             Layout.fillWidth: true
0027             Layout.leftMargin: Kirigami.Units.smallSpacing
0028         }
0029 
0030         RowLayout {
0031             id: colorButton
0032 
0033             Layout.fillWidth: true
0034             Layout.fillHeight: true
0035             Layout.margins: Kirigami.Units.smallSpacing
0036 
0037             Controls.Button {
0038                 id: textButton
0039 
0040                 background: Rectangle {
0041                     color: root.color
0042                     radius: Kirigami.Units.smallSpacing
0043                 }
0044 
0045                 Layout.fillWidth: true
0046                 Layout.preferredHeight: holder.height / 2
0047 
0048                 onClicked: {
0049                     callPicker()
0050                 }
0051             }
0052 
0053             Controls.Button {
0054                 id: resetText
0055 
0056                 icon.name: "edit-undo"
0057 
0058                 onClicked: {
0059                     updateColor(root, "None")
0060                 }
0061             }
0062         }
0063     }
0064 
0065     onClicked: {
0066         callPicker()
0067     }
0068 
0069     function callPicker() {
0070         colorPicker.caller = root
0071         colorPicker.open()
0072     }
0073 }