Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[general]
name=pygeoapi configurator
qgisMinimumVersion=3.0
qgisMaximumVersion=4.99
supportsQt6=True
description=Read and write a pygeoapi configuration
version=0.24
author=DGT,ByteRoad
Expand Down
11 changes: 7 additions & 4 deletions pygeoapi_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
* *
***************************************************************************/
"""
from PyQt5.QtCore import QSettings, QTranslator, QCoreApplication
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
from qgis.PyQt.QtGui import QIcon
try:
from qgis.PyQt.QtGui import QAction # QGIS 4 / Qt6
except ImportError:
from qgis.PyQt.QtWidgets import QAction # QGIS 3 / Qt5

# Initialize Qt resources from file resources.py
from .resources import *
Expand Down Expand Up @@ -187,7 +190,7 @@ def run(self):
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()
result = self.dlg.exec()
# See if OK was pressed
if result:
# Do something useful here - delete the line containing pass and
Expand Down
28 changes: 14 additions & 14 deletions pygeoapi_config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
)
from .models.top_level.utils import STRING_SEPARATOR

from PyQt5 import QtWidgets, uic
from PyQt5.QtWidgets import (
from qgis.PyQt import QtWidgets, uic
from qgis.PyQt.QtWidgets import (
QMainWindow,
QFileDialog,
QMessageBox,
Expand All @@ -57,7 +57,7 @@
QApplication,
) # or PyQt6.QtWidgets

from PyQt5.QtCore import (
from qgis.PyQt.QtCore import (
Qt,
QModelIndex,
QStringListModel,
Expand Down Expand Up @@ -173,7 +173,7 @@ def on_button_clicked(self, button):
print(f"Button clicked: {button.text()}, Role: {role}")

# You can also check the standard button type
if button == self.buttonBox.button(QDialogButtonBox.Save):
if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Save):
# proceed only if UI data inputs are valid
if self._set_validate_ui_data()[0]:

Expand Down Expand Up @@ -201,7 +201,7 @@ def on_button_clicked(self, button):
if file_path:
self.save_to_file(processed_config_data, file_path)

elif button == self.buttonBox.button(QDialogButtonBox.Open):
elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Open):
if self.serverRadio.isChecked():
self.server_config(data_to_push=None)
else:
Expand All @@ -210,15 +210,15 @@ def on_button_clicked(self, button):
)
self.open_file(file_name)

elif button == self.buttonBox.button(QDialogButtonBox.Close):
elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
self.reject()
return

def server_config(self, data_to_push: dict | None = None):

dialog = ServerConfigDialog(self)

if dialog.exec_():
if dialog.exec():
url = dialog.get_server_url()
if data_to_push is not None:
self.push_to_server(url, data_to_push)
Expand Down Expand Up @@ -294,7 +294,7 @@ def pull_from_server(self, url):
def save_to_file(self, new_config_data: dict, file_path: str):

if file_path:
QApplication.setOverrideCursor(Qt.WaitCursor)
QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor)
try:
with open(file_path, "w", encoding="utf-8") as file:
yaml.dump(
Expand Down Expand Up @@ -374,7 +374,7 @@ def update_config_data_and_ui(self, data_dict):
self,
"Warning",
f"All missing or replaced properties (check logs for more details): {all_missing_props}",
).exec_()
).exec()
except:
# QgsMessageLog import error in pytests, ignore
pass # nosec
Expand All @@ -395,7 +395,7 @@ def _set_validate_ui_data(self) -> tuple[bool, list]:
self,
"Warning",
f"Properties are missing or have invalid values: {invalid_props}",
).exec_()
).exec()
except:
pass # nosec

Expand Down Expand Up @@ -444,9 +444,9 @@ def _diff_original_and_current_data(
# if diff detected, show a window with the choice to approve the diff
QgsMessageLog.logMessage(f"{diff_data}")
dialog = ReadOnlyTextDialog(self, "Warning", diff_data, True)
result = dialog.exec_() # returns QDialog.Accepted (1) or QDialog.Rejected (0)
result = dialog.exec() # returns QDialog.Accepted (1) or QDialog.Rejected (0)

if result == QDialog.Accepted:
if result == QDialog.DialogCode.Accepted:
return True, new_config_data
else:
return False, None
Expand Down Expand Up @@ -714,9 +714,9 @@ def delete_resource(self):
self,
"Confirm action",
f"Delete resource '{self.current_res_name}'?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
)
if reply == QMessageBox.Yes:
if reply == QMessageBox.StandardButton.Yes:
self.config_data.delete_resource(self)
self.ui_setter.preview_resource()
self.ui_setter.refresh_resources_list_ui()
Expand Down
2 changes: 1 addition & 1 deletion resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore
from qgis.PyQt import QtCore

qt_resource_data = b"\
\x00\x00\xf7\x36\
Expand Down
14 changes: 7 additions & 7 deletions server_config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from qgis.PyQt import QtCore, QtGui, QtWidgets


class Ui_serverDialog(object):
Expand All @@ -29,7 +29,7 @@ def setupUi(self, serverDialog):
self.radioHttps = QtWidgets.QRadioButton(self.serverGroupBox)
self.radioHttps.setObjectName("radioHttps")
self.gridLayout.addWidget(self.radioHttps, 0, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.gridLayout.addItem(spacerItem, 0, 2, 1, 1)
self.verticalLayout.addWidget(self.serverGroupBox)
self.serverHorizontalLayout = QtWidgets.QHBoxLayout()
Expand All @@ -52,14 +52,14 @@ def setupUi(self, serverDialog):
self.ServerSpinBox.setProperty("value", 5000)
self.ServerSpinBox.setObjectName("ServerSpinBox")
self.horizontalLayout.addWidget(self.ServerSpinBox)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.verticalLayout.addLayout(self.horizontalLayout)
spacerItem2 = QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.MinimumExpanding)
spacerItem2 = QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.MinimumExpanding)
self.verticalLayout.addItem(spacerItem2)
self.serverButtonBox = QtWidgets.QDialogButtonBox(serverDialog)
self.serverButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.serverButtonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.serverButtonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.serverButtonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.serverButtonBox.setObjectName("serverButtonBox")
self.verticalLayout.addWidget(self.serverButtonBox)

Expand All @@ -85,4 +85,4 @@ def retranslateUi(self, serverDialog):
ui = Ui_serverDialog()
ui.setupUi(serverDialog)
serverDialog.show()
sys.exit(app.exec_())
sys.exit(app.exec())
8 changes: 4 additions & 4 deletions ui_widgets/UiSetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
from .utils import get_widget_text_value, reset_widget


from PyQt5.QtGui import QIntValidator, QDoubleValidator
from PyQt5.QtCore import (
from qgis.PyQt.QtGui import QIntValidator, QDoubleValidator
from qgis.PyQt.QtCore import (
Qt,
)
from PyQt5.QtWidgets import QMessageBox
from qgis.PyQt.QtWidgets import QMessageBox

# make imports optional for pytests
try:
Expand Down Expand Up @@ -582,7 +582,7 @@ def setup_map_widget(self):
dialog.bbox_map_canvas = QgsMapCanvas()
crs = QgsCoordinateReferenceSystem("EPSG:4326")
dialog.bbox_map_canvas.setDestinationCrs(crs)
dialog.bbox_map_canvas.setCanvasColor(Qt.white)
dialog.bbox_map_canvas.setCanvasColor(Qt.GlobalColor.white)
dialog.bbox_map_canvas.setLayers([dialog.bbox_base_layer])
dialog.bbox_map_canvas.zoomToFullExtent()
# self.canvas.setExtent(layer.extent(), True)
Expand Down
8 changes: 4 additions & 4 deletions ui_widgets/WarningDialog.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from datetime import datetime
import json
from PyQt5.QtWidgets import (
from qgis.PyQt.QtWidgets import (
QDialog,
QVBoxLayout,
QTextEdit,
QPushButton,
QDialogButtonBox,
)
from PyQt5.QtCore import Qt
from qgis.PyQt.QtCore import Qt


def default_serializer(obj):
Expand All @@ -23,7 +23,7 @@ def __init__(
):
super().__init__(parent)
self.setWindowTitle(title)
self.setWindowFlag(Qt.WindowStaysOnTopHint) # optional: always on top
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint) # optional: always on top
self.setModal(True) # blocks parent

layout = QVBoxLayout(self)
Expand Down Expand Up @@ -51,7 +51,7 @@ def __init__(

else:
# OK / Cancel buttons
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
layout.addWidget(button_box)
8 changes: 4 additions & 4 deletions ui_widgets/providers/NewProviderWindow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import (
from qgis.PyQt.QtWidgets import (
QWidget,
QComboBox,
QLineEdit,
Expand All @@ -10,8 +10,8 @@
QGridLayout,
QDialog,
)
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtGui import QIntValidator
from qgis.PyQt.QtCore import pyqtSignal, Qt
from qgis.PyQt.QtGui import QIntValidator

from ...models.top_level.providers import (
ProviderPostgresql,
Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(

self.setWindowTitle(f"{provider_type.value.title()} Provider Configuration")

self.setWindowFlag(Qt.WindowStaysOnTopHint) # always on top
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint) # always on top
self.setModal(True) # parent becomes unclickable

self.main_layout = QVBoxLayout(self)
Expand Down
8 changes: 4 additions & 4 deletions ui_widgets/providers/StringListWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtWidgets import (
from qgis.PyQt.QtWidgets import (
QWidget,
QVBoxLayout,
QListWidget,
Expand All @@ -11,7 +11,7 @@
QDialog,
QDialogButtonBox,
)
from PyQt5.QtGui import QFontMetrics
from qgis.PyQt.QtGui import QFontMetrics


class StringListWidget(QWidget):
Expand Down Expand Up @@ -61,7 +61,7 @@ def add_item(self, validation_callback):
dialog = InputWithValidateDialog(
self.default_new_string, validation_callback, self
)
if dialog.exec_() == QDialog.Accepted:
if dialog.exec() == QDialog.DialogCode.Accepted:
text = dialog.line_edit.text().strip()
if text:
self.list_widget.addItem(text)
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(self, default_text="", validation_callback=None, parent=None):

# Standard OK/Cancel buttons
self.button_box = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
Expand Down
4 changes: 2 additions & 2 deletions ui_widgets/providers/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from PyQt5.QtWidgets import (
from qgis.PyQt.QtWidgets import (
QHBoxLayout,
QLabel,
QLineEdit,
QGridLayout,
QComboBox,
QPushButton,
)
from PyQt5.QtGui import QIntValidator
from qgis.PyQt.QtGui import QIntValidator

from .StringListWidget import StringListWidget
from ..utils import get_url_status, set_combo_box_value_from_data
Expand Down
2 changes: 1 addition & 1 deletion ui_widgets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
from urllib.parse import urlparse

from PyQt5.QtWidgets import QComboBox, QLineEdit, QMessageBox
from qgis.PyQt.QtWidgets import QComboBox, QLineEdit, QMessageBox


def get_widget_text_value(widget):
Expand Down