Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix QML SliderSpinBox selecting the text label on rightclick

Luna Lovecraft1a3100e34892
diff --git a/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qml b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qml
index 47ce7b7e39..c689c4c2f2 100644
--- a/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qml
+++ b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qml
@@ -240,7 +240,7 @@ FocusScope {
if (root.parentSpinBox) {
root.parentSpinBox.editable = true;
}
- parseSpinBoxContentItem.textInput.selectAll();
+ parseSpinBoxContentItem.textInput.selectContents();
parseSpinBoxContentItem.textInput.forceActiveFocus(Qt.OtherFocusReason);
root.valueBeforeEditing = root.value;
}
@@ -249,7 +249,7 @@ FocusScope {
if (root.parentSpinBox) {
root.parentSpinBox.editable = true;
}
- parseSpinBoxContentItem.textInput.selectAll();
+ parseSpinBoxContentItem.textInput.selectContents();
parseSpinBoxContentItem.textInput.forceActiveFocus(Qt.OtherFocusReason);
root.valueBeforeEditing = root.value;
parseSpinBoxContentItem.textInput.contentsText = v;
diff --git a/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qml b/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qml
index f90c0c90e3..55c2fcd7d5 100644
--- a/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qml
+++ b/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qml
@@ -35,4 +35,10 @@ TextInputWithSelectionRange {
const endPos = text.endsWith(suffix) ? text.length - suffix.length : text.length;
contentsText = text.slice(startPos, endPos);
}
+
+ function selectContents() {
+ const startPos = text.startsWith(prefix) ? prefix.length : 0;
+ const endPos = text.endsWith(suffix) ? text.length - suffix.length : text.length;
+ select(startPos, endPos);
+ }
}