aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CursorNavigation.pro3
-rw-r--r--DemoApplication/DemoApplication.pro3
-rw-r--r--DemoApplication/graphics/marker.pngbin0 -> 752 bytes
-rw-r--r--DemoApplication/main.qml4
-rw-r--r--DemoApplication/pages/Page6.qml135
-rw-r--r--plugin/spatialnavigation360.cpp8
6 files changed, 144 insertions, 9 deletions
diff --git a/CursorNavigation.pro b/CursorNavigation.pro
index e76e405..0a01c20 100644
--- a/CursorNavigation.pro
+++ b/CursorNavigation.pro
@@ -4,3 +4,6 @@ SUBDIRS += \
DemoApplication \
plugin \
tests
+
+DISTFILES += \
+ DemoApplication/pages/Page6.qml
diff --git a/DemoApplication/DemoApplication.pro b/DemoApplication/DemoApplication.pro
index 736fb47..3088011 100644
--- a/DemoApplication/DemoApplication.pro
+++ b/DemoApplication/DemoApplication.pro
@@ -19,12 +19,13 @@ macos:CONFIG -= app_bundle
SOURCES += \
src/main.cpp
-qml.files = main.qml $$PWD/controls $$PWD/pages
+qml.files = main.qml $$PWD/controls $$PWD/pages $$PWD/graphics
qml.path = $$OUT_PWD
INSTALLS += qml
OTHER_FILES += $$files($$PWD/*.qml, true)
OTHER_FILES += $$files($$PWD/*.qmldir, true)
+OTHER_FILES += $$files($$PWD/*.png, true)
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
diff --git a/DemoApplication/graphics/marker.png b/DemoApplication/graphics/marker.png
new file mode 100644
index 0000000..2116dfd
--- /dev/null
+++ b/DemoApplication/graphics/marker.png
Binary files differ
diff --git a/DemoApplication/main.qml b/DemoApplication/main.qml
index c638e86..58f1af5 100644
--- a/DemoApplication/main.qml
+++ b/DemoApplication/main.qml
@@ -31,6 +31,9 @@ ApplicationWindow {
CNTabButton {
text: qsTr("Page 5")
}
+ CNTabButton {
+ text: qsTr("Map")
+ }
}
contentData: StackLayout {
@@ -41,5 +44,6 @@ ApplicationWindow {
Page3 { }
Page4 { }
Page5 { }
+ Page6 { }
}
}
diff --git a/DemoApplication/pages/Page6.qml b/DemoApplication/pages/Page6.qml
new file mode 100644
index 0000000..a90857f
--- /dev/null
+++ b/DemoApplication/pages/Page6.qml
@@ -0,0 +1,135 @@
+
+import QtQuick 2.0
+import QtPositioning 5.5
+import QtLocation 5.6
+import CursorNavigation 1.0
+import QtGamepad 1.0
+import QtQuick.Shapes 1.11
+
+Item {
+ width: parent.width
+ height: parent.height
+
+ Timer {
+ id: cooldownTimer
+ interval: 500
+ repeat: false
+ }
+
+ Gamepad {
+ deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1
+
+ function handleMove() {
+ var v = Qt.vector2d(axisLeftX, axisLeftY)
+ if (v.length() >= 0.99 && !cooldownTimer.running) {
+ //console.log("handle joystick move, v=" + v)
+ parent.CursorNavigation.moveCursor(Qt.vector2d(axisLeftX, axisLeftY), 10)
+ cooldownTimer.start()
+ } else if (v.length() >= 0.1) {
+ var item = parent.CursorNavigation.find(v, 10)
+ //cooldownTimer.start()
+ if (item != undefined) {
+ pointerRect.x = item.x
+ pointerRect.y = item.y
+ pointerRect.width = item.width+10
+ pointerRect.height = item.height+10
+ pointerRect.radius = item.width/2+5
+ pointerRect.visible = true
+ }
+ } else {
+ pointerRect.visible = false
+ }
+ }
+
+ onAxisLeftXChanged: handleMove()
+ onAxisLeftYChanged: handleMove()
+ }
+
+
+ Plugin {
+ id: mapPlugin
+ name: "esri" //"osm", "mapboxgl", "esri", ...
+ }
+
+ PositionSource {
+ id: positionSource
+ property variant lastSearchPosition: locationOslo
+ active: true
+ updateInterval: 120000 // 2 mins
+ onPositionChanged: {
+ var currentPosition = positionSource.position.coordinate
+ map.center = currentPosition
+ var distance = currentPosition.distanceTo(lastSearchPosition)
+ if (distance > 500) {
+ // 500m from last performed pizza search
+ lastSearchPosition = currentPosition
+ searchModel.searchArea = QtPositioning.circle(currentPosition)
+ searchModel.update()
+ }
+ }
+ }
+
+ property variant locationOslo: QtPositioning.coordinate( 59.93, 10.76)
+
+ PlaceSearchModel {
+ id: searchModel
+
+ plugin: mapPlugin
+
+ searchTerm: "Pizza"
+ searchArea: QtPositioning.circle(locationOslo)
+
+ Component.onCompleted: update()
+ }
+
+ Map {
+ id: map
+ anchors.fill: parent
+ plugin: mapPlugin;
+ center: locationOslo
+ zoomLevel: 13
+
+ Rectangle {
+ id: pointerRect
+ border.color: "#00ff00"
+ border.width: 2
+ visible: false
+ color: "transparent"
+ }
+
+ MapItemView {
+ model: searchModel
+ delegate: MapQuickItem {
+ id: itemDelegate
+ CursorNavigation.acceptsCursor: true
+ coordinate: place.location.coordinate
+
+ property bool highlight: false
+
+ anchorPoint.x: image.width * 0.5
+ anchorPoint.y: image.height
+
+ sourceItem: Column {
+ Image { id: image; source: "../graphics/marker.png";
+ transform: Scale {
+ xScale: itemDelegate.CursorNavigation.hasCursor ? 1.8 : 1
+ yScale: itemDelegate.CursorNavigation.hasCursor ? 1.8 : 1
+ origin.x: width/2
+ origin.y: height
+ }
+ }
+ Text { text: title; font.bold: itemDelegate.CursorNavigation.hasCursor }
+ }
+ }
+ }
+ }
+
+ Connections {
+ target: searchModel
+ onStatusChanged: {
+ if (searchModel.status == PlaceSearchModel.Error)
+ console.log("Search error!")
+ console.log(searchModel.errorString());
+ }
+ }
+}
diff --git a/plugin/spatialnavigation360.cpp b/plugin/spatialnavigation360.cpp
index bddcc5a..f7d1e62 100644
--- a/plugin/spatialnavigation360.cpp
+++ b/plugin/spatialnavigation360.cpp
@@ -121,7 +121,6 @@ CursorNavigationAttached* SpatialNavigation360::getNextCandidate(
return nullptr;
if (!currentItem && candidates.size()) {
- qDebug() << "the spatial chooser falling back to first child" << candidates.first();
return candidates.first();
}
@@ -139,14 +138,10 @@ CursorNavigationAttached* SpatialNavigation360::getNextCandidate(
quadrants[2] = sectorsOverlap(angle1, angle2, -M_PI, -M_PI_2);
quadrants[3] = sectorsOverlap(angle1, angle2, -M_PI_2, 0);
- qWarning() << "navigation360: beam angles: " << angle1 << " , " << angle2;
- qWarning() << "navigation360: quadrants = " << quadrants;
-
const QRectF currentItemSceneRect = currentItem->item()->mapRectToScene(
QRectF( 0, 0, currentItem->item()->width(), currentItem->item()->height() ));
const QPointF origin = currentItemSceneRect.center();
- qWarning() << "origin = " << origin;
//item that overlaps the center of the selector beam
CursorNavigationAttached* directHitItem = nullptr;
@@ -167,17 +162,14 @@ CursorNavigationAttached* SpatialNavigation360::getNextCandidate(
if (isRectIncluded(quadrants, itemSceneRect, origin)) {
std::pair<qreal,qreal> sector = getSector(itemSceneRect, origin);
- qWarning() << "item " << iter->item() << " rect = " << itemSceneRect << " sector " << sector;
if (angleIsBetween(cmd.angle, sector.first, sector.second)) {
- qWarning() << "is direct hit";
qreal dist = rectDistance(itemSceneRect, currentItemSceneRect);
if (!directHitItem || dist < directHitDistance) {
directHitDistance = dist;
directHitItem = iter;
}
} else if (!directHitItem && sectorsOverlap(angle1, angle2, sector.first, sector.second)) {
- qWarning() << "is within tolerances";
qreal dist = rectDistance(itemSceneRect, currentItemSceneRect);
if (!withinToleranceItem || dist < withinToleranceDistance) {
withinToleranceDistance = dist;