-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_plugin.py
More file actions
55 lines (43 loc) · 1.67 KB
/
Copy pathmain_plugin.py
File metadata and controls
55 lines (43 loc) · 1.67 KB
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
# -*- coding: utf-8 -*-
"""02-Multimap — main plugin class.
Toolbar-only integration: a single launch icon, no top-level QGIS menu.
"""
from __future__ import annotations
import os
from qgis.PyQt.QtGui import QIcon
try:
from qgis.PyQt.QtWidgets import QAction
except ImportError:
from qgis.PyQt.QtGui import QAction
class O2MultiMapPlugin:
def __init__(self, iface):
self.iface = iface
self.plugin_dir = os.path.dirname(__file__)
self.icon_path = os.path.join(self.plugin_dir, "icons", "icon.png")
self.action: QAction | None = None
self.dialog = None
def initGui(self) -> None:
self.action = QAction(
QIcon(self.icon_path),
"02-Multimap Workspace",
self.iface.mainWindow()
)
self.action.setStatusTip("Open multi-panel synchronized map viewer workspace.")
self.action.triggered.connect(self.show_dialog)
# Add to standard toolbar
self.iface.addToolBarIcon(self.action)
def unload(self) -> None:
if self.action:
self.iface.removeToolBarIcon(self.action)
self.action = None
if self.dialog:
self.dialog.close()
self.dialog = None
# ───────────────────────── Dialog lifecycle ─────────────────────────
def show_dialog(self) -> None:
if self.dialog is None:
from .dialog import MultiMapDialog
self.dialog = MultiMapDialog(self.iface, self.iface.mainWindow())
self.dialog.show()
self.dialog.raise_()
self.dialog.activateWindow()