Files
dragonpilot/selfdrive/ui/qt/widgets/scrollview.cc
Dean Lee 7222d0f20d Cleanup selfdrive/ includes (#20822)
* cleanup include path

* continue

* format includes

* fix testraw.cc

* remove include path from SConstruct

* regroup

* rebase master

* almost done

* apply review

* rename FileReader.xx to filereader.xx

* rename Unlogger.x->unlogger.x

* rename FrameReader.xx -> framereader.xx

* apply reviews

* ui.h

* continue

* fix framebuffer.cc build error:mv util.h up

* full path to msm_media_info

* fix qcom2 camerad

Co-authored-by: Comma Device <device@comma.ai>
2021-05-08 22:15:17 -07:00

48 lines
1.5 KiB
C++

#include "scrollview.h"
#include <QScrollBar>
ScrollView::ScrollView(QWidget *w, QWidget *parent) : QScrollArea(parent){
setWidget(w);
setWidgetResizable(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setStyleSheet("ScrollView { background-color:transparent; }");
QString style = R"(
QScrollBar:vertical {
border: none;
background: transparent;
width:10px;
margin: 0;
}
QScrollBar::handle:vertical {
min-height: 0px;
border-radius: 4px;
background-color: white;
}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
height: 0px;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
)";
verticalScrollBar()->setStyleSheet(style);
horizontalScrollBar()->setStyleSheet(style);
QScroller *scroller = QScroller::scroller(this->viewport());
QScrollerProperties sp = scroller->scrollerProperties();
sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff));
sp.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff));
scroller->grabGesture(this->viewport(), QScroller::LeftMouseButtonGesture);
scroller->setScrollerProperties(sp);
}
void ScrollView::hideEvent(QHideEvent *e){
verticalScrollBar()->setValue(0);
}