1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added "copy coordinates to clipboard"

closes #291
This commit is contained in:
Martin Tůma 2020-11-13 20:15:17 +01:00
parent ed9ebfffac
commit b4d240d8fe
5 changed files with 35 additions and 3 deletions

View File

@ -15,6 +15,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
CoordinatesFormat format() const {return _format;}
void setCoordinates(const Coordinates &c); void setCoordinates(const Coordinates &c);
void setFormat(const CoordinatesFormat &format); void setFormat(const CoordinatesFormat &format);
void setDigitalZoom(qreal zoom); void setDigitalZoom(qreal zoom);

View File

@ -720,7 +720,10 @@ void GUI::keys()
+ "</i></td></tr><tr><td>" + tr("Zoom out") + "</td><td><i>" + "</i></td></tr><tr><td>" + tr("Zoom out") + "</td><td><i>"
+ QKeySequence(ZOOM_OUT).toString() + "</i></td></tr><tr><td>" + QKeySequence(ZOOM_OUT).toString() + "</i></td></tr><tr><td>"
+ tr("Digital zoom") + "</td><td><i>" + QKeySequence(MODIFIER).toString() + tr("Digital zoom") + "</td><td><i>" + QKeySequence(MODIFIER).toString()
+ tr("Zoom") + "</i></td></tr></table></div>"); + tr("Zoom") + "</i></td></tr><tr><td></td><td></td></tr><tr><td>"
+ tr("Copy coordinates") + "</td><td><i>"
+ QKeySequence(MODIFIER).toString() + tr("Left Click")
+ "</i></td></tr></table></div>");
msgBox.exec(); msgBox.exec();
} }

View File

@ -8,6 +8,7 @@
#define PREV_KEY Qt::Key_Backspace #define PREV_KEY Qt::Key_Backspace
#define FIRST_KEY Qt::Key_Home #define FIRST_KEY Qt::Key_Home
#define LAST_KEY Qt::Key_End #define LAST_KEY Qt::Key_End
#define MODIFIER_KEY Qt::Key_Shift
#define MODIFIER Qt::ShiftModifier #define MODIFIER Qt::ShiftModifier
#define ZOOM_IN Qt::Key_Plus #define ZOOM_IN Qt::Key_Plus
#define ZOOM_OUT Qt::Key_Minus #define ZOOM_OUT Qt::Key_Minus

View File

@ -3,6 +3,7 @@
#include <QWheelEvent> #include <QWheelEvent>
#include <QApplication> #include <QApplication>
#include <QScrollBar> #include <QScrollBar>
#include <QClipboard>
#include "data/poi.h" #include "data/poi.h"
#include "data/data.h" #include "data/data.h"
#include "map/map.h" #include "map/map.h"
@ -522,7 +523,12 @@ void MapView::keyPressEvent(QKeyEvent *event)
else if (_digitalZoom && event->key() == Qt::Key_Escape) { else if (_digitalZoom && event->key() == Qt::Key_Escape) {
digitalZoom(0); digitalZoom(0);
return; return;
} else { } else {
if (event->key() == MODIFIER_KEY) {
_cursor = viewport()->cursor();
viewport()->setCursor(Qt::CrossCursor);
}
QGraphicsView::keyPressEvent(event); QGraphicsView::keyPressEvent(event);
return; return;
} }
@ -530,6 +536,23 @@ void MapView::keyPressEvent(QKeyEvent *event)
zoom(z, pos); 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, void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
PlotFlags flags) PlotFlags flags)
{ {

View File

@ -123,13 +123,15 @@ private:
void updatePOIVisibility(); void updatePOIVisibility();
void skipColor() {_palette.nextColor();} void skipColor() {_palette.nextColor();}
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect); void drawBackground(QPainter *painter, const QRectF &rect);
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void scrollContentsBy(int dx, int dy); void scrollContentsBy(int dx, int dy);
void mouseMoveEvent(QMouseEvent *event);
void leaveEvent(QEvent *event); void leaveEvent(QEvent *event);
GraphicsScene *_scene; GraphicsScene *_scene;
@ -163,6 +165,7 @@ private:
int _digitalZoom; int _digitalZoom;
bool _plot; bool _plot;
QCursor _cursor;
#ifdef ENABLE_HIDPI #ifdef ENABLE_HIDPI
qreal _deviceRatio; qreal _deviceRatio;