mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: don't go through manager object to show map
We can open URLs in the browser directly from QML. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f677d482e9
commit
69c10808af
5 changed files with 11 additions and 15 deletions
|
@ -54,7 +54,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (dive.gps !== "")
|
if (dive.gps !== "")
|
||||||
manager.showMap(dive.gps)
|
showMap(dive.gps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ Kirigami.ScrollablePage {
|
||||||
property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
|
property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
|
||||||
|
|
||||||
Kirigami.BasicListItem {
|
Kirigami.BasicListItem {
|
||||||
supportsMouseEvents: true
|
supportsMouseEvents: true
|
||||||
width: parent.width - Kirigami.Units.gridUnit
|
width: parent.width - Kirigami.Units.gridUnit
|
||||||
height: childrenRect.height - Kirigami.Units.smallSpacing
|
height: childrenRect.height - Kirigami.Units.smallSpacing
|
||||||
GridLayout {
|
GridLayout {
|
||||||
|
@ -99,8 +99,7 @@ Kirigami.ScrollablePage {
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
iconName: "gps"
|
iconName: "gps"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
print("show map")
|
showMap(latitude + " " + longitude)
|
||||||
manager.showMap(latitude + " " + longitude)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,14 @@ Kirigami.ApplicationWindow {
|
||||||
diveList.scrollToTop()
|
diveList.scrollToTop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showMap(location) {
|
||||||
|
var urlPrefix = "https://www.google.com/maps/place/"
|
||||||
|
var locationPair = location + "/@" + location
|
||||||
|
var urlSuffix = ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0"
|
||||||
|
Qt.openUrlExternally(urlPrefix + locationPair + urlSuffix)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function startAddDive() {
|
function startAddDive() {
|
||||||
detailsWindow.state = "add"
|
detailsWindow.state = "add"
|
||||||
detailsWindow.dive_id = manager.addDive();
|
detailsWindow.dive_id = manager.addDive();
|
||||||
|
|
|
@ -959,16 +959,6 @@ void QMLManager::setCredentialStatus(const credentialStatus_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::showMap(const QString& location)
|
|
||||||
{
|
|
||||||
if (!location.isEmpty()) {
|
|
||||||
QString link = QString("https://www.google.com/maps/place/%1/@%2,5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0")
|
|
||||||
.arg(location)
|
|
||||||
.arg(location);
|
|
||||||
QDesktopServices::openUrl(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// where in the QML dive list is that dive?
|
// where in the QML dive list is that dive?
|
||||||
int QMLManager::getIndex(const QString &diveId)
|
int QMLManager::getIndex(const QString &diveId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,7 +103,6 @@ public slots:
|
||||||
void clearGpsData();
|
void clearGpsData();
|
||||||
void finishSetup();
|
void finishSetup();
|
||||||
void openLocalThenRemote(QString url);
|
void openLocalThenRemote(QString url);
|
||||||
void showMap(const QString& location);
|
|
||||||
int getIndex(const QString& diveId);
|
int getIndex(const QString& diveId);
|
||||||
QString getNumber(const QString& diveId);
|
QString getNumber(const QString& diveId);
|
||||||
QString getDate(const QString& diveId);
|
QString getDate(const QString& diveId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue