GeoDonkey for QGIS 1.12
This commit is contained in:
commit
20ab32da30
63 files changed
+11157
No files matched your search
@@ -0,0 +1,60 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from qgis.PyQt.QtWidgets import (
|
||||
QComboBox,
|
||||
QStackedWidget,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ..compat import icon
|
||||
from ..i18n import tr
|
||||
from . import theme
|
||||
from .tools import PAGES
|
||||
|
||||
|
||||
class ToolsTab(QWidget):
|
||||
def __init__(self, panel, iface, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
self.panel = panel
|
||||
self.iface = iface
|
||||
self.pages: List[QWidget] = []
|
||||
self._build()
|
||||
|
||||
def _build(self) -> None:
|
||||
box = theme.page_box(self)
|
||||
box.addWidget(theme.page_title(tr("Tools")))
|
||||
|
||||
self.chooser = QComboBox()
|
||||
box.addWidget(self.chooser)
|
||||
|
||||
self.stack = QStackedWidget()
|
||||
for page_class in PAGES:
|
||||
page = page_class(self.panel, self.iface)
|
||||
self.pages.append(page)
|
||||
self.stack.addWidget(page)
|
||||
self.chooser.addItem(icon(page_class.ICON), tr(page_class.NAME),
|
||||
page_class.ALGORITHM)
|
||||
box.addWidget(self.stack, 1)
|
||||
|
||||
self.chooser.currentIndexChanged.connect(self.show_page)
|
||||
|
||||
def show_page(self, index: int) -> None:
|
||||
if index < 0 or index >= len(self.pages):
|
||||
return
|
||||
current = self.stack.currentIndex()
|
||||
if current != index and 0 <= current < len(self.pages):
|
||||
self.pages[current].stop_picking()
|
||||
self.chooser.setCurrentIndex(index)
|
||||
self.stack.setCurrentIndex(index)
|
||||
|
||||
def page_for(self, algorithm: str) -> Optional[int]:
|
||||
for index, page_class in enumerate(PAGES):
|
||||
if page_class.ALGORITHM == algorithm:
|
||||
return index
|
||||
return None
|
||||
|
||||
def shutdown(self) -> None:
|
||||
for page in self.pages:
|
||||
page.shutdown()
|
||||
Reference in new issue
Block a user