diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-12-17 15:43:37 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-12-17 15:43:37 +0100 |
commit | 6a484c615ae3f04873fe41a415277ef6c2c37573 (patch) | |
tree | b2f429eb1baf703463821624691921e1426b7361 /tagview.cpp | |
parent | c6713d0876ce2d99f912151c9884477606909681 (diff) | |
download | numberator-6a484c615ae3f04873fe41a415277ef6c2c37573.tar.gz numberator-6a484c615ae3f04873fe41a415277ef6c2c37573.tar.bz2 numberator-6a484c615ae3f04873fe41a415277ef6c2c37573.zip |
Diffstat (limited to 'tagview.cpp')
-rw-r--r-- | tagview.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tagview.cpp b/tagview.cpp index 9a9c9a0..6bc3934 100644 --- a/tagview.cpp +++ b/tagview.cpp @@ -3,12 +3,13 @@ #include <QWheelEvent> #include <QScrollBar> #include <cmath> +#include <QApplication> TagView::TagView(QWidget *parent) : QGraphicsView(parent) , saveCenterTimer(this) { - setDragMode(QGraphicsView::ScrollHandDrag); + setDragMode(QGraphicsView::RubberBandDrag); setScene(&m_scene); connect(&m_scene, &TagScene::tagDoubleClicked, this, &TagView::tagDoubleClicked); connect(&m_scene, &TagScene::imageLoaded, this, &TagView::zoomToFit); @@ -86,6 +87,31 @@ void TagView::scrollContentsBy(int dx, int dy) saveCenterTimer.start(); } +void TagView::keyPressEvent(QKeyEvent *event) +{ + if (event->modifiers() & Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else + setDragMode(QGraphicsView::RubberBandDrag); +} + +void TagView::keyReleaseEvent(QKeyEvent *event) +{ + if (event->modifiers() & Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else + setDragMode(QGraphicsView::RubberBandDrag); +} + +void TagView::focusInEvent(QFocusEvent *event) +{ + Q_UNUSED(event); + if (QApplication::keyboardModifiers() & Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else + setDragMode(QGraphicsView::RubberBandDrag); +} + void TagView::saveCenter() { QPointF p = mapToScene(viewport()->rect().center()); |