chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -6,9 +6,7 @@
|
||||
#include "ElaScrollAreaPrivate.h"
|
||||
#include "ElaScrollBar.h"
|
||||
|
||||
ElaScrollArea::ElaScrollArea(QWidget* parent)
|
||||
: QScrollArea(parent), d_ptr(new ElaScrollAreaPrivate())
|
||||
{
|
||||
ElaScrollArea::ElaScrollArea(QWidget *parent) : QScrollArea(parent), d_ptr(new ElaScrollAreaPrivate()) {
|
||||
Q_D(ElaScrollArea);
|
||||
d->q_ptr = this;
|
||||
setObjectName("ElaScrollArea");
|
||||
@@ -19,14 +17,10 @@ ElaScrollArea::ElaScrollArea(QWidget* parent)
|
||||
QScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
|
||||
ElaScrollArea::~ElaScrollArea()
|
||||
{
|
||||
}
|
||||
ElaScrollArea::~ElaScrollArea() {}
|
||||
|
||||
void ElaScrollArea::setIsGrabGesture(bool isEnable, qreal mousePressEventDelay)
|
||||
{
|
||||
if (isEnable)
|
||||
{
|
||||
void ElaScrollArea::setIsGrabGesture(bool isEnable, qreal mousePressEventDelay) {
|
||||
if (isEnable) {
|
||||
QScroller::grabGesture(this->viewport(), QScroller::LeftMouseButtonGesture);
|
||||
QScrollerProperties properties = QScroller::scroller(this->viewport())->scrollerProperties();
|
||||
properties.setScrollMetric(QScrollerProperties::MousePressEventDelay, mousePressEventDelay);
|
||||
@@ -34,46 +28,38 @@ void ElaScrollArea::setIsGrabGesture(bool isEnable, qreal mousePressEventDelay)
|
||||
properties.setScrollMetric(QScrollerProperties::OvershootScrollTime, 0.5);
|
||||
properties.setScrollMetric(QScrollerProperties::FrameRate, QScrollerProperties::Fps60);
|
||||
QScroller::scroller(this->viewport())->setScrollerProperties(properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
QScroller::ungrabGesture(this->viewport());
|
||||
}
|
||||
}
|
||||
|
||||
void ElaScrollArea::setIsOverShoot(Qt::Orientation orientation, bool isEnable)
|
||||
{
|
||||
void ElaScrollArea::setIsOverShoot(Qt::Orientation orientation, bool isEnable) {
|
||||
QScrollerProperties properties = QScroller::scroller(this->viewport())->scrollerProperties();
|
||||
properties.setScrollMetric(orientation == Qt::Horizontal ? QScrollerProperties::HorizontalOvershootPolicy : QScrollerProperties::VerticalOvershootPolicy, isEnable ? QScrollerProperties::OvershootAlwaysOn : QScrollerProperties::OvershootAlwaysOff);
|
||||
properties.setScrollMetric(orientation == Qt::Horizontal ? QScrollerProperties::HorizontalOvershootPolicy
|
||||
: QScrollerProperties::VerticalOvershootPolicy,
|
||||
isEnable ? QScrollerProperties::OvershootAlwaysOn : QScrollerProperties::OvershootAlwaysOff);
|
||||
QScroller::scroller(this->viewport())->setScrollerProperties(properties);
|
||||
}
|
||||
|
||||
bool ElaScrollArea::getIsOverShoot(Qt::Orientation orientation) const
|
||||
{
|
||||
bool ElaScrollArea::getIsOverShoot(Qt::Orientation orientation) const {
|
||||
QScrollerProperties properties = QScroller::scroller(this->viewport())->scrollerProperties();
|
||||
return properties.scrollMetric(orientation == Qt::Horizontal ? QScrollerProperties::HorizontalOvershootPolicy : QScrollerProperties::VerticalOvershootPolicy).toBool();
|
||||
return properties
|
||||
.scrollMetric(orientation == Qt::Horizontal ? QScrollerProperties::HorizontalOvershootPolicy : QScrollerProperties::VerticalOvershootPolicy)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void ElaScrollArea::setIsAnimation(Qt::Orientation orientation, bool isAnimation)
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
dynamic_cast<ElaScrollBar*>(this->horizontalScrollBar())->setIsAnimation(isAnimation);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic_cast<ElaScrollBar*>(this->verticalScrollBar())->setIsAnimation(isAnimation);
|
||||
void ElaScrollArea::setIsAnimation(Qt::Orientation orientation, bool isAnimation) {
|
||||
if (orientation == Qt::Horizontal) {
|
||||
dynamic_cast<ElaScrollBar *>(this->horizontalScrollBar())->setIsAnimation(isAnimation);
|
||||
} else {
|
||||
dynamic_cast<ElaScrollBar *>(this->verticalScrollBar())->setIsAnimation(isAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
bool ElaScrollArea::getIsAnimation(Qt::Orientation orientation) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
return dynamic_cast<ElaScrollBar*>(this->horizontalScrollBar())->getIsAnimation();
|
||||
}
|
||||
else
|
||||
{
|
||||
return dynamic_cast<ElaScrollBar*>(this->verticalScrollBar())->getIsAnimation();
|
||||
bool ElaScrollArea::getIsAnimation(Qt::Orientation orientation) const {
|
||||
if (orientation == Qt::Horizontal) {
|
||||
return dynamic_cast<ElaScrollBar *>(this->horizontalScrollBar())->getIsAnimation();
|
||||
} else {
|
||||
return dynamic_cast<ElaScrollBar *>(this->verticalScrollBar())->getIsAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user