WebViewSmoothScroller::WebViewSmoothScroller (QWebView *view) : QObject { view } , View_ { view } , ScrollTimer_ { new QTimer { this } } { connect (ScrollTimer_, SIGNAL (timeout ()), this, SLOT (handleAutoscroll ())); auto ef = Util::MakeLambdaEventFilter ([this] (QKeyEvent *event) { if (event->modifiers () == Qt::SHIFT && (event->key () == Qt::Key_PageUp || event->key () == Qt::Key_PageDown)) { ScrollDelta_ += event->key () == Qt::Key_PageUp ? -0.1 : 0.1; if (!ScrollTimer_->isActive ()) ScrollTimer_->start (30); return true; } else if (event->modifiers () == Qt::SHIFT && event->key () == Qt::Key_Plus) { ScrollDelta_ = 0; ScrollTimer_->stop (); return true; } return false; }, this); view->installEventFilter (ef); }
void HScrollBar::logic( double timeElapsed ) { handleAutoscroll(timeElapsed); }