blob: 12c6f70e21d9f344ecef1ac3c8d0f463e548debc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import QtQuick
import Qt.labs.platform as P
import "../.."
// A swatch of the current colour that opens a colour dialog. picked carries
// the choice as #rrggbb, the form qtmaildir.conf uses.
//
// Qt.labs.platform, not QtQuick.Dialogs: the Quick dialog paints from the
// Qt Quick palette, which qt6ct leaves at Qt's light default here
// (custom_palette=false; the dark comes from the kvantum-dark widget style),
// so it opened light on a dark desktop. This one falls back to the widget
// QColorDialog in a QApplication, which shell.qml's UseQApplication pragma
// makes this process, and widgets take the kvantum style like every app.
Rectangle {
id: pick
property string colour: ""
signal picked(string hex)
width: 34; height: 34
radius: 8
color: /^#[0-9a-fA-F]{6}$/.test(pick.colour) ? pick.colour : Theme.surface
border.width: 1
border.color: area.containsMouse ? Theme.accent : Qt.alpha(Theme.text, 0.2)
Text {
anchors.centerIn: parent
visible: !/^#[0-9a-fA-F]{6}$/.test(pick.colour)
// nf-fa-eyedropper, present in Inconsolata Nerd Font.
text: ""
font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 2 }
color: Theme.subtext
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: dialog.open()
}
P.ColorDialog {
id: dialog
currentColor: /^#[0-9a-fA-F]{6}$/.test(pick.colour) ? pick.colour : "#808080"
// toString() is #rrggbb for an opaque colour, and the dialog offers
// no alpha unless asked to; the slice is a guard all the same.
onAccepted: pick.picked(color.toString().slice(0, 7))
}
}
|