Changeset View
Standalone View
lib/documentview/documentview.cpp
Show All 35 Lines | |||||
36 | #include <QPropertyAnimation> | 36 | #include <QPropertyAnimation> | ||
37 | #include <QPointer> | 37 | #include <QPointer> | ||
38 | #include <QDebug> | 38 | #include <QDebug> | ||
39 | #include <QIcon> | 39 | #include <QIcon> | ||
40 | #include <QUrl> | 40 | #include <QUrl> | ||
41 | #include <QDrag> | 41 | #include <QDrag> | ||
42 | #include <QMimeData> | 42 | #include <QMimeData> | ||
43 | #include <QStyleHints> | 43 | #include <QStyleHints> | ||
44 | #include <QGestureEvent> | ||||
45 | #include <QTouchEvent> | ||||
44 | 46 | | |||
ngraham: Unnecessary whitespace change | |||||
45 | // KDE | 47 | // KDE | ||
46 | #include <KLocalizedString> | 48 | #include <KLocalizedString> | ||
47 | #include <KFileItem> | 49 | #include <KFileItem> | ||
48 | 50 | | |||
ngraham: Unnecessary whitespace change | |||||
49 | // Local | 51 | // Local | ||
50 | #include <lib/document/document.h> | 52 | #include <lib/document/document.h> | ||
51 | #include <lib/document/documentfactory.h> | 53 | #include <lib/document/documentfactory.h> | ||
52 | #include <lib/documentview/abstractrasterimageviewtool.h> | 54 | #include <lib/documentview/abstractrasterimageviewtool.h> | ||
53 | #include <lib/documentview/birdeyeview.h> | 55 | #include <lib/documentview/birdeyeview.h> | ||
54 | #include <lib/documentview/loadingindicator.h> | 56 | #include <lib/documentview/loadingindicator.h> | ||
55 | #include <lib/documentview/messageviewadapter.h> | 57 | #include <lib/documentview/messageviewadapter.h> | ||
56 | #include <lib/documentview/rasterimageview.h> | 58 | #include <lib/documentview/rasterimageview.h> | ||
57 | #include <lib/documentview/rasterimageviewadapter.h> | 59 | #include <lib/documentview/rasterimageviewadapter.h> | ||
58 | #include <lib/documentview/svgviewadapter.h> | 60 | #include <lib/documentview/svgviewadapter.h> | ||
59 | #include <lib/documentview/videoviewadapter.h> | 61 | #include <lib/documentview/videoviewadapter.h> | ||
60 | #include <lib/hud/hudbutton.h> | 62 | #include <lib/hud/hudbutton.h> | ||
61 | #include <lib/hud/hudwidget.h> | 63 | #include <lib/hud/hudwidget.h> | ||
62 | #include <lib/graphicswidgetfloater.h> | 64 | #include <lib/graphicswidgetfloater.h> | ||
63 | #include <lib/gvdebug.h> | 65 | #include <lib/gvdebug.h> | ||
64 | #include <lib/gwenviewconfig.h> | 66 | #include <lib/gwenviewconfig.h> | ||
65 | #include <lib/mimetypeutils.h> | 67 | #include <lib/mimetypeutils.h> | ||
66 | #include <lib/signalblocker.h> | 68 | #include <lib/signalblocker.h> | ||
67 | #include <lib/urlutils.h> | 69 | #include <lib/urlutils.h> | ||
68 | #include <lib/thumbnailview/dragpixmapgenerator.h> | 70 | #include <lib/thumbnailview/dragpixmapgenerator.h> | ||
69 | #include <lib/thumbnailprovider/thumbnailprovider.h> | 71 | #include <lib/thumbnailprovider/thumbnailprovider.h> | ||
72 | #include <transformimageoperation.h> | ||||
70 | 73 | | |||
71 | namespace Gwenview | 74 | namespace Gwenview | ||
72 | { | 75 | { | ||
73 | 76 | | |||
74 | #undef ENABLE_LOG | 77 | #undef ENABLE_LOG | ||
75 | #undef LOG | 78 | #undef LOG | ||
76 | //#define ENABLE_LOG | 79 | //#define ENABLE_LOG | ||
77 | #ifdef ENABLE_LOG | 80 | #ifdef ENABLE_LOG | ||
Show All 18 Lines | 97 | { | |||
96 | int mSortKey; // Used to sort views when displayed in compare mode | 99 | int mSortKey; // Used to sort views when displayed in compare mode | ||
97 | HudWidget* mHud; | 100 | HudWidget* mHud; | ||
98 | BirdEyeView* mBirdEyeView; | 101 | BirdEyeView* mBirdEyeView; | ||
99 | QPointer<QPropertyAnimation> mMoveAnimation; | 102 | QPointer<QPropertyAnimation> mMoveAnimation; | ||
100 | QPointer<QPropertyAnimation> mFadeAnimation; | 103 | QPointer<QPropertyAnimation> mFadeAnimation; | ||
101 | QGraphicsOpacityEffect* mOpacityEffect; | 104 | QGraphicsOpacityEffect* mOpacityEffect; | ||
102 | 105 | | |||
103 | LoadingIndicator* mLoadingIndicator; | 106 | LoadingIndicator* mLoadingIndicator; | ||
104 | 107 | | |||
ngraham: Unnecessary whitespace change | |||||
105 | QScopedPointer<AbstractDocumentViewAdapter> mAdapter; | 108 | QScopedPointer<AbstractDocumentViewAdapter> mAdapter; | ||
106 | QList<qreal> mZoomSnapValues; | 109 | QList<qreal> mZoomSnapValues; | ||
107 | Document::Ptr mDocument; | 110 | Document::Ptr mDocument; | ||
108 | DocumentView::Setup mSetup; | 111 | DocumentView::Setup mSetup; | ||
109 | bool mCurrent; | 112 | bool mCurrent; | ||
110 | bool mCompareMode; | 113 | bool mCompareMode; | ||
111 | int controlWheelAccumulatedDelta; | 114 | int controlWheelAccumulatedDelta; | ||
112 | 115 | | |||
113 | QPointF mDragStartPosition; | 116 | QPointF mDragStartPosition; | ||
114 | QPointer<ThumbnailProvider> mDragThumbnailProvider; | 117 | QPointer<ThumbnailProvider> mDragThumbnailProvider; | ||
115 | QPointer<QDrag> mDrag; | 118 | QPointer<QDrag> mDrag; | ||
119 | qint64 timestamp; | ||||
120 | qint64 lastTouchUpdateTimestamp; | ||||
121 | qint64 lastTabtimestamp; | ||||
rkflx: It's `Tap`, not `Tab` (applies everywhere). | |||||
122 | qreal lastRotation; | ||||
123 | bool firstMoving; | ||||
124 | QPointF startCenterPoint; | ||||
125 | bool dragIsStarted; | ||||
126 | bool noPinch; | ||||
127 | bool isOnlyTab; | ||||
Member variables should be prefixed with a lowercase m. Also, some of the names are too generic, e.g. timestamp in the context of DocumentView is not descriptive enough. That said, I wonder why all of those variables are really necessary. Is there no Qt mechanism to differentiate between different gesture and to get at timestamps or positions of gestures? rkflx: Member variables should be prefixed with a lowercase `m`.
Also, some of the names are too… | |||||
116 | 128 | | |||
117 | void setCurrentAdapter(AbstractDocumentViewAdapter* adapter) | 129 | void setCurrentAdapter(AbstractDocumentViewAdapter* adapter) | ||
118 | { | 130 | { | ||
119 | Q_ASSERT(adapter); | 131 | Q_ASSERT(adapter); | ||
120 | mAdapter.reset(adapter); | 132 | mAdapter.reset(adapter); | ||
121 | 133 | | |||
122 | adapter->widget()->setParentItem(q); | 134 | adapter->widget()->setParentItem(q); | ||
123 | resizeAdapterWidget(); | 135 | resizeAdapterWidget(); | ||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Line(s) | 435 | { | |||
428 | d->q = this; | 440 | d->q = this; | ||
429 | d->mLoadingIndicator = nullptr; | 441 | d->mLoadingIndicator = nullptr; | ||
430 | d->mBirdEyeView = nullptr; | 442 | d->mBirdEyeView = nullptr; | ||
431 | d->mCurrent = false; | 443 | d->mCurrent = false; | ||
432 | d->mCompareMode = false; | 444 | d->mCompareMode = false; | ||
433 | d->controlWheelAccumulatedDelta = 0; | 445 | d->controlWheelAccumulatedDelta = 0; | ||
434 | d->mDragStartPosition = QPointF(0, 0); | 446 | d->mDragStartPosition = QPointF(0, 0); | ||
435 | d->mDrag = nullptr; | 447 | d->mDrag = nullptr; | ||
448 | grabGesture(Qt::PinchGesture); | ||||
449 | setAcceptTouchEvents (true); | ||||
rkflx: Remove extra space before `(`. | |||||
436 | 450 | | |||
451 | d->lastTabtimestamp = 0; | ||||
437 | // We use an opacity effect instead of using the opacity property directly, because the latter operates at | 452 | // We use an opacity effect instead of using the opacity property directly, because the latter operates at | ||
438 | // the painter level, which means if you draw multiple layers in paint(), all layers get the specified | 453 | // the painter level, which means if you draw multiple layers in paint(), all layers get the specified | ||
439 | // opacity, resulting in all layers being visible when 0 < opacity < 1. | 454 | // opacity, resulting in all layers being visible when 0 < opacity < 1. | ||
If the reason why this code is commented out is because the features haven't been implemented yet, please add a comment indicating this. ngraham: If the reason why this code is commented out is because the features haven't been implemented… | |||||
440 | // QGraphicsEffects on the other hand, operate after all painting is done, therefore 'flattening' all layers. | 455 | // QGraphicsEffects on the other hand, operate after all painting is done, therefore 'flattening' all layers. | ||
441 | // This is important for fade effects, where we don't want any background layers visible during the fade. | 456 | // This is important for fade effects, where we don't want any background layers visible during the fade. | ||
442 | d->mOpacityEffect = new QGraphicsOpacityEffect(this); | 457 | d->mOpacityEffect = new QGraphicsOpacityEffect(this); | ||
443 | d->mOpacityEffect->setOpacity(0); | 458 | d->mOpacityEffect->setOpacity(0); | ||
444 | setGraphicsEffect(d->mOpacityEffect); | 459 | setGraphicsEffect(d->mOpacityEffect); | ||
445 | 460 | | |||
446 | scene->addItem(this); | 461 | scene->addItem(this); | ||
447 | 462 | | |||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Line(s) | 679 | { | |||
665 | d->setZoom(zoom); | 680 | d->setZoom(zoom); | ||
666 | } | 681 | } | ||
667 | 682 | | |||
668 | qreal DocumentView::zoom() const | 683 | qreal DocumentView::zoom() const | ||
669 | { | 684 | { | ||
670 | return d->mAdapter->zoom(); | 685 | return d->mAdapter->zoom(); | ||
671 | } | 686 | } | ||
672 | 687 | | |||
688 | bool DocumentView::event(QEvent *event) | ||||
I did not review event, gestureEvent and the corresponding functions in ThumbnailView in detail yet, but some general comments:
rkflx: I did not review `event`, `gestureEvent` and the corresponding functions in `ThumbnailView` in… | |||||
689 | { | ||||
690 | if (event->type() == QEvent::TouchBegin) { | ||||
691 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | ||||
692 | event->accept(); | ||||
Coding style: opening braces in if statements go on the same line (do the same below, too). ngraham: Coding style: opening braces in `if` statements go on the same line (do the same below, too). | |||||
693 | d->timestamp = touchEvent->timestamp(); | ||||
694 | d->firstMoving = true; | ||||
695 | d->dragIsStarted = false; | ||||
ngraham: Coding style: add spaces around the `=` (do the same below, too). | |||||
696 | d->isOnlyTab = true; | ||||
697 | QObject *receiver = touchEvent->target(); | ||||
698 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
699 | QMouseEvent *evt = new QMouseEvent(QEvent::MouseMove,pos, Qt::NoButton, Qt::NoButton,0); | ||||
700 | QCoreApplication::postEvent(receiver,evt); | ||||
701 | return true; | ||||
702 | } | ||||
703 | | ||||
704 | if (event->type() == QEvent::TouchUpdate) { | ||||
705 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | ||||
Coding style: this line is very long and a bit difficult to read. Might be better formatted with variables, like so: const QPointF start = touchevent->touchPoints().at(0).startPos(); const QPointF end = touchevent->touchPoints().at(0).pos(); QPoint diff = start - end; ngraham: Coding style: this line is very long and a bit difficult to read. Might be better formatted… | |||||
706 | event->accept(); | ||||
707 | d->isOnlyTab = false; | ||||
708 | d->lastTouchUpdateTimestamp = touchEvent->timestamp(); | ||||
709 | if (touchEvent->touchPoints().size() == 2) { | ||||
710 | if (touchEvent->touchPoints().at(0).state() == Qt::TouchPointReleased || touchEvent->touchPoints().at(1).state() == Qt::TouchPointReleased ) { | ||||
711 | d->noPinch = true; | ||||
Coding style: comments should be in English. @rkflx (or many others) can probably provide an English translation for you. ngraham: Coding style: comments should be in English. @rkflx (or many others) can probably provide an… | |||||
712 | return true; | ||||
ngraham: Coding style: space after the `<` | |||||
713 | } | ||||
714 | d->noPinch = true; | ||||
ngraham: Coding style: indent this line (do the same below, too). | |||||
715 | if (d->lastTouchUpdateTimestamp - d->timestamp >= 200) { | ||||
716 | QPointF startone = touchEvent->touchPoints().at(0).startPos(); | ||||
717 | QPointF starttwo = touchEvent->touchPoints().at(1).startPos(); | ||||
718 | QPointF endone = touchEvent->touchPoints().at(0).pos(); | ||||
719 | QPointF endtwo = touchEvent->touchPoints().at(1).pos(); | ||||
720 | QPointF vectorone = startone - endone; | ||||
721 | QPointF vectortwo = starttwo - endtwo; | ||||
722 | int x = (vectorone).x() * (vectortwo).x(); | ||||
723 | int y = (vectorone).y() * (vectortwo).y(); | ||||
724 | if (x == 0 && y>0) x=1; | ||||
725 | if (y == 0 && x>0) y=1; | ||||
726 | if (x >= -500 && x<0 && y>0) x=1; | ||||
ngraham: Coding style: unnecessary whitespace | |||||
727 | if (y >= -500 && y<0 && x>0) y=1; | ||||
728 | if (x>0 && y>0) { | ||||
729 | d->noPinch = true; | ||||
730 | QPointF lastPos = touchEvent->touchPoints().at(0).lastPos(); | ||||
731 | QPointF pos = touchEvent->touchPoints().at(0).pos(); | ||||
732 | QPointF diff = lastPos - pos; | ||||
733 | d->mAdapter->setScrollPos(d->mAdapter->scrollPos() + diff); | ||||
734 | } else { | ||||
735 | if (vectorone.manhattanLength() > 50 || vectortwo.manhattanLength() > 50){ | ||||
736 | d->noPinch = false; | ||||
737 | } | ||||
738 | } | ||||
Coding style: insufficient indentation for this level and everything below it ngraham: Coding style: insufficient indentation for this level and everything below it | |||||
739 | } | ||||
740 | return true; | ||||
741 | } | ||||
742 | | ||||
743 | if (touchEvent->touchPoints().size() == 1) { | ||||
744 | qint64 now = touchEvent->timestamp(); | ||||
745 | QPointF startPos = touchEvent->touchPoints().at(0).startPos(); | ||||
746 | QPointF nowPos = touchEvent->touchPoints().at(0).pos(); | ||||
747 | if (d->firstMoving && now - d->timestamp >= 400 && (nowPos - startPos).manhattanLength() < 20) { | ||||
748 | if (!d->dragIsStarted) { | ||||
749 | d->dragIsStarted = true; | ||||
750 | d->startDragIfSensible(); | ||||
751 | } | ||||
752 | d->firstMoving = false; | ||||
753 | return true; | ||||
ngraham: coding style: add whitespace around the `,` | |||||
754 | } | ||||
755 | if (d->dragIsStarted) { | ||||
756 | QGraphicsWidget *receiver = this; | ||||
757 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
758 | QMouseEvent *evt = new QMouseEvent(QEvent::MouseMove,pos, Qt::NoButton, Qt::LeftButton,0); | ||||
759 | QCoreApplication::postEvent(receiver,evt); | ||||
760 | d->firstMoving = false; | ||||
761 | return true; | ||||
762 | } | ||||
763 | QPointF lastPos = touchEvent->touchPoints().at(0).lastPos(); | ||||
764 | QPointF pos = touchEvent->touchPoints().at(0).pos(); | ||||
765 | QPointF diff = lastPos - pos; | ||||
766 | d->mAdapter->setScrollPos(d->mAdapter->scrollPos() + diff); | ||||
767 | d->firstMoving = false; | ||||
768 | return true; | ||||
769 | } | ||||
770 | } | ||||
771 | | ||||
772 | if (event->type() == QEvent::TouchEnd) { | ||||
773 | event->accept(); | ||||
774 | d->firstMoving = false; | ||||
775 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | ||||
776 | if (d->dragIsStarted) { | ||||
777 | QGraphicsWidget *receiver = this; | ||||
778 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
779 | QMouseEvent *evt = new QMouseEvent(QEvent::MouseButtonRelease,pos, Qt::LeftButton, Qt::LeftButton,0); | ||||
780 | QCoreApplication::postEvent(receiver,evt); | ||||
781 | d->dragIsStarted = false; | ||||
782 | d->lastTabtimestamp = d->timestamp; | ||||
783 | return true; | ||||
784 | } | ||||
785 | const QPointF start = touchEvent->touchPoints().at(0).startPos(); | ||||
786 | const QPointF end = touchEvent->touchPoints().at(0).pos(); | ||||
787 | QPointF diff = start - end; | ||||
788 | qint64 now = touchEvent->timestamp(); | ||||
789 | qint64 time = now - d->timestamp; | ||||
790 | qreal doupleclicktime = QGuiApplication::styleHints()->mouseDoubleClickInterval(); | ||||
ngraham: Should probably be `sensitivityModifier` | |||||
791 | if (now - d->lastTabtimestamp <= doupleclicktime && d->isOnlyTab){ | ||||
792 | d->mAdapter->toggleFullScreenRequested(); | ||||
793 | d->lastTabtimestamp = 0; | ||||
794 | return true; | ||||
795 | } | ||||
796 | if (now - d->lastTabtimestamp > doupleclicktime && d->isOnlyTab ){ | ||||
797 | QPoint pos = touchEvent->touchPoints().at(0).startScenePos().toPoint(); | ||||
798 | QPoint screenPos = touchEvent->touchPoints().at(0).screenPos().toPoint(); | ||||
799 | QObject *receiver = touchEvent->target(); | ||||
800 | QMouseEvent *evt = new QMouseEvent(QEvent::MouseButtonPress,pos,screenPos, Qt::LeftButton, Qt::LeftButton,0); | ||||
801 | QCoreApplication::postEvent(receiver,evt); | ||||
802 | QMouseEvent *evtr = new QMouseEvent(QEvent::MouseButtonRelease,pos,screenPos, Qt::LeftButton, Qt::LeftButton,0); | ||||
803 | QCoreApplication::postEvent(receiver,evtr); | ||||
804 | } | ||||
805 | if (touchEvent->touchPoints().size() <= 2 && diff.manhattanLength() > 200 && time < 300) { | ||||
806 | if (diff.x() < 0 && abs(diff.x()) >= abs(diff.y()) * 2) { | ||||
807 | QPoint scrollPos = d->mAdapter->scrollPos().toPoint(); | ||||
808 | if (scrollPos.x() <= 1) { | ||||
809 | d->mAdapter->previousImageRequested(); | ||||
810 | } | ||||
811 | } | ||||
812 | if (diff.x() > 0 && abs(diff.x()) >= abs(diff.y()) * 2) { | ||||
813 | QPoint scrollPos = d->mAdapter->scrollPos().toPoint(); | ||||
814 | int width = d->mAdapter->document()->width() * d->mAdapter->zoom(); | ||||
815 | QRect visibleRect = d->mAdapter->visibleDocumentRect().toRect(); | ||||
816 | int x = scrollPos.x() + visibleRect.width(); | ||||
817 | if (x >= (width - 1)) { | ||||
818 | d->mAdapter->nextImageRequested(); | ||||
819 | } | ||||
820 | } | ||||
821 | } | ||||
822 | d->lastTabtimestamp = d->timestamp; | ||||
823 | return true; | ||||
824 | } | ||||
825 | | ||||
826 | if ( event->type() == QEvent::Gesture ) { | ||||
827 | return gestureEvent(static_cast<QGestureEvent *>( event )); | ||||
828 | } | ||||
829 | return QGraphicsWidget::event( event ); | ||||
830 | } | ||||
831 | | ||||
832 | bool DocumentView::gestureEvent( QGestureEvent *event ) | ||||
833 | { | ||||
834 | QPinchGesture *pinch = static_cast<QPinchGesture *>(event->gesture(Qt::PinchGesture)); | ||||
835 | const qreal rotationThreshold = 50; | ||||
836 | | ||||
837 | if (pinch) | ||||
838 | { | ||||
839 | event->accept(); | ||||
840 | if (pinch->state() == Qt::GestureStarted) { | ||||
841 | d->lastRotation = 0; | ||||
842 | d->startCenterPoint = pinch->centerPoint(); | ||||
843 | } | ||||
844 | | ||||
845 | if (pinch->state() == Qt::GestureUpdated && !d->noPinch) { | ||||
846 | if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged) { | ||||
847 | if (d->mAdapter->canZoom()) { | ||||
848 | if ((d->startCenterPoint - pinch->centerPoint()).manhattanLength() <= 600) { | ||||
849 | qreal currentZoom = d->mAdapter->zoom(); | ||||
850 | qreal sensitivModifier = 0.4; | ||||
851 | qreal zoom; | ||||
852 | if (pinch->scaleFactor() >= 1.0){ | ||||
853 | zoom = ((pinch->scaleFactor() - 1.0) * sensitivModifier + 1.0) * currentZoom; | ||||
854 | } else { | ||||
855 | zoom = (1.0 - (1.0 - pinch->scaleFactor()) * sensitivModifier) * currentZoom; | ||||
856 | } | ||||
857 | QPointF zoomCenter = mapFromScene(event->mapToGraphicsScene(pinch->centerPoint())); | ||||
858 | d->setZoom(zoom,zoomCenter); | ||||
859 | } | ||||
860 | } | ||||
861 | } | ||||
862 | | ||||
863 | if (pinch->changeFlags() & QPinchGesture::RotationAngleChanged) { | ||||
864 | if ((d->startCenterPoint - pinch->centerPoint()).manhattanLength() <= 150) { | ||||
865 | if (pinch->rotationAngle() - d->lastRotation > rotationThreshold) { | ||||
866 | TransformImageOperation *op = new TransformImageOperation(ROT_90); | ||||
867 | op->applyToDocument(d->mDocument); | ||||
868 | d->lastRotation = pinch->rotationAngle(); | ||||
869 | } | ||||
870 | else if (-(pinch->rotationAngle() - d->lastRotation) > rotationThreshold) { | ||||
871 | TransformImageOperation *op = new TransformImageOperation(ROT_270); | ||||
872 | op->applyToDocument(d->mDocument); | ||||
873 | d->lastRotation = pinch->rotationAngle(); | ||||
874 | } | ||||
875 | } | ||||
876 | } | ||||
877 | } | ||||
878 | | ||||
879 | if (pinch->state() == Qt::GestureFinished) { | ||||
880 | d->lastRotation = 0; | ||||
881 | d->startCenterPoint = QPointF (0,0); | ||||
882 | } | ||||
883 | return true; | ||||
884 | } | ||||
885 | return false; | ||||
886 | } | ||||
887 | | ||||
673 | void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event) | 888 | void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event) | ||
674 | { | 889 | { | ||
675 | d->resizeAdapterWidget(); | 890 | d->resizeAdapterWidget(); | ||
676 | d->updateZoomSnapValues(); | 891 | d->updateZoomSnapValues(); | ||
677 | QGraphicsWidget::resizeEvent(event); | 892 | QGraphicsWidget::resizeEvent(event); | ||
678 | } | 893 | } | ||
679 | 894 | | |||
680 | void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event) | 895 | void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event) | ||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 1095 | if (event->type() == QEvent::GraphicsSceneMousePress) { | |||
884 | } | 1099 | } | ||
885 | QMetaObject::invokeMethod(this, "emitFocused", Qt::QueuedConnection); | 1100 | QMetaObject::invokeMethod(this, "emitFocused", Qt::QueuedConnection); | ||
886 | } else if (event->type() == QEvent::GraphicsSceneHoverMove) { | 1101 | } else if (event->type() == QEvent::GraphicsSceneHoverMove) { | ||
887 | if (d->mBirdEyeView) { | 1102 | if (d->mBirdEyeView) { | ||
888 | d->mBirdEyeView->onMouseMoved(); | 1103 | d->mBirdEyeView->onMouseMoved(); | ||
889 | } | 1104 | } | ||
890 | } else if (event->type() == QEvent::GraphicsSceneMouseMove) { | 1105 | } else if (event->type() == QEvent::GraphicsSceneMouseMove) { | ||
891 | const QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); | 1106 | const QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); | ||
1107 | if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt){ | ||||
rkflx: Space before `{` missing. | |||||
ngraham: Which older versions? If it's older than 5.9, we don't need this. | |||||
can we keep this for the moment, because I need it on my working system (OpenSUSE Leap, Qt 5.9.4, KDE 5.45) ? steffenh: can we keep this for the moment, because I need it on my working system (OpenSUSE Leap, Qt 5.9. | |||||
ngraham: OK. | |||||
1108 | return true; | ||||
1109 | } | ||||
892 | const qreal dragDistance = (mouseEvent->pos() - d->mDragStartPosition).manhattanLength(); | 1110 | const qreal dragDistance = (mouseEvent->pos() - d->mDragStartPosition).manhattanLength(); | ||
893 | const qreal minDistanceToStartDrag = QGuiApplication::styleHints()->startDragDistance(); | 1111 | const qreal minDistanceToStartDrag = QGuiApplication::styleHints()->startDragDistance(); | ||
894 | if (!d->canPan() && dragDistance >= minDistanceToStartDrag) { | 1112 | if (!d->canPan() && dragDistance >= minDistanceToStartDrag && mouseEvent->source() == Qt::MouseEventNotSynthesized) { | ||
rkflx: Is this still needed given the check above? | |||||
895 | d->startDragIfSensible(); | 1113 | d->startDragIfSensible(); | ||
896 | } | 1114 | } | ||
897 | } | 1115 | } | ||
898 | return false; | 1116 | return false; | ||
899 | } | 1117 | } | ||
900 | 1118 | | |||
901 | AbstractRasterImageViewTool* DocumentView::currentTool() const | 1119 | AbstractRasterImageViewTool* DocumentView::currentTool() const | ||
902 | { | 1120 | { | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Unnecessary whitespace change