diff options
Diffstat (limited to 'mobile-widgets/qmlmapwidgethelper.cpp')
-rw-r--r-- | mobile-widgets/qmlmapwidgethelper.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp index 70d165983..1bc884ecf 100644 --- a/mobile-widgets/qmlmapwidgethelper.cpp +++ b/mobile-widgets/qmlmapwidgethelper.cpp @@ -1,4 +1,7 @@ // SPDX-License-Identifier: GPL-2.0
+#include <QApplication>
+#include <QClipboard>
+#include <QGeoCoordinate>
#include <QDebug>
#include "qmlmapwidgethelper.h"
@@ -44,3 +47,17 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location) {
qDebug() << location;
}
+
+void MapWidgetHelper::copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional)
+{
+ bool savep = prefs.coordinates_traditional;
+ prefs.coordinates_traditional = formatTraditional;
+
+ const int lat = llrint(1000000.0 * coord.latitude());
+ const int lon = llrint(1000000.0 * coord.longitude());
+ const char *coordinates = printGPSCoords(lat, lon);
+ QApplication::clipboard()->setText(QString(coordinates), QClipboard::Clipboard);
+
+ free((void *)coordinates);
+ prefs.coordinates_traditional = savep;
+}
|