summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2012-12-05 17:26:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-19 23:42:49 +0100
commit56dc245a2beb42ceb9f2159da8cd5dd131e23a02 (patch)
tree64232908fe8d37a7b0874ef4ceaf1cc42b442f62 /src/widgets
parent4e38747d8deb13593e0f277fa10145a6608063c1 (diff)
Mac: Ignore ScrollBarAlwaysOn policy for transient scrollbars
Change-Id: I8a542263df64a21cad6b8cddc5ab1d8a93e153d5 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index ae363fe71f..c277f7bd45 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -328,11 +328,14 @@ void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)
void QAbstractScrollAreaPrivate::layoutChildren()
{
Q_Q(QAbstractScrollArea);
- bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
- || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty()));
+ bool transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar ? vbar : hbar);
+ bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn && !transient)
+ || ((hbarpolicy == Qt::ScrollBarAsNeeded || transient)
+ && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty());
- bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
- || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty()));
+ bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn && !transient)
+ || ((vbarpolicy == Qt::ScrollBarAsNeeded || transient)
+ && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty());
QStyleOption opt(0);
opt.init(q);
@@ -490,7 +493,7 @@ void QAbstractScrollAreaPrivate::layoutChildren()
horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0);
#endif
#ifdef Q_OS_MAC
- if (!hasCornerWidget && QSysInfo::macVersion() >= QSysInfo::MV_10_8 && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar))
+ if (!hasCornerWidget && QSysInfo::macVersion() >= QSysInfo::MV_10_8 && transient)
horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0);
#endif
scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect));
@@ -500,7 +503,7 @@ void QAbstractScrollAreaPrivate::layoutChildren()
if (needv) {
QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1));
#ifdef Q_OS_MAC
- if (!hasCornerWidget && QSysInfo::macVersion() >= QSysInfo::MV_10_8 && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar))
+ if (!hasCornerWidget && QSysInfo::macVersion() >= QSysInfo::MV_10_8 && transient)
verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y());
#endif
scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect));
@@ -662,7 +665,6 @@ void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
d->layoutChildren();
if (oldPolicy != d->vbarpolicy)
d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
- d->setScrollBarTransient(d->vbar, policy == Qt::ScrollBarAsNeeded);
}
@@ -724,7 +726,6 @@ void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy polic
d->layoutChildren();
if (oldPolicy != d->hbarpolicy)
d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
- d->setScrollBarTransient(d->hbar, policy == Qt::ScrollBarAsNeeded);
}
/*!
@@ -943,7 +944,7 @@ bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)
Q_D(QAbstractScrollArea);
if ((o == d->hbar || o == d->vbar) && (e->type() == QEvent::HoverEnter || e->type() == QEvent::HoverLeave)) {
Qt::ScrollBarPolicy policy = o == d->hbar ? d->vbarpolicy : d->hbarpolicy;
- if (policy == Qt::ScrollBarAsNeeded) {
+ if (policy == Qt::ScrollBarAsNeeded || style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, d->vbar ? d->vbar : d->hbar)) {
QScrollBar *sibling = o == d->hbar ? d->vbar : d->hbar;
d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
}
@@ -1453,9 +1454,11 @@ bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
void QAbstractScrollAreaPrivate::flashScrollBars()
{
- if (hbarpolicy == Qt::ScrollBarAsNeeded)
+ Q_Q(QAbstractScrollArea);
+ bool transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar ? vbar : hbar);
+ if (hbarpolicy == Qt::ScrollBarAsNeeded || transient)
hbar->d_func()->flash();
- if (vbarpolicy == Qt::ScrollBarAsNeeded)
+ if (vbarpolicy == Qt::ScrollBarAsNeeded || transient)
vbar->d_func()->flash();
}