diff --git a/README.md b/README.md index 202cd79..228d3b9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ AusMap is a QGIS plugin for visualising publicly available Australian geographic ### Requirements -- QGIS version 3.18 or higher +- QGIS version 3.18 or higher, including QGIS 4.x - Internet access for fetching online map layer web services ### Installation through QGIS diff --git a/ausmap.py b/ausmap.py index f9120bf..273d938 100644 --- a/ausmap.py +++ b/ausmap.py @@ -1,9 +1,9 @@ import os.path import webbrowser -from PyQt5.QtCore import QFileInfo -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QAction, QMenu +from qgis.PyQt.QtCore import QFileInfo +from qgis.PyQt.QtGui import QIcon +from qgis.PyQt.QtWidgets import QAction, QMenu from qgis.core import QgsProject, QgsSettings from .config import Config diff --git a/ausmap_config.py b/ausmap_config.py index 875f4f6..d8d74f9 100644 --- a/ausmap_config.py +++ b/ausmap_config.py @@ -3,7 +3,7 @@ from datetime import datetime, timezone from urllib.request import urlopen -from PyQt5.QtCore import QFile, QIODevice, QObject +from qgis.PyQt.QtCore import QFile, QIODevice, QObject from qgis.core import Qgis, QgsMessageLog from .qlr_file import QlrFile @@ -81,12 +81,12 @@ def _get_qlr_file(self): "An unexpected error occurred while" f"fetching QLR file: {str(error)}" ), - level=Qgis.Critical, + level=Qgis.MessageLevel.Critical, ) def _read_cached_qlr(self): f = QFile(self.cached_ausmap_qlr_file) - f.open(QIODevice.ReadOnly) + f.open(self._read_only_mode()) content = f.readAll() return QlrFile(content) @@ -99,3 +99,7 @@ def _write_local_qlr(self, content): os.remove(self.cached_ausmap_qlr_file) with codecs.open(self.cached_ausmap_qlr_file, "w", "utf-8") as f: f.write(content) + + @staticmethod + def _read_only_mode(): + return getattr(QIODevice, "ReadOnly", QIODevice.OpenModeFlag.ReadOnly) diff --git a/config.py b/config.py index 112e774..c506a92 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -from PyQt5 import QtCore +from qgis.PyQt import QtCore from .ausmap_config import AusMapConfig from .local_config import LocalConfig diff --git a/local_config.py b/local_config.py index 612dc3c..3270951 100644 --- a/local_config.py +++ b/local_config.py @@ -1,6 +1,6 @@ import os -from PyQt5.QtCore import QFile, QIODevice +from qgis.PyQt.QtCore import QFile, QIODevice from .qlr_file import QlrFile @@ -30,7 +30,7 @@ def load(self): def _load_qlr_file(self): """Read and load the QLR file from the local path.""" f = QFile(self.local_qlr_file_path) - f.open(QIODevice.ReadOnly) + f.open(self._read_only_mode()) return QlrFile(f.readAll()) def _parse_local_categories(self): @@ -56,3 +56,7 @@ def get_categories(self): def get_maplayer_node(self, layer_id): return self.qlr_file.get_maplayer_node(layer_id) + + @staticmethod + def _read_only_mode(): + return getattr(QIODevice, "ReadOnly", QIODevice.OpenModeFlag.ReadOnly) diff --git a/metadata.txt b/metadata.txt index b25c90b..0ad02b9 100644 --- a/metadata.txt +++ b/metadata.txt @@ -1,9 +1,10 @@ [general] name=AusMap qgisMinimumVersion=3.18 +qgisMaximumVersion=4.99 description=AusMap is a plugin for visualising publicly available Australian geographic data. about=AusMap gives quick access to a variety of feature sets and map layers provided by Geoscience Australia, the Google Maps Platform and OpenStreetMap. Selecting a desired layer from the AusMap menu will add it to the map canvas with styling and labelling applied. The layers are provided via WCS, WFS, WMS, WMTS and XYZ services, which all require an active internet connection. -version=2.0 +version=2.1 author=WMS Engineering email=tools@wmseng.com.au @@ -15,6 +16,7 @@ changelog=- Updated links to Geoscience Australia web services - Fixed locator filter - User manual included - Fixed issue with AusMap settings dialog overwriting QGIS > Preferences on Mac + - Added QGIS 4 / Qt6 compatibility updates homepage=https://wmseng.com.au/ repository=https://github.com/WMS-Engineering/AusMap diff --git a/qlr_file.py b/qlr_file.py index b62d2e9..27a9ea0 100644 --- a/qlr_file.py +++ b/qlr_file.py @@ -1,6 +1,6 @@ import urllib.parse as urlparse -from PyQt5 import QtXml +from qgis.PyQt import QtXml class QlrFile: diff --git a/resources.py b/resources.py index 4785f34..0b7b44b 100644 --- a/resources.py +++ b/resources.py @@ -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\x01\xdb\ diff --git a/settings/options_tab.py b/settings/options_tab.py index 0fe2204..cad4d42 100644 --- a/settings/options_tab.py +++ b/settings/options_tab.py @@ -1,7 +1,7 @@ import os -from PyQt5 import uic -from PyQt5.QtGui import QIcon +from qgis.PyQt import uic +from qgis.PyQt.QtGui import QIcon from qgis.core import QgsSettings from qgis.gui import ( QgsFileWidget,