Skip to content

Commit 2d72f3f

Browse files
committed
Provide feedback on color selection for pointers
Also allow easily undoing color selection
1 parent 070dc54 commit 2d72f3f

File tree

2 files changed

+77
-21
lines changed

2 files changed

+77
-21
lines changed

src/kirigami_ui/PrompterPage.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,9 @@ Kirigami.Page {
11951195
viewport.editor.enabled = true;
11961196
viewport.prompter.restoreFocus();
11971197
}
1198-
PointerSettings{
1198+
PointerSettings {
11991199
id: pointerSettings
1200+
prompterBackground: prompterPage.prompterBackground
12001201
}
12011202
}
12021203

src/prompter/PointerSettings.qml

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ ColumnLayout {
3939
QML
4040
}
4141

42+
required property PrompterBackground prompterBackground
43+
4244
property alias pointerKind: listView.currentIndex
4345
property alias colorsEditing: editingColor.value
4446
property alias colorsReady: readyColor.value
@@ -104,45 +106,98 @@ ColumnLayout {
104106
}
105107
RowLayout {
106108
id: pointerColorSettings
107-
Label {
108-
text: qsTr("Editing: ")
109+
Button {
110+
implicitWidth: editingColorLabel.implicitWidth + implicitHeight / 2
111+
onClicked: event => {
112+
if (editingColor.text.length)
113+
editingColor.text = "";
114+
else {
115+
pointerColorDialog.source = editingColor;
116+
pointerColorDialog.open();
117+
}
118+
}
119+
Material.theme: Material.Dark
120+
Rectangle {
121+
color: pointerSettings.prompterBackground.backgroundColor
122+
radius: parent.height / 2
123+
anchors.fill: parent
124+
Label {
125+
id: editingColorLabel
126+
anchors.centerIn: parent
127+
text: qsTr("Editing: ") + (editingColor.text.length ? "\n>🧹<" : "\n>🖌️<")
128+
color: editingColor.text ? Qt.color(editingColor.text) : editingColor.placeholderText
129+
font.bold: true
130+
horizontalAlignment: Qt.AlignHCenter
131+
}
132+
}
109133
}
110134
TextField {
111135
id: editingColor
112136
property color value: text ? text : placeholderText
113137
placeholderText: Material.theme === Material.Light ? "#4d94cf" : "#2b72ad"
114-
onPressed: event => {
115-
pointerColorDialog.source = this
116-
pointerColorDialog.open()
117-
}
118138
Layout.fillWidth: true
119139
Material.theme: Material.Dark
120140
}
121-
Label {
122-
text: qsTr("Ready: ")
141+
Button {
142+
implicitWidth: editingColorLabel.implicitWidth + implicitHeight / 2
143+
onClicked: {
144+
if (readyColor.text.length)
145+
readyColor.text = "";
146+
else {
147+
pointerColorDialog.source = readyColor;
148+
pointerColorDialog.open();
149+
}
150+
}
151+
Material.theme: Material.Dark
152+
Rectangle {
153+
color: pointerSettings.prompterBackground.backgroundColor
154+
radius: parent.height / 2
155+
anchors.fill: parent
156+
Label {
157+
id: readyColorLabel
158+
anchors.centerIn: parent
159+
text: qsTr("Ready: ") + (readyColor.text.length ? "\n>🧹<" : "\n>🖌️<")
160+
color: readyColor.text ? Qt.color(readyColor.text) : readyColor.placeholderText
161+
font.bold: true
162+
horizontalAlignment: Qt.AlignHCenter
163+
}
164+
}
123165
}
124166
TextField {
125167
id: readyColor
126168
property color value: text ? text : placeholderText
127169
placeholderText: Material.theme === Material.Light ? "#4d94cf" : "#2b72ad"
128-
onPressed: event => {
129-
pointerColorDialog.source = this
130-
pointerColorDialog.open()
131-
}
132170
Layout.fillWidth: true
133171
Material.theme: Material.Dark
134172
}
135-
Label {
136-
text: qsTr("Prompting: ")
173+
Button {
174+
implicitWidth: promptingColorLabel.implicitWidth + implicitHeight / 2
175+
onClicked: {
176+
if (promptingColor.text.length)
177+
promptingColor.text = "";
178+
else {
179+
pointerColorDialog.source = promptingColor;
180+
pointerColorDialog.open();
181+
} }
182+
Material.theme: Material.Dark
183+
Rectangle {
184+
color: pointerSettings.prompterBackground.backgroundColor
185+
radius: parent.height / 2
186+
anchors.fill: parent
187+
Label {
188+
id: promptingColorLabel
189+
anchors.centerIn: parent
190+
text: qsTr("Prompting: ") + (promptingColor.text.length ? "\n>🧹<" : "\n>🖌️<")
191+
color: promptingColor.text ? Qt.color(promptingColor.text) : promptingColor.placeholderText
192+
font.bold: true
193+
horizontalAlignment: Qt.AlignHCenter
194+
}
195+
}
137196
}
138197
TextField {
139198
id: promptingColor
140199
property color value: text ? text : placeholderText
141200
placeholderText: Material.theme === Material.Light ? "#4d94cf" : "#2b72ad"
142-
onPressed: event => {
143-
pointerColorDialog.source = this
144-
pointerColorDialog.open()
145-
}
146201
Layout.fillWidth: true
147202
Material.theme: Material.Dark
148203
}
@@ -554,9 +609,9 @@ ColumnLayout {
554609
}
555610
ColorDialog {
556611
id: pointerColorDialog
557-
options: Qt.platform.os === "ios" ? 0 : ColorDialog.DontUseNativeDialog
612+
options: ["ios", "osx"].indexOf(Qt.platform.os) ? 0 : ColorDialog.DontUseNativeDialog
558613
property TextField source
559-
selectedColor: appTheme.__backgroundColor
614+
selectedColor: Material.theme === Material.Light ? "#4d94cf" : "#2b72ad"
560615
onAccepted: {
561616
source.text = selectedColor
562617
}

0 commit comments

Comments
 (0)