Skip to content

Commit

Permalink
Try to design map items
Browse files Browse the repository at this point in the history
  • Loading branch information
iiLubos committed Oct 11, 2023
1 parent 6feeb57 commit f4862e1
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
67 changes: 67 additions & 0 deletions app/qmlV2/component/MMMapButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import Qt5Compat.GraphicalEffects
import "../Style.js" as Style
import "."

Item {
id: control

width: 50
height: 50

Rectangle {
id: border

width: control.width + 3
height: control.height + 3
radius: width / 2
color: "transparent"

RadialGradient {
id: light
anchors.centerIn: parent

width: control.width * 1.2
height: control.height * 1.2

gradient: Gradient {
GradientStop { position: 0.3; color: "#80000000" }
GradientStop { position: 0.5; color: "transparent" }
}

layer.enabled: true
layer.effect: OpacityMask {
id: mask
maskSource: Rectangle {
height: light.height
width: light.width
radius: width / 2
}
}
}
}

Rectangle {
id: rectangle

width: parent.width
height: parent.height
radius: 25
color: Style.white

MouseArea {
anchors.fill: parent
}
}
}
2 changes: 2 additions & 0 deletions gallery/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
<file>qml/pages/ChecksPage.qml</file>
<file>../app/qmlV2/component/MMComponent_reachedDataLimit.qml</file>
<file>../app/qmlV2/component/MMProgressBar.qml</file>
<file>qml/pages/MapPage.qml</file>
<file>../app/qmlV2/component/MMMapButton.qml</file>
</qresource>
</RCC>
4 changes: 4 additions & 0 deletions gallery/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ ApplicationWindow {
title: "Drawers"
source: "DrawerPage.qml"
}
ListElement {
title: "Map"
source: "MapPage.qml"
}
}

ScrollIndicator.vertical: ScrollIndicator {}
Expand Down
89 changes: 89 additions & 0 deletions gallery/qml/pages/MapPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtLocation
import QtPositioning

import "../../app/qmlV2/component"
import "../../app/qmlV2/Style.js" as Style

Page {
id: pane

Plugin {
id: mapPlugin
name: "osm"
}

Map {
id: map

anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(48.72, 21.25) // KE
zoomLevel: 12
property geoCoordinate startCentroid

PinchHandler {
id: pinch

target: null
onActiveChanged: if (active) {
map.startCentroid = map.toCoordinate(pinch.centroid.position, false)
}
onScaleChanged: (delta) => {
map.zoomLevel += Math.log2(delta)
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
onRotationChanged: (delta) => {
map.bearing -= delta
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
grabPermissions: PointerHandler.TakeOverForbidden
}

WheelHandler {
acceptedDevices: Qt.platform.pluginName === "cocoa" || Qt.platform.pluginName === "wayland"
? PointerDevice.Mouse | PointerDevice.TouchPad
: PointerDevice.Mouse
rotationScale: 1/120
property: "zoomLevel"
}

DragHandler {
target: null
onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
}
}

Rectangle {
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
height: 30
color: "white"

Text {
anchors.centerIn: parent
text: map.center + "\tzoom: " + map.zoomLevel.toFixed(2)
}
}

MMMapButton {
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 20
anchors.bottomMargin: 50
}
}

1 comment on commit f4862e1

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.10.468411 just submitted!

Please sign in to comment.