Skip to content

Commit

Permalink
[fix] Use new Enum only for QGIS 3.39+ (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor authored Oct 8, 2024
1 parent 0345d24 commit 8b2d3d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pg_service_parser/core/service_connections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from qgis.core import (
Qgis,
QgsAbstractDatabaseProviderConnection,
QgsDataSourceUri,
QgsProviderRegistry,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8b2d3d6

Please sign in to comment.