-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.py
71 lines (54 loc) · 2.29 KB
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import logging
import sys
from PyQt5.QtCore import PYQT_VERSION_STR, QT_VERSION_STR
from PyQt5.QtWidgets import QAction
from qgis.core import QgsProject
from qgis.gui import QgisInterface
from qgis.utils import iface
iface: QgisInterface
from .tool.tool import OFDSDedupToolDialog
from .tool.style import OFDSStyleToolDialog
logger = logging.getLogger(__name__)
class OFDSDedupPlugin:
def __init__(self):
self.consolidate_tool_dialog = OFDSDedupToolDialog()
self.style_tool_dialog = OFDSStyleToolDialog()
def initGui(self):
self.action_consolidate = QAction("Consolidate OFDS", iface.mainWindow())
self.action_consolidate.setObjectName("consolidateOfdsAction")
self.action_consolidate.triggered.connect(self.run_consolidate)
iface.addToolBarIcon(self.action_consolidate)
iface.addPluginToMenu("&OFDS", self.action_consolidate)
self.action_style = QAction("Style OFDS", iface.mainWindow())
self.action_style.setObjectName("styleOfdsAction")
self.action_style.triggered.connect(self.run_style)
iface.addToolBarIcon(self.action_style)
iface.addPluginToMenu("&OFDS", self.action_style)
def unload(self):
iface.removePluginMenu("&OFDS", self.action_consolidate)
iface.removeToolBarIcon(self.action_consolidate)
del self.action_consolidate
iface.removePluginMenu("&OFDS", self.action_style)
iface.removeToolBarIcon(self.action_style)
del self.action_style
self.consolidate_tool_dialog.close()
del self.consolidate_tool_dialog
self.style_tool_dialog.close()
del self.style_tool_dialog
def run_consolidate(self):
logger.debug("Opening OFDS Consolidate Tool Dialog")
logger.debug(
f"Qt: v{QT_VERSION_STR} PyQt: v{PYQT_VERSION_STR} Python: {sys.version}"
)
project = QgsProject.instance()
if not project:
raise Exception
self.consolidate_tool_dialog.reset(project=project)
self.consolidate_tool_dialog.show()
def run_style(self):
logger.debug("Opening OFDS Style Tool Dialog")
project = QgsProject.instance()
if not project:
raise Exception
self.style_tool_dialog.refresh_layers()
self.style_tool_dialog.show()