blob: 7094a4a8537f377136dbc01f346830e97718afdf (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.Commons
import qs.Widgets
import "." as Local
// Label + background pill + text pill + optional rename field + reset. Used by
// Settings.qml for per-category color customization. Empty bgValue/textValue
// means "use fallback". When showLabel is set, an extra text field lets the user
// rename the key's display label (used for the generic Mod2/Mod3/Mod5 keys).
RowLayout {
id: row
property var pluginApi
property var screen
property string labelText: ""
property string bgValue: ""
property string textValue: ""
property color bgFallback: "#888888"
property color textFallback: "#FFFFFF"
property string letter: "A"
property string clipboardHex: ""
property bool showBg: true
property bool showText: true
// Optional display-label override (e.g. rename "Mod3" -> "Hyper")
property bool showLabel: false
property string labelValue: ""
property string labelPlaceholder: ""
signal bgPicked(color value)
signal textPicked(color value)
signal bgPasted(string hex)
signal textPasted(string hex)
signal labelEdited(string value)
signal resetRequested()
Layout.fillWidth: true
spacing: Style.marginM
NText {
text: row.labelText
color: Color.mOnSurface
pointSize: Style.fontSizeM
Layout.preferredWidth: 180 * Style.uiScaleRatio
elide: Text.ElideRight
}
Local.ColorPill {
Layout.preferredWidth: 130 * Style.uiScaleRatio
visible: row.showBg
screen: row.screen
hexValue: row.bgValue
displayColor: row.bgValue.length > 0 ? row.bgValue : row.bgFallback
textMode: false
clipboardHex: row.clipboardHex
placeholderText: row.bgValue.length === 0 ? row.pluginApi?.tr("settings.color-auto") : ""
onColorPicked: c => row.bgPicked(c)
onPasteRequested: hex => row.bgPasted(hex)
}
Local.ColorPill {
Layout.preferredWidth: 130 * Style.uiScaleRatio
visible: row.showText
screen: row.screen
hexValue: row.textValue
displayColor: row.textValue.length > 0 ? row.textValue : row.textFallback
textMode: true
letter: row.letter
textModeBg: row.bgValue.length > 0 ? row.bgValue : row.bgFallback
clipboardHex: row.clipboardHex
placeholderText: row.textValue.length === 0 ? row.pluginApi?.tr("settings.color-auto") : ""
onColorPicked: c => row.textPicked(c)
onPasteRequested: hex => row.textPasted(hex)
}
NTextInput {
Layout.preferredWidth: 160 * Style.uiScaleRatio
Layout.preferredHeight: Style.baseWidgetSize
visible: row.showLabel
text: row.labelValue
placeholderText: row.labelPlaceholder
onTextChanged: row.labelEdited(text)
}
Item { Layout.fillWidth: true }
NIconButton {
icon: "rotate"
tooltipText: row.pluginApi?.tr("settings.reset-color")
onClicked: row.resetRequested()
}
}
|