chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -7,44 +7,33 @@
|
||||
#include "private/ElaGraphicsViewPrivate.h"
|
||||
Q_PROPERTY_CREATE_Q_CPP(ElaGraphicsView, qreal, MaxTransform);
|
||||
Q_PROPERTY_CREATE_Q_CPP(ElaGraphicsView, qreal, MinTransform);
|
||||
ElaGraphicsView::ElaGraphicsView(QWidget* parent)
|
||||
: QGraphicsView(parent), d_ptr(new ElaGraphicsViewPrivate())
|
||||
{
|
||||
ElaGraphicsView::ElaGraphicsView(QWidget *parent) : QGraphicsView(parent), d_ptr(new ElaGraphicsViewPrivate()) {
|
||||
Q_D(ElaGraphicsView);
|
||||
d->q_ptr = this;
|
||||
d->q_ptr = this;
|
||||
d->_pMaxTransform = 5;
|
||||
d->_pMinTransform = 0.15;
|
||||
d->_initStyle();
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
}
|
||||
|
||||
ElaGraphicsView::ElaGraphicsView(QGraphicsScene* scene, QWidget* parent)
|
||||
: QGraphicsView(scene, parent), d_ptr(new ElaGraphicsViewPrivate())
|
||||
{
|
||||
ElaGraphicsView::ElaGraphicsView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent), d_ptr(new ElaGraphicsViewPrivate()) {
|
||||
Q_D(ElaGraphicsView);
|
||||
d->q_ptr = this;
|
||||
d->q_ptr = this;
|
||||
d->_pMaxTransform = 5;
|
||||
d->_pMinTransform = 0.15;
|
||||
d->_initStyle();
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
}
|
||||
|
||||
ElaGraphicsView::~ElaGraphicsView()
|
||||
{
|
||||
}
|
||||
ElaGraphicsView::~ElaGraphicsView() {}
|
||||
|
||||
void ElaGraphicsView::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
void ElaGraphicsView::wheelEvent(QWheelEvent *event) {
|
||||
Q_D(ElaGraphicsView);
|
||||
if (event->modifiers() == Qt::CTRL)
|
||||
{
|
||||
if (event->modifiers() == Qt::CTRL) {
|
||||
// 放大
|
||||
if ((event->angleDelta().y() > 0) && transform().m11() <= d->_pMaxTransform)
|
||||
{
|
||||
if ((event->angleDelta().y() > 0) && transform().m11() <= d->_pMaxTransform) {
|
||||
this->scale(1.1, 1.1);
|
||||
}
|
||||
else if ((event->angleDelta().y() < 0) && transform().m11() >= d->_pMinTransform)
|
||||
{
|
||||
} else if ((event->angleDelta().y() < 0) && transform().m11() >= d->_pMinTransform) {
|
||||
this->scale(1.0 / 1.1, 1.0 / 1.1);
|
||||
}
|
||||
return;
|
||||
@@ -52,19 +41,15 @@ void ElaGraphicsView::wheelEvent(QWheelEvent* event)
|
||||
QGraphicsView::wheelEvent(event);
|
||||
}
|
||||
|
||||
void ElaGraphicsView::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Alt)
|
||||
{
|
||||
void ElaGraphicsView::keyPressEvent(QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_Alt) {
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
}
|
||||
QGraphicsView::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void ElaGraphicsView::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Alt)
|
||||
{
|
||||
void ElaGraphicsView::keyReleaseEvent(QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_Alt) {
|
||||
setDragMode(QGraphicsView::RubberBandDrag);
|
||||
}
|
||||
QGraphicsView::keyReleaseEvent(event);
|
||||
|
||||
Reference in New Issue
Block a user