From d83f85dbc0be1ce154a788c46086715cfabfffab Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jens.bache-wiig@digia.com> Date: Sun, 10 Feb 2013 12:29:51 +0100 Subject: [PATCH] Fix Slider tickmarks Change-Id: I965321d08a5fec10930fef58427dfb7d23e6c8fb Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> --- examples/gallery/content/Controls.qml | 2 +- src/private/qstyleitem.cpp | 5 +++-- src/styles/Desktop/SliderStyle.qml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/gallery/content/Controls.qml b/examples/gallery/content/Controls.qml index d40a66b76..9a2b8a744 100644 --- a/examples/gallery/content/Controls.qml +++ b/examples/gallery/content/Controls.qml @@ -132,7 +132,7 @@ Item { CheckBox { id: tickmarkCheck text: "Tickmarks" - checked: true + checked: false KeyNavigation.tab: r1 } } diff --git a/src/private/qstyleitem.cpp b/src/private/qstyleitem.cpp index 22ffcf54a..eca2deab9 100644 --- a/src/private/qstyleitem.cpp +++ b/src/private/qstyleitem.cpp @@ -436,15 +436,16 @@ void QStyleItem::initStyleOption() qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep; // at least 5 pixels between tick marks if (numOfSteps && (width() / numOfSteps < 5)) - opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step(); + opt->tickInterval = qRound((5 * numOfSteps / width()) + 0.5) * step(); else opt->tickInterval = opt->singleStep; + } else // default Qt-components implementation opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0; opt->sliderValue = value(); opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; - opt->tickPosition = (activeControl() == "tick" ? + opt->tickPosition = (activeControl() == "ticks" ? QSlider::TicksBelow : QSlider::NoTicks); if (opt->tickPosition != QSlider::NoTicks) opt->subControls |= QStyle::SC_SliderTickmarks; diff --git a/src/styles/Desktop/SliderStyle.qml b/src/styles/Desktop/SliderStyle.qml index 26d550247..7f551a3b7 100644 --- a/src/styles/Desktop/SliderStyle.qml +++ b/src/styles/Desktop/SliderStyle.qml @@ -56,5 +56,5 @@ StyleItem { enabled: control.enabled hasFocus: control.focus hints: control.styleHints - activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : "" + activeControl: control.tickmarksEnabled ? "ticks" : "" } -- GitLab