7#ifndef KO_TOOLBOX_SCROLL_AREA_H
8#define KO_TOOLBOX_SCROLL_AREA_H
16#include <QStyleOption>
31 setFrameShape(QFrame::NoFrame);
32 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
33 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
52 QScroller::grabGesture(viewport(), QScroller::MiddleMouseButtonGesture);
53 scroller = QScroller::scroller(viewport());
54 QScrollerProperties sp = scroller->scrollerProperties();
56 sp.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.0);
57 sp.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.1);
58 sp.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.1);
59 sp.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.0);
60 sp.setScrollMetric(QScrollerProperties::OvershootScrollTime, 0.4);
62 scroller->setScrollerProperties(sp);
98 if (
event->type() == QEvent::LayoutRequest) {
104 return QScrollArea::event(
event);
114 return QScrollArea::eventFilter(watched,
event);
120 QScrollArea::resizeEvent(
event);
127 QApplication::sendEvent(verticalScrollBar(),
event);
129 QApplication::sendEvent(horizontalScrollBar(),
event);
135 QScrollArea::scrollContentsBy(dx, dy);
143 verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub);
145 horizontalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub);
152 verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd);
154 horizontalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd);
163 return style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, &opt,
this);
169 QSize newSize = viewport()->size();
189 const QScrollBar *scrollbar =
m_orientation == Qt::Vertical ? verticalScrollBar() : horizontalScrollBar();
190 const bool canPrev = scrollbar->value() != scrollbar->minimum();
191 const bool canNext = scrollbar->value() != scrollbar->maximum();
199 }
else if (isLeftToRight()) {
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))