From 7de98d00488bb3e50d0f163803d9119ee1dd6999 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 1 May 2009 17:08:31 +0000 Subject: [PATCH] vertically (or horizontally) center sliders svn path=/trunk/KDE/kdelibs/; revision=962180 --- private/style.cpp | 24 +++++++++++++++++++++++- private/style_p.h | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/private/style.cpp b/private/style.cpp index cd45a53c0..4a5c18fd2 100644 --- a/private/style.cpp +++ b/private/style.cpp @@ -284,6 +284,28 @@ void Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, } } +QRect Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, + SubControl subControl, const QWidget *widget) const +{ + QRect rect(qApp->style()->subControlRect(control, option, subControl, widget)); + switch (control) { + case CC_Slider: { + const QStyleOptionSlider *sliderOpt = qstyleoption_cast(option); + if (sliderOpt) { + if (sliderOpt->orientation == Qt::Horizontal) { + rect.moveCenter(QPoint(rect.center().x(), option->rect.center().y())); + } else { + rect.moveCenter(QPoint(option->rect.center().x(), rect.center().y())); + } + } + return rect; + break; + } + default: + return rect; + } +} + int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { if (Theme::defaultTheme()->useNativeWidgetStyle()) { @@ -301,7 +323,7 @@ int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWi } } default: - return QCommonStyle::pixelMetric(metric, option, widget); + return qApp->style()->pixelMetric(metric, option, widget); } } diff --git a/private/style_p.h b/private/style_p.h index d99633f6b..96f656a57 100644 --- a/private/style_p.h +++ b/private/style_p.h @@ -53,6 +53,8 @@ protected: const QWidget *widget) const; int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; + QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, + SubControl subControl, const QWidget *widget) const; private: StylePrivate *d;