diff --git a/qfieldsync/gui/project_configuration_widget.py b/qfieldsync/gui/project_configuration_widget.py index 3c0cf336..28de3858 100644 --- a/qfieldsync/gui/project_configuration_widget.py +++ b/qfieldsync/gui/project_configuration_widget.py @@ -110,6 +110,19 @@ def __init__(self, parent=None): self.event_eater = EventEater() self.attachmentDirsListWidget.installEventFilter(self.event_eater) + self.geofencingBehaviorComboBox.addItem( + self.tr("Alert users when inside an area"), + ProjectProperties.GeofencingBehavior.ALERT_INSIDE_AREAS, + ) + self.geofencingBehaviorComboBox.addItem( + self.tr("Alert users when outside all areas"), + ProjectProperties.GeofencingBehavior.ALERT_OUTSIDE_AREAS, + ) + self.geofencingBehaviorComboBox.addItem( + self.tr("Inform users when entering and leaving an area"), + ProjectProperties.GeofencingBehavior.INFORM_ENTER_LEAVE_AREAS, + ) + self.reloadProject() def reloadProject(self): @@ -144,10 +157,16 @@ def reloadProject(self): self.mapThemeComboBox.addItem(theme) self.layerComboBox.setFilters(QgsMapLayerProxyModel.RasterLayer) + + self.geofencingLayerComboBox.setFilters(QgsMapLayerProxyModel.PolygonLayer) + self.geofencingLayerComboBox.setAllowEmptyLayer(True) + self.digitizingLogsLayerComboBox.setFilters(QgsMapLayerProxyModel.PointLayer) self.digitizingLogsLayerComboBox.setAllowEmptyLayer(True) self.__project_configuration = ProjectConfiguration(self.project) + + # Base map settings self.createBaseMapGroupBox.setChecked( self.__project_configuration.create_base_map ) @@ -169,6 +188,27 @@ def reloadProject(self): ) self.layerComboBox.setLayer(layer) + # Geofencing settings + self.geofencingGroupBox.setChecked( + self.__project_configuration.geofencing_is_active + ) + + geofencingLayer = QgsProject.instance().mapLayer( + self.__project_configuration.geofencing_layer + ) + self.geofencingLayerComboBox.setLayer(geofencingLayer) + + self.geofencingBehaviorComboBox.setCurrentIndex( + self.geofencingBehaviorComboBox.findData( + self.__project_configuration.geofencing_behavior + ) + ) + + self.geofencingShouldPreventDigitizingCheckBox.setChecked( + self.__project_configuration.geofencing_should_prevent_digitizing + ) + + # Advanced settings digitizingLogsLayer = QgsProject.instance().mapLayer( self.__project_configuration.digitizing_logs_layer ) @@ -229,14 +269,25 @@ def apply(self): self.cloudLayersConfigWidget.apply() self.cableLayersConfigWidget.apply() + # Base map settings self.__project_configuration.create_base_map = ( self.createBaseMapGroupBox.isChecked() ) + + if self.singleLayerRadioButton.isChecked(): + self.__project_configuration.base_map_type = ( + ProjectProperties.BaseMapType.SINGLE_LAYER + ) + else: + self.__project_configuration.base_map_type = ( + ProjectProperties.BaseMapType.MAP_THEME + ) + self.__project_configuration.base_map_theme = ( self.mapThemeComboBox.currentText() ) - # try/pass these because the save button is global for all + # try/pass layer ID fetching because the save button is global for all # project settings, not only QField try: self.__project_configuration.base_map_layer = ( @@ -244,6 +295,30 @@ def apply(self): ) except AttributeError: pass + + # Geofencing settings + self.__project_configuration.geofencing_is_active = ( + self.geofencingGroupBox.isChecked() + ) + + try: + self.__project_configuration.geofencing_layer = ( + self.geofencingLayerComboBox.currentLayer().id() + if self.geofencingLayerComboBox.currentLayer() + else "" + ) + except AttributeError: + pass + + self.__project_configuration.geofencing_behavior = ( + self.geofencingBehaviorComboBox.currentData() + ) + + self.__project_configuration.geofencing_should_prevent_digitizing = ( + self.geofencingShouldPreventDigitizingCheckBox.isChecked() + ) + + # Advanced settings try: self.__project_configuration.digitizing_logs_layer = ( self.digitizingLogsLayerComboBox.currentLayer().id() @@ -253,15 +328,6 @@ def apply(self): except AttributeError: pass - if self.singleLayerRadioButton.isChecked(): - self.__project_configuration.base_map_type = ( - ProjectProperties.BaseMapType.SINGLE_LAYER - ) - else: - self.__project_configuration.base_map_type = ( - ProjectProperties.BaseMapType.MAP_THEME - ) - self.__project_configuration.base_map_mupp = float( self.mapUnitsPerPixel.value() ) diff --git a/qfieldsync/ui/project_configuration_widget.ui b/qfieldsync/ui/project_configuration_widget.ui index b3fe52a3..c1a0a3a3 100644 --- a/qfieldsync/ui/project_configuration_widget.ui +++ b/qfieldsync/ui/project_configuration_widget.ui @@ -356,6 +356,55 @@ + + + + Geofencing + + + true + + + + + + QField provides real-time feedback to users when their device position falls within or outside of areas defined by a selected polygon layer. + + + true + + + + + + + Geofencing areas layer + + + + + + + + + + Geofencing behavior + + + + + + + + + + Prevent digitizing when alerting + + + + + + diff --git a/requirements.txt b/requirements.txt index 5141ebc1..972422ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ future transifex-client # NOTE `libqfielsync` version should be defined in the `*.tar.gz` format, not `git+https://` to make `wheel` happy -libqfieldsync @ https://github.com/opengisch/libqfieldsync/archive/c98ef2671aca31c7943d3aa4c69221dbdb157d5a.tar.gz +libqfieldsync @ https://github.com/opengisch/libqfieldsync/archive/61523b5775dd1bccc25abcf4b9c7a266af18c214.tar.gz