From 2a37fd0b8557c6b59f4638444efe90c292b27e18 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 16 Nov 2011 16:45:28 +0100 Subject: Fix sliders style issues. Due to their widget heritage,some styles' logic for drawing sliders incorrectly assumed a rect with a top left point at (0,0). Change-Id: I02d9c32d925650ccb36e2b917dd890e5d2bbf925 Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qmotifstyle.cpp | 10 ++++--- src/widgets/styles/qplastiquestyle.cpp | 51 ++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/widgets/styles/qmotifstyle.cpp b/src/widgets/styles/qmotifstyle.cpp index a18fc3ba97..46a64eb575 100644 --- a/src/widgets/styles/qmotifstyle.cpp +++ b/src/widgets/styles/qmotifstyle.cpp @@ -1952,11 +1952,13 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, slider->upsideDown); if (horizontal) return visualRect(slider->direction, slider->rect, - QRect(sliderPos + motifBorder, tickOffset + motifBorder, len, - thickness - 2 * motifBorder)); + QRect(sliderPos + motifBorder + slider->rect.left() + , tickOffset + motifBorder + slider->rect.top() + , len, thickness - 2 * motifBorder)); return visualRect(slider->direction, slider->rect, - QRect(tickOffset + motifBorder, sliderPos + motifBorder, - thickness - 2 * motifBorder, len)); + QRect(tickOffset + motifBorder + slider->rect.left() + , sliderPos + motifBorder + slider->rect.top() + , thickness - 2 * motifBorder, len)); } } break; diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp index 799bc95fdd..65e269f800 100644 --- a/src/widgets/styles/qplastiquestyle.cpp +++ b/src/widgets/styles/qplastiquestyle.cpp @@ -3727,46 +3727,49 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("slider_groove-%0-%1").arg(ticksAbove).arg(ticksBelow)) p->fillRect(groove, option->palette.background()); + rect = groove; + rect.moveTo(groove.left() - option->rect.left(), groove.top() - option->rect.top()); + // draw groove if (horizontal) { p->setPen(borderColor); const QLine lines[4] = { - QLine(groove.left() + 1, groove.top(), - groove.right() - 1, groove.top()), - QLine(groove.left() + 1, groove.bottom(), - groove.right() - 1, groove.bottom()), - QLine(groove.left(), groove.top() + 1, - groove.left(), groove.bottom() - 1), - QLine(groove.right(), groove.top() + 1, - groove.right(), groove.bottom() - 1) }; + QLine(rect.left() + 1, rect.top(), + rect.right() - 1, rect.top()), + QLine(rect.left() + 1, rect.bottom(), + rect.right() - 1, rect.bottom()), + QLine(rect.left(), rect.top() + 1, + rect.left(), rect.bottom() - 1), + QLine(rect.right(), rect.top() + 1, + rect.right(), rect.bottom() - 1) }; p->drawLines(lines, 4); p->setPen(alphaCornerColor); const QPoint points[4] = { - QPoint(groove.left(), groove.top()), - QPoint(groove.left(), groove.bottom()), - QPoint(groove.right(), groove.top()), - QPoint(groove.right(), groove.bottom()) }; + QPoint(rect.left(), rect.top()), + QPoint(rect.left(), rect.bottom()), + QPoint(rect.right(), rect.top()), + QPoint(rect.right(), rect.bottom()) }; p->drawPoints(points, 4); } else { p->setPen(borderColor); const QLine lines[4] = { - QLine(groove.left() + 1, groove.top(), - groove.right() - 1, groove.top()), - QLine(groove.left() + 1, groove.bottom(), - groove.right() - 1, groove.bottom()), - QLine(groove.left(), groove.top() + 1, - groove.left(), groove.bottom() - 1), - QLine(groove.right(), groove.top() + 1, - groove.right(), groove.bottom() - 1) }; + QLine(rect.left() + 1, rect.top(), + rect.right() - 1, rect.top()), + QLine(rect.left() + 1, rect.bottom(), + rect.right() - 1, rect.bottom()), + QLine(rect.left(), rect.top() + 1, + rect.left(), rect.bottom() - 1), + QLine(rect.right(), rect.top() + 1, + rect.right(), rect.bottom() - 1) }; p->drawLines(lines, 4); p->setPen(alphaCornerColor); const QPoint points[4] = { - QPoint(groove.left(), groove.top()), - QPoint(groove.right(), groove.top()), - QPoint(groove.left(), groove.bottom()), - QPoint(groove.right(), groove.bottom()) }; + QPoint(rect.left(), rect.top()), + QPoint(rect.right(), rect.top()), + QPoint(rect.left(), rect.bottom()), + QPoint(rect.right(), rect.bottom()) }; p->drawPoints(points, 4); } END_STYLE_PIXMAPCACHE -- cgit v1.2.3