summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-04-14 09:28:09 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-04-14 10:04:21 (GMT)
commitfcd009cd77f95106f4522103bab9aaf86109a17d (patch)
treee7626eee7b1e05ca95d1c2ebfed27eec6cbbf4e6 /src
parent0ef6bb1dfadf8e83f20e2282ff4a73a466b3de87 (diff)
downloadQt-fcd009cd77f95106f4522103bab9aaf86109a17d.zip
Qt-fcd009cd77f95106f4522103bab9aaf86109a17d.tar.gz
Qt-fcd009cd77f95106f4522103bab9aaf86109a17d.tar.bz2
QAbstractScrollArea StyleSheet: fix drawing of border with SH_ScrollView_FrameOnlyAroundContents
- Since Qt 4.6.0, the frame is drawn by PE_Widget, but there we do not take in account the scrollbar for the case where SH_ScrollView_FrameOnlyAroundContents is true. - We also reserved too much space for the border, as we included the native border as well in the computation, so do not reserve additional space by setting PM_ScrollView_ScrollBarSpacing to 0 Task-number: QTBUG-9821 Reviewed-by: jbache
Diffstat (limited to 'src')
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp16
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp2
2 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index c550938..285a789 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -4242,8 +4242,15 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
const QAbstractScrollAreaPrivate *sap = sa->d_func();
rule.drawBackground(p, opt->rect, sap->contentsOffset());
- if (rule.hasBorder())
- rule.drawBorder(p, rule.borderRect(opt->rect));
+ if (rule.hasBorder()) {
+ QRect brect = rule.borderRect(opt->rect);
+ if (styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, opt, w)) {
+ QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
+ sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0);
+ brect = QStyle::visualRect(opt->direction, brect, r);
+ }
+ rule.drawBorder(p, brect);
+ }
break;
}
#endif
@@ -4628,6 +4635,11 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
return msz.width() == -1 ? msz.height() : msz.width();
}
break;
+
+ case PM_ScrollView_ScrollBarSpacing:
+ if(!rule.hasNativeBorder() || rule.hasBox())
+ return 0;
+ break;
#endif // QT_NO_SCROLLBAR
case PM_ProgressBarChunkWidth:
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 1d496d5..73ec53e 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -394,7 +394,7 @@ void QAbstractScrollAreaPrivate::layoutChildren()
if ((frameStyle != QFrame::NoFrame) &&
q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
controlsRect = widgetRect;
- const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing);
+ const int extra = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
QRect frameRect = widgetRect;
frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());