Commit 2de01f93 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files
parent 106a2fdb
......@@ -30,6 +30,7 @@ import typing
import warnings
from qgis.core import QgsApplication, Qgis
from qgis.gui import QgsMapLayerConfigWidgetFactory
import qgis.utils
MIN_QGIS_VERSION = '3.14'
__version__ = '1.0'
......@@ -39,7 +40,7 @@ DIR_UI_FILES = DIR_QPS / 'ui'
DIR_ICONS = DIR_UI_FILES / 'icons'
QPS_RESOURCE_FILE = DIR_QPS / 'qpsresources_rc.py'
MAPLAYER_CONFIGWIDGET_FACTORIES = list()
MAPLAYER_CONFIGWIDGET_FACTORIES: typing.List[QgsMapLayerConfigWidgetFactory] = list()
if Qgis.QGIS_VERSION < MIN_QGIS_VERSION:
warnings.warn(f'Your QGIS ({Qgis.QGIS_VERSION}) is outdated. '
......@@ -54,9 +55,11 @@ def registerMapLayerConfigWidgetFactory(factory: QgsMapLayerConfigWidgetFactory)
:return:
:rtype:
"""
global MAPLAYER_CONFIGWIDGET_FACTORIES
assert isinstance(factory, QgsMapLayerConfigWidgetFactory)
if factory not in MAPLAYER_CONFIGWIDGET_FACTORIES:
MAPLAYER_CONFIGWIDGET_FACTORIES.append(factory)
qgis.utils.iface.registerMapLayerConfigWidgetFactory(factory)
def unregisterMapLayerConfigWidgetFactory(factory: QgsMapLayerConfigWidgetFactory):
......@@ -67,10 +70,11 @@ def unregisterMapLayerConfigWidgetFactory(factory: QgsMapLayerConfigWidgetFactor
:return:
:rtype:
"""
global MAPLAYER_CONFIGWIDGET_FACTORIES
assert isinstance(factory, QgsMapLayerConfigWidgetFactory)
while factory in MAPLAYER_CONFIGWIDGET_FACTORIES:
MAPLAYER_CONFIGWIDGET_FACTORIES.remove(factory)
qgis.utils.iface.unregisterMapLayerConfigWidgetFactory(factory)
def mapLayerConfigWidgetFactories() -> typing.List[QgsMapLayerConfigWidgetFactory]:
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment