Verified Commit efb795ef authored by ivan tkachenko's avatar ivan tkachenko
Browse files

ProgressBar,Slider: Adapt great precision to the harsh reality

Test case: `to` values >= 214749 should work.

BUG: 455339
parent 299748e9
Pipeline #207802 passed with stage
in 3 minutes and 21 seconds
......@@ -22,11 +22,15 @@ T.ProgressBar {
contentItem: Item {}
background: StylePrivate.StyleItem {
// Rescale for extra precision. Adapts to the range of `from` & `to` to avoid integer overflow.
property int factor: (Math.abs(controlRoot.from) < 100000 && Math.abs(controlRoot.to) < 100000)
? 10000 : 1
elementType: "progressbar"
control: controlRoot
maximum: indeterminate ? 0 : 10000 * controlRoot.to
minimum: indeterminate ? 0 : 10000 * controlRoot.from
value: indeterminate ? 0 : 10000 * controlRoot.value
maximum: indeterminate ? 0 : factor * controlRoot.to
minimum: indeterminate ? 0 : factor * controlRoot.from
value: indeterminate ? 0 : factor * controlRoot.value
horizontal: true
enabled: controlRoot.enabled
......
......@@ -28,6 +28,10 @@ T.Slider {
snapMode: T.Slider.SnapOnRelease
background: StylePrivate.StyleItem {
// Rescale for extra precision. Adapts to the range of `from` & `to` to avoid integer overflow.
property int factor: (Math.abs(controlRoot.from) < 100000 && Math.abs(controlRoot.to) < 100000)
? 10000 : 1
control: controlRoot
elementType: "slider"
sunken: controlRoot.pressed
......@@ -36,10 +40,10 @@ T.Slider {
contentHeight: horizontal ? (Kirigami.Settings.tabletMode ? 24 : 22) : controlRoot.implicitHeight
anchors.verticalCenter: controlRoot.verticalCenter
maximum: 10000 * controlRoot.to
minimum: 10000 * controlRoot.from
step: 10000 * controlRoot.stepSize
value: 10000 * controlRoot.value
maximum: factor * controlRoot.to
minimum: factor * controlRoot.from
step: factor * controlRoot.stepSize
value: factor * controlRoot.value
horizontal: controlRoot.orientation === Qt.Horizontal
enabled: controlRoot.enabled
hasFocus: controlRoot.activeFocus
......
......@@ -94,9 +94,6 @@ Kirigami.ApplicationWindow {
}
ProgressBar {
id: progress
from: 0
to: 1
LoopAnimation on value {}
Layout.fillWidth: true
}
......@@ -127,7 +124,6 @@ Kirigami.ApplicationWindow {
}
Slider {
id: slider
stepSize: 0.1
LoopAnimation on value {}
Layout.fillWidth: true
......@@ -143,8 +139,11 @@ Kirigami.ApplicationWindow {
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
}
// Test for BUG-455339
Slider {
stepSize: 0.1
to: 300000
stepSize: 30000
value: 90000
Layout.fillWidth: true
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment