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 range issues on the QML spinbox sliders.

Wolthera van Hövell tot Westerflierfdfc8904b953
diff --git a/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml
index d3742adf23..a7447a8f41 100644
--- a/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml
+++ b/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml
@@ -11,26 +11,22 @@ KisDoubleSpinBox {
property alias prefix: contentId.prefix
property alias suffix: contentId.suffix
- property real softDFrom: from
- property real softDTo: from
+ property real softDFrom: dFrom
+ property real softDTo: dFrom
property bool softRangeActive: false
property alias blockUpdateSignalOnDrag: contentId.blockUpdateSignalOnDrag
property alias exponentRatio: contentId.exponentRatio
property alias fastSliderStep: contentId.fastSliderStep
readonly property alias dragging : contentId.dragging
+ property bool isComplete: false;
+
function fixSoftRange() {
- if (root.softDFrom < root.dFrom) {
- root.softDFrom = root.dFrom;
- } else if (root.softDFrom > root.softDTo) {
- root.softDFrom = root.softDTo;
- }
- if (root.softDTo < root.softDFrom) {
- root.softDTo = root.softDFrom;
- } else if (root.softDTo > root.dTo) {
- root.softDTo = root.dTo;
- }
- contentId.showSoftRange = root.softDFrom !== root.softDTo;
+ if (!isComplete) return;
+ root.softDFrom = Math.min(Math.max(root.softDFrom, root.dFrom), root.dTo);
+ root.softDTo = Math.min(Math.max(root.softDTo, root.softDFrom), root.dTo);
+ contentId.showSoftRange = (root.softDFrom != root.softDTo)
+ && (root.softDFrom !== root.dFrom || root.softDTo !== root.dTo);
}
editable: false
@@ -68,4 +64,9 @@ KisDoubleSpinBox {
onDToChanged: fixSoftRange()
onSoftDFromChanged: fixSoftRange()
onSoftDToChanged: fixSoftRange()
+
+ Component.onCompleted: {
+ isComplete = true;
+ fixSoftRange()
+ }
}
diff --git a/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml
index 461b3bbf69..9b67ec82c1 100644
--- a/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml
+++ b/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml
@@ -19,18 +19,14 @@ SpinBox {
property int fastSliderStep: 5
readonly property alias dragging : contentId.dragging
+ property bool isComplete: false;
+
function fixSoftRange() {
- if (root.softFrom < root.from) {
- root.softFrom = root.from;
- } else if (root.softFrom > root.softTo) {
- root.softFrom = root.softTo;
- }
- if (root.softTo < root.softFrom) {
- root.softTo = root.softFrom;
- } else if (root.softTo > root.to) {
- root.softTo = root.to;
- }
- contentId.showSoftRange = root.softFrom !== root.softTo;
+ if (!isComplete) return;
+ root.softFrom = Math.min(Math.max(root.softFrom, root.from), root.To);
+ root.softTo = Math.min(Math.max(root.softTo, root.softFrom), root.To);
+ contentId.showSoftRange = (root.softFrom !== root.softTo)
+ && (root.softFrom !== root.from || root.softTo !== root.to);
}
editable: false
@@ -77,5 +73,7 @@ SpinBox {
} else {
root.leftPadding = 0;
}
+ isComplete = true;
+ fixSoftRange()
}
}
diff --git a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml b/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml
index fba8e42aed..30f7466591 100644
--- a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml
+++ b/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml
@@ -66,7 +66,7 @@ FocusScope {
const w = root.softTo - root.softFrom;
return Math.max(Math.min(x, w), 0) / w;
}
- bottomBarWidth: value / (root.to - root.from)
+ bottomBarWidth: (value - root.from) / (root.to - root.from)
faded: root.editing
exponentRatio: root.exponentRatio
}
diff --git a/qmlmodules/components/qml/tooltip/KisToolTip.qml b/qmlmodules/components/qml/tooltip/KisToolTip.qml
index 7dcdb886a2..e6323ee1e3 100644
--- a/qmlmodules/components/qml/tooltip/KisToolTip.qml
+++ b/qmlmodules/components/qml/tooltip/KisToolTip.qml
@@ -10,7 +10,7 @@ ToolTip {
id: root
delay: Qt.styleHints.mousePressAndHoldInterval;
- timeout: Qt.styleHints.mousePressAndHoldInterval;
+ timeout: Qt.styleHints.mousePressAndHoldInterval*10;
property Item parentControl
property bool changingParentControl: false