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 dontZoom; | ||||
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 | | |||
437 | // We use an opacity effect instead of using the opacity property directly, because the latter operates at | 451 | // 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 | 452 | // 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. | 453 | // opacity, resulting in all layers being visible when 0 < opacity < 1. | ||
440 | // QGraphicsEffects on the other hand, operate after all painting is done, therefore 'flattening' all layers. | 454 | // QGraphicsEffects on the other hand, operate after all painting is done, therefore 'flattening' all layers. | ||
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… | |||||
441 | // This is important for fade effects, where we don't want any background layers visible during the fade. | 455 | // This is important for fade effects, where we don't want any background layers visible during the fade. | ||
442 | d->mOpacityEffect = new QGraphicsOpacityEffect(this); | 456 | d->mOpacityEffect = new QGraphicsOpacityEffect(this); | ||
443 | d->mOpacityEffect->setOpacity(0); | 457 | d->mOpacityEffect->setOpacity(0); | ||
444 | setGraphicsEffect(d->mOpacityEffect); | 458 | setGraphicsEffect(d->mOpacityEffect); | ||
445 | 459 | | |||
446 | scene->addItem(this); | 460 | scene->addItem(this); | ||
447 | 461 | | |||
448 | d->setupHud(); | 462 | d->setupHud(); | ||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | 678 | { | |||
665 | d->setZoom(zoom); | 679 | d->setZoom(zoom); | ||
666 | } | 680 | } | ||
667 | 681 | | |||
668 | qreal DocumentView::zoom() const | 682 | qreal DocumentView::zoom() const | ||
669 | { | 683 | { | ||
670 | return d->mAdapter->zoom(); | 684 | return d->mAdapter->zoom(); | ||
671 | } | 685 | } | ||
672 | 686 | | |||
687 | 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… | |||||
688 | { | ||||
689 | if (event->type() == QEvent::TouchBegin) { | ||||
690 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | ||||
691 | 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). | |||||
692 | d->timestamp = touchEvent->timestamp(); | ||||
693 | d->firstMoving = true; | ||||
694 | d->dragIsStarted = false; | ||||
ngraham: Coding style: add spaces around the `=` (do the same below, too). | |||||
695 | d->isOnlyTab = true; | ||||
696 | QGraphicsWidget *receiver = this; | ||||
697 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
698 | QMouseEvent* evt = new QMouseEvent(QEvent::MouseMove,pos, Qt::NoButton, Qt::NoButton,0); | ||||
699 | QCoreApplication::postEvent(receiver,evt); | ||||
700 | QMetaObject::invokeMethod(this, "emitFocused", Qt::QueuedConnection); | ||||
701 | return true; | ||||
702 | } | ||||
703 | | ||||
704 | if (event->type() == QEvent::TouchUpdate) { | ||||
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… | |||||
705 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | ||||
706 | d->isOnlyTab = false; | ||||
707 | d->lastTouchUpdateTimestamp = touchEvent->timestamp(); | ||||
708 | if (touchEvent->touchPoints().size() == 2) { | ||||
709 | d->dontZoom = true; | ||||
710 | if (d->lastTouchUpdateTimestamp - d->timestamp >= 300) { | ||||
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… | |||||
711 | QPointF startone = touchEvent->touchPoints().at(0).startPos(); | ||||
ngraham: Coding style: space after the `<` | |||||
712 | QPointF starttwo = touchEvent->touchPoints().at(1).startPos(); | ||||
713 | QPointF endone = touchEvent->touchPoints().at(0).pos(); | ||||
ngraham: Coding style: indent this line (do the same below, too). | |||||
714 | QPointF endtwo = touchEvent->touchPoints().at(1).pos(); | ||||
715 | QPointF vectorone = startone - endone; | ||||
716 | QPointF vectortwo = starttwo - endtwo; | ||||
717 | int x = (startone - endone).x() * (starttwo - endtwo).x(); | ||||
718 | int y = (startone - endone).y() * (starttwo - endtwo).y(); | ||||
719 | if (x == 0 && y>0) x=1; | ||||
720 | if (y == 0 && x>0) y=1; | ||||
721 | if (x >= -500 && x<0 && y>0) x=1; | ||||
722 | if (y >= -500 && y<0 && x>0) y=1; | ||||
723 | if (x>0 && y>0) { | ||||
724 | d->dontZoom = true; | ||||
725 | QPointF lastPos = touchEvent->touchPoints().at(0).lastPos(); | ||||
ngraham: Coding style: unnecessary whitespace | |||||
726 | QPointF pos = touchEvent->touchPoints().at(0).pos(); | ||||
727 | QPointF diff = lastPos - pos; | ||||
728 | d->mAdapter->setScrollPos(d->mAdapter->scrollPos() + diff); | ||||
729 | } else { | ||||
730 | if (vectorone.manhattanLength() > 50 || vectortwo.manhattanLength() > 50){ | ||||
731 | d->dontZoom = false; | ||||
732 | } | ||||
733 | } | ||||
734 | } | ||||
735 | return true; | ||||
736 | } | ||||
737 | | ||||
Coding style: insufficient indentation for this level and everything below it ngraham: Coding style: insufficient indentation for this level and everything below it | |||||
738 | if (touchEvent->touchPoints().size() == 1) { | ||||
739 | qint64 now = touchEvent->timestamp(); | ||||
740 | QPointF startPos = touchEvent->touchPoints().at(0).startPos(); | ||||
741 | QPointF nowPos = touchEvent->touchPoints().at(0).pos(); | ||||
742 | if (d->firstMoving && now - d->timestamp >= 400 && (nowPos - startPos).manhattanLength() < 20) { | ||||
743 | if (!d->dragIsStarted) { | ||||
744 | d->dragIsStarted = true; | ||||
745 | d->startDragIfSensible(); | ||||
746 | } | ||||
747 | d->firstMoving = false; | ||||
748 | return true; | ||||
749 | } | ||||
750 | if (d->dragIsStarted) { | ||||
751 | QGraphicsWidget *receiver = this; | ||||
752 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
ngraham: coding style: add whitespace around the `,` | |||||
753 | QMouseEvent* evt = new QMouseEvent(QEvent::MouseMove,pos, Qt::NoButton, Qt::LeftButton,0); | ||||
754 | QCoreApplication::postEvent(receiver,evt); | ||||
755 | d->firstMoving = false; | ||||
756 | return true; | ||||
757 | } | ||||
758 | QPointF lastPos = touchEvent->touchPoints().at(0).lastPos(); | ||||
759 | QPointF pos = touchEvent->touchPoints().at(0).pos(); | ||||
760 | QPointF diff = lastPos - pos; | ||||
761 | d->mAdapter->setScrollPos(d->mAdapter->scrollPos() + diff); | ||||
762 | d->firstMoving = false; | ||||
763 | return true; | ||||
764 | } | ||||
765 | } | ||||
766 | | ||||
767 | if (event->type() == QEvent::TouchEnd) { | ||||
768 | d->firstMoving = false; | ||||
769 | QTouchEvent* touchEvent = static_cast<QTouchEvent *>(event); | ||||
770 | if (d->dragIsStarted) { | ||||
771 | QGraphicsWidget *receiver = this; | ||||
772 | QPoint pos = touchEvent->touchPoints().at(0).pos().toPoint(); | ||||
773 | QMouseEvent* evt = new QMouseEvent(QEvent::MouseButtonRelease,pos, Qt::LeftButton, Qt::LeftButton,0); | ||||
774 | QCoreApplication::postEvent(receiver,evt); | ||||
775 | d->dragIsStarted = false; | ||||
776 | return true; | ||||
777 | } | ||||
778 | const QPointF start = touchEvent->touchPoints().at(0).startPos(); | ||||
779 | const QPointF end = touchEvent->touchPoints().at(0).pos(); | ||||
780 | QPointF diff = start - end; | ||||
781 | qint64 now = touchEvent->timestamp(); | ||||
782 | qint64 time = now - d->timestamp; | ||||
783 | qreal doupleclicktime = QGuiApplication::styleHints()->mouseDoubleClickInterval(); | ||||
784 | if (now - d->lastTabtimestamp <= doupleclicktime && d->isOnlyTab){ | ||||
785 | d->mAdapter->toggleFullScreenRequested(); | ||||
786 | return true; | ||||
787 | } | ||||
788 | if (now - d->lastTabtimestamp > doupleclicktime && d->isOnlyTab ){ | ||||
789 | QPoint pos = touchEvent->touchPoints().at(0).startPos().toPoint(); | ||||
ngraham: Should probably be `sensitivityModifier` | |||||
790 | QGraphicsWidget *receiver = this; | ||||
791 | QMouseEvent* evt = new QMouseEvent(QEvent::MouseButtonPress,pos, Qt::LeftButton, Qt::LeftButton,0); | ||||
792 | QCoreApplication::postEvent(receiver,evt); | ||||
793 | QMouseEvent* evtr = new QMouseEvent(QEvent::MouseButtonRelease,pos, Qt::LeftButton, Qt::LeftButton,0); | ||||
794 | QCoreApplication::postEvent(receiver,evtr); | ||||
795 | } | ||||
796 | if (touchEvent->touchPoints().size() <= 2 && diff.manhattanLength() > 200 && time < 300) { | ||||
797 | if (diff.x() < 0 && abs(diff.x()) >= abs(diff.y()) * 2) { | ||||
798 | QPoint scrollPos = d->mAdapter->scrollPos().toPoint(); | ||||
799 | if (scrollPos.x() <= 1) { | ||||
800 | d->mAdapter->previousImageRequested(); | ||||
801 | } | ||||
802 | } | ||||
803 | if (diff.x() > 0 && abs(diff.x()) >= abs(diff.y()) * 2) { | ||||
804 | QPoint scrollPos = d->mAdapter->scrollPos().toPoint(); | ||||
805 | int width = d->mAdapter->document()->width() * d->mAdapter->zoom(); | ||||
806 | QRect visibleRect = d->mAdapter->visibleDocumentRect().toRect(); | ||||
807 | int x = scrollPos.x() + visibleRect.width(); | ||||
808 | if (x >= (width - 1)) { | ||||
809 | d->mAdapter->nextImageRequested(); | ||||
810 | } | ||||
811 | } | ||||
812 | } | ||||
813 | d->lastTabtimestamp = d->timestamp; | ||||
814 | return true; | ||||
815 | } | ||||
816 | | ||||
817 | if ( event->type() == QEvent::Gesture ) { | ||||
818 | return gestureEvent(static_cast<QGestureEvent*>( event )); | ||||
819 | } | ||||
820 | return QGraphicsWidget::event( event ); | ||||
821 | } | ||||
822 | | ||||
823 | bool DocumentView::gestureEvent( QGestureEvent* event ) | ||||
824 | { | ||||
825 | | ||||
826 | QPinchGesture *pinch = static_cast<QPinchGesture*>(event->gesture(Qt::PinchGesture)); | ||||
827 | const int waitingTime = 100; | ||||
828 | const qreal rotationsDelta = 35; | ||||
829 | if (pinch) | ||||
830 | { | ||||
831 | event->accept(); | ||||
832 | if (pinch->state() == Qt::GestureStarted) { | ||||
833 | d->lastRotation = 0; | ||||
834 | d->startCenterPoint = pinch->centerPoint(); | ||||
835 | } | ||||
836 | | ||||
837 | if (pinch->state() == Qt::GestureUpdated) { | ||||
838 | qreal time = d->lastTouchUpdateTimestamp - d->timestamp; | ||||
839 | if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged) { | ||||
840 | if (d->mAdapter->canZoom()) { | ||||
841 | if ((d->startCenterPoint - pinch->centerPoint()).manhattanLength() <= 500 && time >= waitingTime) { | ||||
842 | qreal currentZoom = d->mAdapter->zoom(); | ||||
843 | qreal sensitivModifier = 0.3; | ||||
844 | qreal zoom; | ||||
845 | if (pinch->scaleFactor() >= 1){ | ||||
846 | zoom = ((pinch->scaleFactor() - 1.0) * sensitivModifier + 1.0) * currentZoom; | ||||
847 | } else { | ||||
848 | zoom = (1.0 - (1.0 - pinch->scaleFactor()) * sensitivModifier) * currentZoom; | ||||
849 | } | ||||
850 | qreal diff = currentZoom > zoom ? currentZoom - zoom : zoom - currentZoom; | ||||
851 | if (diff > 0.0001) { | ||||
852 | QPointF zoomCenter = event->mapToGraphicsScene(pinch->centerPoint()) - d->mAdapter->visibleDocumentRect().topLeft(); | ||||
853 | if (!d->dontZoom) { | ||||
854 | d->setZoom(zoom,zoomCenter); | ||||
855 | } | ||||
856 | } | ||||
857 | } | ||||
858 | } | ||||
859 | } | ||||
860 | | ||||
861 | if (pinch->changeFlags() & QPinchGesture::RotationAngleChanged) { | ||||
862 | if ((d->startCenterPoint - pinch->centerPoint()).manhattanLength() <= 150 && time >= waitingTime) { | ||||
863 | if (pinch->rotationAngle() - d->lastRotation > rotationsDelta) { | ||||
864 | TransformImageOperation *op = new TransformImageOperation(ROT_90); | ||||
865 | op->applyToDocument(d->mDocument); | ||||
866 | d->lastRotation = pinch->rotationAngle(); | ||||
867 | } | ||||
868 | else if (-(pinch->rotationAngle() - d->lastRotation) > rotationsDelta) { | ||||
869 | TransformImageOperation *op = new TransformImageOperation(ROT_270); | ||||
870 | op->applyToDocument(d->mDocument); | ||||
871 | d->lastRotation = pinch->rotationAngle(); | ||||
872 | } | ||||
873 | } | ||||
874 | } | ||||
875 | } | ||||
876 | | ||||
877 | if (pinch->state() == Qt::GestureFinished) { | ||||
878 | d->lastRotation = 0; | ||||
879 | d->startCenterPoint = QPointF (0,0); | ||||
880 | } | ||||
881 | return true; | ||||
882 | } | ||||
883 | return false; | ||||
884 | } | ||||
885 | | ||||
673 | void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event) | 886 | void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event) | ||
674 | { | 887 | { | ||
675 | d->resizeAdapterWidget(); | 888 | d->resizeAdapterWidget(); | ||
676 | d->updateZoomSnapValues(); | 889 | d->updateZoomSnapValues(); | ||
677 | QGraphicsWidget::resizeEvent(event); | 890 | QGraphicsWidget::resizeEvent(event); | ||
678 | } | 891 | } | ||
679 | 892 | | |||
680 | void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event) | 893 | void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event) | ||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 1093 | if (event->type() == QEvent::GraphicsSceneMousePress) { | |||
884 | } | 1097 | } | ||
885 | QMetaObject::invokeMethod(this, "emitFocused", Qt::QueuedConnection); | 1098 | QMetaObject::invokeMethod(this, "emitFocused", Qt::QueuedConnection); | ||
886 | } else if (event->type() == QEvent::GraphicsSceneHoverMove) { | 1099 | } else if (event->type() == QEvent::GraphicsSceneHoverMove) { | ||
887 | if (d->mBirdEyeView) { | 1100 | if (d->mBirdEyeView) { | ||
888 | d->mBirdEyeView->onMouseMoved(); | 1101 | d->mBirdEyeView->onMouseMoved(); | ||
889 | } | 1102 | } | ||
890 | } else if (event->type() == QEvent::GraphicsSceneMouseMove) { | 1103 | } else if (event->type() == QEvent::GraphicsSceneMouseMove) { | ||
891 | const QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); | 1104 | const QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); | ||
892 | const qreal dragDistance = (mouseEvent->pos() - d->mDragStartPosition).manhattanLength(); | 1105 | const qreal dragDistance = (mouseEvent->pos() - d->mDragStartPosition).manhattanLength(); | ||
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. | |||||
893 | const qreal minDistanceToStartDrag = QGuiApplication::styleHints()->startDragDistance(); | 1106 | const qreal minDistanceToStartDrag = QGuiApplication::styleHints()->startDragDistance(); | ||
894 | if (!d->canPan() && dragDistance >= minDistanceToStartDrag) { | 1107 | if (!d->canPan() && dragDistance >= minDistanceToStartDrag && mouseEvent->source() == Qt::MouseEventNotSynthesized) { | ||
rkflx: Is this still needed given the check above? | |||||
895 | d->startDragIfSensible(); | 1108 | d->startDragIfSensible(); | ||
896 | } | 1109 | } | ||
897 | } | 1110 | } | ||
898 | return false; | 1111 | return false; | ||
899 | } | 1112 | } | ||
900 | 1113 | | |||
901 | AbstractRasterImageViewTool* DocumentView::currentTool() const | 1114 | AbstractRasterImageViewTool* DocumentView::currentTool() const | ||
902 | { | 1115 | { | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Unnecessary whitespace change