From a7a443dc6058fd14d5ffb88bab28624469ea4554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= <gcarrillo@linuxmail.org> Date: Tue, 8 Oct 2024 12:15:19 -0500 Subject: [PATCH] [fix] Use new Enum only for QGIS 3.39+ --- pg_service_parser/core/service_connections.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pg_service_parser/core/service_connections.py b/pg_service_parser/core/service_connections.py index 41d798f..528e5c2 100644 --- a/pg_service_parser/core/service_connections.py +++ b/pg_service_parser/core/service_connections.py @@ -1,4 +1,5 @@ from qgis.core import ( + Qgis, QgsAbstractDatabaseProviderConnection, QgsDataSourceUri, QgsProviderRegistry, @@ -37,9 +38,12 @@ def edit_connection(connection_name: str, parent: QWidget) -> None: if connection_name in provider.dbConnections(): pg = QgsGui.sourceSelectProviderRegistry().providerByName("postgres") - widget = pg.createDataSourceWidget( - parent, widgetMode=QgsProviderRegistry.WidgetMode.Standalone - ) + if Qgis.QGIS_VERSION_INT >= 33900: + widget_mode = QgsProviderRegistry.WidgetMode.Standalone + else: + widget_mode = QgsProviderRegistry.WidgetMode.None_ + + widget = pg.createDataSourceWidget(parent, widgetMode=widget_mode) settings = QSettings() settings.setValue("PostgreSQL/connections/selected", connection_name)