summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-03-25 13:06:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-28 20:46:53 +0100
commit123ae472e2668a1f57f7c69a1a2a59336f83d06a (patch)
tree31111ec5bde8c835a65b9116fdc84ae464df91e9 /src/widgets/widgets
parent3c6c14c0bff9ceb10a64aa04fb33cf2476800e20 (diff)
Fix disappearing transient scrollbars
When a transient scrollbar is already at the end and user attempts to scroll further, the scrollbar is "flashed" to indicate that the scroll area is already scrolled to the end. This is done so that the scrollbar is first painted with a flag turned on to make it appear visible and then again with the flag turned off to make qstyle start fading it out. The previous code that relied on paint events to clear the flag was error prone, and caused the scrollbars to get stuck in an inconsistent state. This change makes sure that the flag gets cleared regardless of whether a paint event in each state is received or not. Task-number: QTBUG-37787 Change-Id: I907697c32cd4d55208a490804a221a5dd6bf7b0b Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qscrollbar.cpp23
-rw-r--r--src/widgets/widgets/qscrollbar_p.h1
2 files changed, 19 insertions, 5 deletions
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 05b8935bb5..5060ca0a70 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -248,8 +248,13 @@ void QScrollBarPrivate::flash()
Q_Q(QScrollBar);
if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) {
flashed = true;
- q->show();
+ if (!q->isVisible())
+ q->show();
+ else
+ q->update();
}
+ if (!flashTimer)
+ flashTimer = q->startTimer(0);
}
void QScrollBarPrivate::activateControl(uint control, int threshold)
@@ -386,6 +391,7 @@ void QScrollBarPrivate::init()
pointerOutsidePressedControl = false;
transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q);
flashed = false;
+ flashTimer = 0;
q->setFocusPolicy(Qt::NoFocus);
QSizePolicy sp(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Slider);
if (orientation == Qt::Vertical)
@@ -476,6 +482,7 @@ void QScrollBar::sliderChange(SliderChange change)
*/
bool QScrollBar::event(QEvent *event)
{
+ Q_D(QScrollBar);
switch(event->type()) {
case QEvent::HoverEnter:
case QEvent::HoverLeave:
@@ -486,6 +493,16 @@ bool QScrollBar::event(QEvent *event)
case QEvent::StyleChange:
d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this));
break;
+ case QEvent::Timer:
+ if (static_cast<QTimerEvent *>(event)->timerId() == d->flashTimer) {
+ if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) {
+ d->flashed = false;
+ update();
+ }
+ killTimer(d->flashTimer);
+ d->flashTimer = 0;
+ }
+ break;
default:
break;
}
@@ -536,10 +553,6 @@ void QScrollBar::paintEvent(QPaintEvent *)
opt.activeSubControls = (QStyle::SubControl)d->hoverControl;
}
style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this);
- if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) {
- d->flashed = false;
- update();
- }
}
/*!
diff --git a/src/widgets/widgets/qscrollbar_p.h b/src/widgets/widgets/qscrollbar_p.h
index c62c337a40..5fc714d530 100644
--- a/src/widgets/widgets/qscrollbar_p.h
+++ b/src/widgets/widgets/qscrollbar_p.h
@@ -81,6 +81,7 @@ public:
void setTransient(bool value);
bool flashed;
+ int flashTimer;
void flash();
};