diff --git a/src/map-quick/CMakeLists.txt b/src/map-quick/CMakeLists.txt index a821235..1668714 100644 --- a/src/map-quick/CMakeLists.txt +++ b/src/map-quick/CMakeLists.txt @@ -1,27 +1,28 @@ set(kosmindoormapquickplugin_SRC kosmindoormapquickplugin.cpp floorlevelmodel.cpp mapitem.cpp osmelement.cpp ) set(kosmindoormapquickplugin_qml qmldir IndoorMap.qml + IndoorMapAttributionLabel.qml IndoorMapScale.qml ) add_library(kosmindoormapquickplugin ${kosmindoormapquickplugin_SRC}) target_link_libraries(kosmindoormapquickplugin Qt5::Quick KOSMIndoorMap ) # make examples work without installation set_property(TARGET kosmindoormapquickplugin PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/kosmindoormap) file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/kosmindoormap/) foreach(f IN LISTS kosmindoormapquickplugin_qml) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/org/kde/kosmindoormap/${f} SYMBOLIC) endforeach() # install(TARGETS kosmindoormapquickplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kosmindoormap) # install(FILES ${kosmindoormapquickplugin_qml} ${quick_SRC} DESTINATION ${QML_INSTALL_DIR}/org/kde/kosmindoormap) diff --git a/src/map-quick/IndoorMapAttributionLabel.qml b/src/map-quick/IndoorMapAttributionLabel.qml new file mode 100644 index 0000000..782da7c --- /dev/null +++ b/src/map-quick/IndoorMapAttributionLabel.qml @@ -0,0 +1,45 @@ +/* + Copyright (C) 2020 Volker Krause + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 as QQC2 + +Item { + id: root + + implicitHeight: background.height + implicitWidth: background.width + + property int __margin: 2 + + Rectangle { + id: background + color: label.palette.base + opacity: 0.5 + height: label.implicitHeight + 2 * __margin + width: label.implicitWidth + } + + QQC2.Label { + text: qsTr("© OpenStreetMap contributors"); + id: label + font.pointSize: 7; + anchors.centerIn: background + + onLinkActivated: Qt.openUrlExternally(link) + } +} diff --git a/src/map-quick/qmldir b/src/map-quick/qmldir index 7c00125..e199068 100644 --- a/src/map-quick/qmldir +++ b/src/map-quick/qmldir @@ -1,5 +1,6 @@ module org.kde.kosmindoormap plugin kosmindoormapquickplugin classname KOSMIndoorMapQuickPlugin IndoorMap 1.0 IndoorMap.qml +IndoorMapAttributionLabel 1.0 IndoorMapAttributionLabel.qml IndoorMapScale 1.0 IndoorMapScale.qml diff --git a/tests/indoormap.qml b/tests/indoormap.qml index c630619..a22182d 100644 --- a/tests/indoormap.qml +++ b/tests/indoormap.qml @@ -1,152 +1,157 @@ /* Copyright (C) 2020 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.12 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.0 as Kirigami import org.kde.kosmindoormap 1.0 Kirigami.ApplicationWindow { title: "OSM Indoor Map QML Test" pageStack.initialPage: Kirigami.Page { title: "Indoor Map View" actions { left: Kirigami.Action { iconName: "go-down-symbolic" enabled: map.floorLevels.hasFloorLevelBelow(map.view.floorLevel) onTriggered: map.view.floorLevel = map.floorLevels.floorLevelBelow(map.view.floorLevel) } right: Kirigami.Action { iconName: "go-up-symbolic" enabled: map.floorLevels.hasFloorLevelAbove(map.view.floorLevel) onTriggered: map.view.floorLevel = map.floorLevels.floorLevelAbove(map.view.floorLevel) } contextualActions: [ Kirigami.Action { text: "Light Style" onTriggered: map.styleSheet = ":/org.kde.kosmindoormap/assets/css/breeze-light.mapcss" }, Kirigami.Action { text: "Dark Style" onTriggered: map.styleSheet = ":/org.kde.kosmindoormap/assets/css/breeze-dark.mapcss" }, Kirigami.Action { text: "Diagnostic View" onTriggered: map.styleSheet = ":/org.kde.kosmindoormap/assets/css/diagnostic.mapcss" } ] } header: RowLayout { QQC2.Label { text: "Floor Level:" } QQC2.ComboBox { id: floorLevelCombo model: map.floorLevels textRole: "display" Component.onCompleted: currentIndex = map.floorLevels.rowForLevel(map.view.floorLevel); onCurrentIndexChanged: if (currentIndex >= 0) { map.view.floorLevel = map.floorLevels.levelForRow(currentIndex); } } Connections { target: map.view onFloorLevelChanged: floorLevelCombo.currentIndex = map.floorLevels.rowForLevel(map.view.floorLevel); } QQC2.Label { text: "Coordinate:" } QQC2.TextField { id: coordInput placeholderText: "map coordinates" text: "49.44572, 11.08196" } QQC2.Button { text: "x" onClicked: coordInput.text = "" } QQC2.Button { text: ">" onClicked: { var c = coordInput.text.match(/(.*)[,;/ ]+(.*)/); var lat = c[1]; var lon = c[2]; map.mapLoader.loadForCoordinate(lat, lon); } } } Kirigami.OverlaySheet { id: elementDetailsSheet property var element header: Kirigami.Heading { text: elementDetailsSheet.element.name } ColumnLayout { QQC2.Label { visible: text != "" text: elementDetailsSheet.element.tagValue("description"); } QQC2.Label { visible: text != "" text: elementDetailsSheet.element.tagValue("amenity") + elementDetailsSheet.element.tagValue("shop") + elementDetailsSheet.element.tagValue("tourism") + elementDetailsSheet.element.tagValue("office") } QQC2.Label { visible: text != "" text: elementDetailsSheet.element.tagValue("opening_hours"); } QQC2.Label { visible: elementDetailsSheet.element.tagValue("website") != "" text: "" + elementDetailsSheet.element.tagValue("website") + "" onLinkActivated: Qt.openUrlExternally(link) } QQC2.Label { visible: elementDetailsSheet.element.wikipediaUrl != "" text: "Wikipedia" onLinkActivated: Qt.openUrlExternally(link) } QQC2.Label { text: elementDetailsSheet.element.tagValue("addr:street") + " " + elementDetailsSheet.element.tagValue("addr:housenumber") + "\n" + elementDetailsSheet.element.tagValue("addr:postcode") + " " + elementDetailsSheet.element.tagValue("addr:city") + "\n" + elementDetailsSheet.element.tagValue("addr:country"); } } } IndoorMap { id: map anchors.fill: parent IndoorMapScale { view: map.view anchors.left: map.left anchors.bottom: map.bottom width: 0.3 * map.width } + IndoorMapAttributionLabel { + anchors.right: map.right + anchors.bottom: map.bottom + } + Component.onCompleted: { map.mapLoader.loadForCoordinate(49.44572, 11.08196); } onElementPicked: { elementDetailsSheet.element = element; elementDetailsSheet.sheetOpen = true; } } } }