From 3c151f8b6dc0e811c89d5fce4006b972307b4a12 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 9 Feb 2025 15:19:50 +0700 Subject: [PATCH 1/2] Add a signal to the coder reader to capture what is decoded but not yet accepted --- src/qml/CodeReader.qml | 6 +++++- src/qml/LocatorItem.qml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qml/CodeReader.qml b/src/qml/CodeReader.qml index b6d3786848..4f32fbc6eb 100644 --- a/src/qml/CodeReader.qml +++ b/src/qml/CodeReader.qml @@ -13,7 +13,10 @@ import Theme Popup { id: codeReader + //! Emitted when a QR code or NFC tag has been decoded/received signal decoded(var string) + //! Emitted when a QR code or NFC tag has been accepted + signal accepted(var string) property string decodedString: '' property var barcodeRequestedItem: undefined // Date: Sun, 9 Feb 2025 15:25:25 +0700 Subject: [PATCH 2/2] Generalize the geometry highlighter references so plugin can utilize the functionality too --- .../locator/activelayerfeatureslocatorfilter.cpp | 4 ++-- src/core/locator/bookmarklocatorfilter.cpp | 4 ++-- src/core/locator/featureslocatorfilter.cpp | 4 ++-- src/core/locator/finlandlocatorfilter.cpp | 4 ++-- src/core/locator/gotolocatorfilter.cpp | 4 ++-- src/core/locator/locatormodelsuperbridge.cpp | 12 ++++++------ src/core/locator/locatormodelsuperbridge.h | 14 +++++++------- src/qml/editorwidgets/RelationReference.qml | 4 ++-- .../relationeditors/ordered_relation_editor.qml | 4 ++-- .../relationeditors/relation_editor.qml | 4 ++-- src/qml/qgismobileapp.qml | 5 +++-- 11 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/core/locator/activelayerfeatureslocatorfilter.cpp b/src/core/locator/activelayerfeatureslocatorfilter.cpp index d4ca06ec38..c3f86bbd3f 100644 --- a/src/core/locator/activelayerfeatureslocatorfilter.cpp +++ b/src/core/locator/activelayerfeatureslocatorfilter.cpp @@ -436,8 +436,8 @@ void ActiveLayerFeaturesLocatorFilter::triggerResultFromAction( const QgsLocator mLocatorBridge->mapSettings()->setExtent( r, true ); } - mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", layer->crs() ); + mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom ); + mLocatorBridge->geometryHighlighter()->setProperty( "crs", layer->crs() ); break; } } diff --git a/src/core/locator/bookmarklocatorfilter.cpp b/src/core/locator/bookmarklocatorfilter.cpp index 7893c750d2..89bb7b7a54 100644 --- a/src/core/locator/bookmarklocatorfilter.cpp +++ b/src/core/locator/bookmarklocatorfilter.cpp @@ -77,6 +77,6 @@ void BookmarkLocatorFilter::triggerResultFromAction( const QgsLocatorResult &res mLocatorBridge->bookmarks()->setExtentFromBookmark( mLocatorBridge->bookmarks()->index( row, 0 ) ); QgsGeometry geom( mLocatorBridge->bookmarks()->data( mLocatorBridge->bookmarks()->index( row, 0 ), BookmarkModel::BookmarkPoint ).value() ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() ); + mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom ); + mLocatorBridge->geometryHighlighter()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() ); } diff --git a/src/core/locator/featureslocatorfilter.cpp b/src/core/locator/featureslocatorfilter.cpp index 96774e287a..4f537994c7 100644 --- a/src/core/locator/featureslocatorfilter.cpp +++ b/src/core/locator/featureslocatorfilter.cpp @@ -241,7 +241,7 @@ void FeaturesLocatorFilter::triggerResultFromAction( const QgsLocatorResult &res mLocatorBridge->mapSettings()->setExtent( r, true ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", layer->crs() ); + mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom ); + mLocatorBridge->geometryHighlighter()->setProperty( "crs", layer->crs() ); } } diff --git a/src/core/locator/finlandlocatorfilter.cpp b/src/core/locator/finlandlocatorfilter.cpp index 16daa5f8cf..2ae7007687 100644 --- a/src/core/locator/finlandlocatorfilter.cpp +++ b/src/core/locator/finlandlocatorfilter.cpp @@ -61,6 +61,6 @@ void FinlandLocatorFilter::handleGeocodeResult( const QgsGeocoderResult &result mLocatorBridge->mapSettings()->setCenter( transformedGeometry.centroid().vertexAt( 0 ), true ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", result.geometry() ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", result.crs() ); + mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", result.geometry() ); + mLocatorBridge->geometryHighlighter()->setProperty( "crs", result.crs() ); } diff --git a/src/core/locator/gotolocatorfilter.cpp b/src/core/locator/gotolocatorfilter.cpp index 3de2491c9d..52e71120eb 100644 --- a/src/core/locator/gotolocatorfilter.cpp +++ b/src/core/locator/gotolocatorfilter.cpp @@ -206,7 +206,7 @@ void GotoLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result, { mLocatorBridge->mapSettings()->setCenter( geom.vertexAt( 0 ), true ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom ); - mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() ); + mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom ); + mLocatorBridge->geometryHighlighter()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() ); } } diff --git a/src/core/locator/locatormodelsuperbridge.cpp b/src/core/locator/locatormodelsuperbridge.cpp index 7c82562d53..534fadd1b3 100644 --- a/src/core/locator/locatormodelsuperbridge.cpp +++ b/src/core/locator/locatormodelsuperbridge.cpp @@ -113,18 +113,18 @@ void LocatorModelSuperBridge::setMapSettings( QgsQuickMapSettings *mapSettings ) emit mapSettingsChanged(); } -QObject *LocatorModelSuperBridge::locatorHighlightGeometry() const +QObject *LocatorModelSuperBridge::geometryHighlighter() const { - return mLocatorHighlightGeometry; + return mGeometryHighlighter; } -void LocatorModelSuperBridge::setLocatorHighlightGeometry( QObject *locatorHighlightGeometry ) +void LocatorModelSuperBridge::setGeometryHighlighter( QObject *geometryHighlighter ) { - if ( locatorHighlightGeometry == mLocatorHighlightGeometry ) + if ( mGeometryHighlighter == geometryHighlighter ) return; - mLocatorHighlightGeometry = locatorHighlightGeometry; - emit locatorHighlightGeometryChanged(); + mGeometryHighlighter = geometryHighlighter; + emit geometryHighlighterChanged(); } FeatureListExtentController *LocatorModelSuperBridge::featureListController() const diff --git a/src/core/locator/locatormodelsuperbridge.h b/src/core/locator/locatormodelsuperbridge.h index 8448f1ee6b..f7e0f8d797 100644 --- a/src/core/locator/locatormodelsuperbridge.h +++ b/src/core/locator/locatormodelsuperbridge.h @@ -63,7 +63,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge //! The current project's map settings Q_PROPERTY( QgsQuickMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged ) //! The locator highlight geometry object through which locator actions can highhlight features - Q_PROPERTY( QObject *locatorHighlightGeometry READ locatorHighlightGeometry WRITE setLocatorHighlightGeometry NOTIFY locatorHighlightGeometryChanged ) + Q_PROPERTY( QObject *geometryHighlighter READ geometryHighlighter WRITE setGeometryHighlighter NOTIFY geometryHighlighterChanged ) //! The feature list extent controller Q_PROPERTY( FeatureListExtentController *featureListController READ featureListController WRITE setFeatureListController NOTIFY featureListControllerChanged ) //! The current project's active layer @@ -94,10 +94,10 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge //! \copydoc LocatorModelSuperBridge::navigation void setNavigation( Navigation *navigation ); - //! \copydoc LocatorModelSuperBridge::locatorHighlightGeometry - QObject *locatorHighlightGeometry() const; - //! \copydoc LocatorModelSuperBridge::locatorHighlightGeometry - void setLocatorHighlightGeometry( QObject *locatorHighlightGeometry ); + //! \copydoc LocatorModelSuperBridge::geometryHighlighter + QObject *geometryHighlighter() const; + //! \copydoc LocatorModelSuperBridge::geometryHighlighter + void setGeometryHighlighter( QObject *geometryHighlighter ); //! \copydoc LocatorModelSuperBridge::featureListController FeatureListExtentController *featureListController() const; @@ -158,7 +158,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge void mapSettingsChanged(); void bookmarksChanged(); void navigationChanged(); - void locatorHighlightGeometryChanged(); + void geometryHighlighterChanged(); void featureListControllerChanged(); void activeLayerChanged(); void messageEmitted( const QString &text ); @@ -172,7 +172,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge private: QgsQuickMapSettings *mMapSettings = nullptr; - QObject *mLocatorHighlightGeometry = nullptr; + QObject *mGeometryHighlighter = nullptr; FeatureListExtentController *mFeatureListController = nullptr; QPointer mActiveLayer; bool mKeepScale = false; diff --git a/src/qml/editorwidgets/RelationReference.qml b/src/qml/editorwidgets/RelationReference.qml index 6d608c249a..ed06b26cfb 100644 --- a/src/qml/editorwidgets/RelationReference.qml +++ b/src/qml/editorwidgets/RelationReference.qml @@ -72,8 +72,8 @@ EditorWidgetBase { onClicked: { if (listModel.currentLayer !== undefined) { var feature = listModel.getFeatureFromKeyValue(relationReference.currentKeyValue); - locatorHighlightItem.geometryWrapper.qgsGeometry = feature.geometry; - locatorHighlightItem.geometryWrapper.crs = listModel.currentLayer.crs; + geometryHighlighter.geometryWrapper.qgsGeometry = feature.geometry; + geometryHighlighter.geometryWrapper.crs = listModel.currentLayer.crs; mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, listModel.currentLayer, feature); } } diff --git a/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml b/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml index 07e7b18151..8246c1a291 100644 --- a/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml +++ b/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml @@ -197,8 +197,8 @@ EditorWidgetBase { onClicked: { if (orderedRelationModel.relation.referencingLayer !== undefined) { - locatorHighlightItem.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry; - locatorHighlightItem.geometryWrapper.crs = orderedRelationModel.relation.referencingLayer.crs; + geometryHighlighter.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry; + geometryHighlighter.geometryWrapper.crs = orderedRelationModel.relation.referencingLayer.crs; mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, orderedRelationModel.relation.referencingLayer, nmRelationId ? model.nmReferencingFeature : model.referencingFeature); } } diff --git a/src/qml/editorwidgets/relationeditors/relation_editor.qml b/src/qml/editorwidgets/relationeditors/relation_editor.qml index 8cb07f4877..a391ba9858 100644 --- a/src/qml/editorwidgets/relationeditors/relation_editor.qml +++ b/src/qml/editorwidgets/relationeditors/relation_editor.qml @@ -211,8 +211,8 @@ EditorWidgetBase { onClicked: { if (relationEditorModel.relation.referencingLayer !== undefined) { - locatorHighlightItem.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry; - locatorHighlightItem.geometryWrapper.crs = relationEditorModel.relation.referencingLayer.crs; + geometryHighlighter.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry; + geometryHighlighter.geometryWrapper.crs = relationEditorModel.relation.referencingLayer.crs; mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, relationEditorModel.relation.referencingLayer, nmRelationId ? model.nmReferencingFeature : model.referencingFeature); } } diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 90741a4221..a7c4854365 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -102,7 +102,7 @@ ApplicationWindow { featureListController: featureForm.extentController mapSettings: mapCanvas.mapSettings navigation: navigation - locatorHighlightGeometry: locatorHighlightItem.geometryWrapper + geometryHighlighter: geometryHighlighter.geometryWrapper keepScale: qfieldSettings.locatorKeepScale onMessageEmitted: { @@ -987,7 +987,8 @@ ApplicationWindow { /* Highlight features identified by locator or relation editor widgets */ GeometryHighlighter { - id: locatorHighlightItem + id: geometryHighlighter + objectName: "geometryHighlighter" } MapToScreen {