diff --git a/felt/gui/create_map_dialog.py b/felt/gui/create_map_dialog.py index e635941..ca41066 100644 --- a/felt/gui/create_map_dialog.py +++ b/felt/gui/create_map_dialog.py @@ -61,6 +61,8 @@ ) from .workspaces_combo import WorkspacesComboBox from ..core import ( + LayerExporter, + LayerSupport, MapUploaderTask, Map ) @@ -309,9 +311,37 @@ def upload_raster_as_styled_toggled(): ) self.started = False - self._validate() + self._validate_initial() self.maps_widget.filter_line_edit().setFocus() + def _fatal_error(self, error: str): + """ + Called when a fatal error which prevents sharing occurs + """ + self.stacked_widget.setCurrentIndex(2) + self.error_label.setText(error) + self.button_box.button(QDialogButtonBox.Ok).deleteLater() + + def _validate_initial(self): + + error: Optional[str] = None + + export_layers = self.layers if self.layers else \ + QgsProject.instance().mapLayers().values() + for layer in export_layers: + support, reason = LayerExporter.can_export_layer(layer) + if support == LayerSupport.UnsavedEdits: + error = self.tr( + 'Layer "{}" has unsaved changes. Please save ' + 'the layer before sharing to Felt.').format( + layer.name()) + break + + if error: + self._fatal_error(error) + else: + self._validate() + def _workspace_changed(self, workspace_id: str): """ Called when the selected workspace is changed diff --git a/felt/plugin.py b/felt/plugin.py index 872aeec..b38e445 100644 --- a/felt/plugin.py +++ b/felt/plugin.py @@ -210,20 +210,6 @@ def _create_map_authorized(self, self._create_map_dialog.raise_() return - export_layers = layers if layers else \ - QgsProject.instance().mapLayers().values() - for layer in export_layers: - support, reason = LayerExporter.can_export_layer(layer) - if support == LayerSupport.UnsavedEdits: - QMessageBox.warning( - self.iface.mainWindow(), - self.tr('Share to Felt'), - self.tr( - 'Layer "{}" has unsaved changes. Please save ' - 'the layer before sharing to Felt.').format( - layer.name())) - return - def _cleanup_dialog(_dialog): """ Remove references to outdated dialogs diff --git a/felt/ui/create_map.ui b/felt/ui/create_map.ui index dac5629..1e72402 100644 --- a/felt/ui/create_map.ui +++ b/felt/ui/create_map.ui @@ -166,6 +166,26 @@ + + + + + + TextLabel + + + true + + + true + + + Qt::TextBrowserInteraction + + + + +