8import QtQuick.Controls as QQC2
9import QtQuick.Dialogs as QtDialogs
33 property alias color: colorDialog.selectedColor
38 property alias dialogTitle: colorDialog.title
43 property bool showAlphaChannel: true
50 signal accepted(color color)
52 readonly property real _buttonMarigns: 4
54 implicitWidth: 40 + _buttonMarigns * 2
56 Accessible.name: i18nc("@info:whatsthis for a button",
"Color button")
57 Accessible.description: enabled
58 ?
i18nc(
"@info:whatsthis for a button of current color code %1",
"Current color is %1. This button will open a color chooser dialog.", color)
59 :
i18nc(
"@info:whatsthis for a button of current color code %1",
"Current color is %1.", color)
63 anchors.fill: colorBlock
64 visible: colorDialog.selectedColor.a < 1
67 const ctx = getContext(
'2d');
69 ctx.fillStyle =
"white";
70 ctx.fillRect(0,0, ctx.width, ctx.height);
72 ctx.fillStyle =
"black";
74 for (let j = 0; j < width; j += 16) {
75 for (let i = 0; i < height; i += 16) {
77 ctx.fillRect(j, i, 8, 8);
78 ctx.fillRect(j + 8, i + 8, 8, 8);
87 anchors.centerIn: parent
88 height: parent.height - _buttonMarigns * 2
89 width: parent.width - _buttonMarigns * 2
91 color: enabled ? colorDialog.selectedColor : disabledPalette.button
95 colorGroup: SystemPalette.Disabled
99 QtDialogs.ColorDialog {
101 onAccepted: root.accepted(color)
102 parentWindow: root.Window.window
103 options: root.showAlphaChannel ? QtDialogs.ColorDialog.ShowAlphaChannel : undefined
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:47:07 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.