diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml
index 31e8252..6436b34 100644
--- a/package/contents/config/main.xml
+++ b/package/contents/config/main.xml
@@ -15,6 +15,9 @@
0
+
+
+
true
@@ -42,6 +45,9 @@
+
+ 200
+
13
diff --git a/package/contents/ui/FullRepresentation.qml b/package/contents/ui/FullRepresentation.qml
index ba286d8..b6f6339 100644
--- a/package/contents/ui/FullRepresentation.qml
+++ b/package/contents/ui/FullRepresentation.qml
@@ -24,8 +24,12 @@ import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents
+import QtLocation
+import QtPositioning
+
Item {
+ readonly property int mapSize: Plasmoid.configuration.mapSize
readonly property int mapZoomLevel: Plasmoid.configuration.mapZoomLevel
readonly property bool layoutRow: Plasmoid.configuration.layoutRow
readonly property bool showHostname: Plasmoid.configuration.showHostname
@@ -34,6 +38,10 @@ Item {
readonly property bool useLinkThemeColor: Plasmoid.configuration.useLinkThemeColor
readonly property string linkColor: Plasmoid.configuration.linkColor
+ readonly property string thunderforestAPIKey: Plasmoid.configuration.thunderforestAPIKey
+
+ property string mapLink: "https://www.openstreetmap.org/?mlat=" + latitude + "&mlon=" + longitude + "#map=" + mapZoomLevel + "/" + latitude + "/" + longitude
+
id: fullRoot
// Automatically adapt to the GridLayout’s implicit size
width: labelsContainer.implicitWidth
@@ -41,96 +49,162 @@ Item {
Layout.preferredWidth: labelsContainer.implicitWidth
Layout.preferredHeight: labelsContainer.implicitHeight
+ function addMarker(latitude, longitude) {
+ debug_print("addMarker init")
+ var component = Qt.createComponent("Marker.qml")
+ if( component.status != Component.Ready )
+ {
+ if( component.status == Component.Error )
+ debug_print("Error creating Marker:"+ component.errorString() );
+ return; // or maybe throw
+ }
+ // removing previous markers
+ my_map.clearMapItems()
+ var item = component.createObject(
+ grid, {
+ coordinate: QtPositioning.coordinate(latitude, longitude)
+ })
+ my_map.addMapItem(item)
+ debug_print("Added Marker: lat=" + latitude + "; long=" + longitude)
+ }
+
GridLayout {
- id: labelsContainer
- flow: GridLayout.LeftToRight
- columns: 2
+ id: grid
+ rowSpacing: 10
+ columnSpacing: 10
+ flow: layoutRow ? GridLayout.LeftToRight : GridLayout.TopToBottom
+
+ Item {
+ width: mapSize
+ height: width
+ Layout.alignment: layoutRow ? Qt.AlignLeft : Qt.AlignHCenter
+
+ Plugin {
+ id: mapPlugin
+ name: "osm" // "mapboxgl", "esri", ...
+
+ PluginParameter {
+ name: "osm.mapping.custom.host";
+ value: {
+ // catch the case that there is no proper API key
+ if( thunderforestAPIKey.length === 0 )
+ return "https://tile.thunderforest.com/atlas/%z/%x/%y.png"
+ else
+ return "https://tile.thunderforest.com/atlas/%z/%x/%y.png?apikey=" + thunderforestAPIKey
+ }
+ }
- QtControls.Label {
- text: i18n("IP address:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.ip ? jsonData.ip : "N/A"
+ Map {
+ id: my_map
+ anchors.fill: parent
+ plugin: mapPlugin
+ center: {
+ if (jsonData !== undefined) {
+ addMarker(latitude, longitude)
+ return QtPositioning.coordinate(latitude, longitude)
+ }
+ addMarker(41.8902, 12.4922)
+ return QtPositioning.coordinate(41.8902, 12.4922) // Rome
+ }
+ activeMapType: my_map.supportedMapTypes[my_map.supportedMapTypes.length - 1]
+
+ zoomLevel: mapZoomLevel
+ }
}
- QtControls.Label {
- text: i18n("Country:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ GridLayout {
+ id: labelsContainer
+ flow: GridLayout.LeftToRight
+ columns: 2
- LabelDelegate {
- text: jsonData !== undefined && jsonData.country ? jsonData.country : "N/A"
- }
+ QtControls.Label {
+ text: i18n("IP address:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Label {
- text: i18n("Region:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.ip ? jsonData.ip : "N/A"
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.region ? jsonData.region : "N/A"
- }
+ QtControls.Label {
+ text: i18n("Country:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Label {
- text: i18n("Postal Code:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.country ? jsonData.country : "N/A"
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.postal ? jsonData.postal : "N/A"
- }
+ QtControls.Label {
+ text: i18n("Region:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Label {
- text: i18n("City:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.region ? jsonData.region : "N/A"
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.city ? jsonData.city : "N/A"
- }
+ QtControls.Label {
+ text: i18n("Postal Code:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Label {
- text: i18n("Coordinates:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- }
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.postal ? jsonData.postal : "N/A"
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.loc ? jsonData.loc : "N/A"
- }
+ QtControls.Label {
+ text: i18n("City:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Label {
- text: i18n("Hostname:")
- color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
- visible: showHostname
- }
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.city ? jsonData.city : "N/A"
+ }
- LabelDelegate {
- text: jsonData !== undefined && jsonData.hostname ? jsonData.hostname : "N/A"
- visible: showHostname
- }
+ QtControls.Label {
+ text: i18n("Coordinates:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ }
- QtControls.Button {
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignHCenter
- Layout.preferredWidth: parent.width
- text: jsonData !== undefined ? i18n("Open map in the browser") : "N/A"
- visible: jsonData !== undefined
- onClicked: {
- let mapLink = "https://www.openstreetmap.org/?mlat=" + latitude + "&mlon=" + longitude + "#map=" + mapZoomLevel + "/" + latitude + "/" + longitude
- debug_print("[showMap onClicked] " + mapLink)
- Qt.openUrlExternally(mapLink)
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.loc ? jsonData.loc : "N/A"
+ }
+
+ QtControls.Label {
+ text: i18n("Hostname:")
+ color: useLabelThemeColor ? Kirigami.Theme.textColor : labelColor
+ visible: showHostname
+ }
+
+ LabelDelegate {
+ text: jsonData !== undefined && jsonData.hostname ? jsonData.hostname : "N/A"
+ visible: showHostname
+ }
+
+ QtControls.Button {
+ Layout.columnSpan: 2
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: parent.width
+ text: jsonData !== undefined ? i18n("Open map in the browser") : "N/A"
+ visible: jsonData !== undefined
+ onClicked: {
+ debug_print("[showMap onClicked] " + mapLink)
+ Qt.openUrlExternally(mapLink)
+ }
}
- }
- QtControls.Button {
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignHCenter
- Layout.preferredWidth: parent.width
- text: i18n("Update")
- onClicked: {
- root._triggerReloadOnClick()
+ QtControls.Button {
+ Layout.columnSpan: 2
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: parent.width
+ text: i18n("Update")
+ onClicked: {
+ debug_print("[button onClicked]")
+ root._triggerReloadOnClick()
+ }
}
}
}
diff --git a/package/contents/ui/Marker.qml b/package/contents/ui/Marker.qml
new file mode 100644
index 0000000..dae1d6e
--- /dev/null
+++ b/package/contents/ui/Marker.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.2
+import QtLocation
+
+MapQuickItem{
+ id: marker
+ anchorPoint.x: marker.width / 4
+ anchorPoint.y: marker.height
+ z: my_map.z + 1
+ sourceItem: Image{
+ id: icon
+ source: "../icons/marker.png"
+ sourceSize.width: 40
+ sourceSize.height: 40
+ }
+}
diff --git a/package/contents/ui/config/configGeneral.qml b/package/contents/ui/config/configGeneral.qml
index 780e708..9473b50 100644
--- a/package/contents/ui/config/configGeneral.qml
+++ b/package/contents/ui/config/configGeneral.qml
@@ -41,6 +41,8 @@ KCM.SimpleKCM {
property alias cfg_sendNotifOnIPChange: sendNotificationOnIpChange.checked
property alias cfg_triggerFile: triggerFileEdit.text
+ property alias cfg_thunderforestAPIKey: thunderforestAPIKeyEdit.text
+
Kirigami.FormLayout {
QtControls.SpinBox {
@@ -61,6 +63,18 @@ KCM.SimpleKCM {
Layout.fillHeight: true
}
+ QtControls.TextField {
+ id: thunderforestAPIKeyEdit
+ Kirigami.FormData.label: "Thunderforest API key\n(https://www.thunderforest.com/):"
+ width: 300
+ focus: false
+ selectByMouse: true
+ }
+
+ Item { // tighten layout
+ Layout.fillHeight: true
+ }
+
QtControls.ComboBox {
id: widgetIconSizeCombo
Kirigami.FormData.label: i18n("Icon size:")