diff --git a/src/GUI/coordinatesitem.h b/src/GUI/coordinatesitem.h index a0b52a1a..df95c3db 100644 --- a/src/GUI/coordinatesitem.h +++ b/src/GUI/coordinatesitem.h @@ -15,6 +15,8 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + CoordinatesFormat format() const {return _format;} + void setCoordinates(const Coordinates &c); void setFormat(const CoordinatesFormat &format); void setDigitalZoom(qreal zoom); diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 98f51015..04c52dad 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -720,7 +720,10 @@ void GUI::keys() + "" + tr("Zoom out") + "" + QKeySequence(ZOOM_OUT).toString() + "" + tr("Digital zoom") + "" + QKeySequence(MODIFIER).toString() - + tr("Zoom") + ""); + + tr("Zoom") + "" + + tr("Copy coordinates") + "" + + QKeySequence(MODIFIER).toString() + tr("Left Click") + + ""); msgBox.exec(); } diff --git a/src/GUI/keys.h b/src/GUI/keys.h index 4289f6cd..354b7987 100644 --- a/src/GUI/keys.h +++ b/src/GUI/keys.h @@ -8,6 +8,7 @@ #define PREV_KEY Qt::Key_Backspace #define FIRST_KEY Qt::Key_Home #define LAST_KEY Qt::Key_End +#define MODIFIER_KEY Qt::Key_Shift #define MODIFIER Qt::ShiftModifier #define ZOOM_IN Qt::Key_Plus #define ZOOM_OUT Qt::Key_Minus diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 88a09d6f..09b99e36 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "data/poi.h" #include "data/data.h" #include "map/map.h" @@ -522,7 +523,12 @@ void MapView::keyPressEvent(QKeyEvent *event) else if (_digitalZoom && event->key() == Qt::Key_Escape) { digitalZoom(0); return; - } else { + } else { + if (event->key() == MODIFIER_KEY) { + _cursor = viewport()->cursor(); + viewport()->setCursor(Qt::CrossCursor); + } + QGraphicsView::keyPressEvent(event); return; } @@ -530,6 +536,23 @@ void MapView::keyPressEvent(QKeyEvent *event) zoom(z, pos); } +void MapView::keyReleaseEvent(QKeyEvent *event) +{ + if (event->key() == MODIFIER_KEY && viewport()->cursor() == Qt::CrossCursor) + viewport()->setCursor(_cursor); + + QGraphicsView::keyReleaseEvent(event); +} + +void MapView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && event->modifiers() & MODIFIER) + QGuiApplication::clipboard()->setText(Format::coordinates( + _map->xy2ll(mapToScene(event->pos())), _coordinates->format())); + else + QGraphicsView::mousePressEvent(event); +} + void MapView::plot(QPainter *painter, const QRectF &target, qreal scale, PlotFlags flags) { diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index a75edf91..c332ea52 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -123,13 +123,15 @@ private: void updatePOIVisibility(); void skipColor() {_palette.nextColor();} + void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event); void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); void drawBackground(QPainter *painter, const QRectF &rect); void paintEvent(QPaintEvent *event); void scrollContentsBy(int dx, int dy); - void mouseMoveEvent(QMouseEvent *event); void leaveEvent(QEvent *event); GraphicsScene *_scene; @@ -163,6 +165,7 @@ private: int _digitalZoom; bool _plot; + QCursor _cursor; #ifdef ENABLE_HIDPI qreal _deviceRatio;