43 als "vernachlässigbar" eingestufte Funktionen (dialog_wrapper.py, message_wrapper.py, os_wrapper.py, qgisui_wrapper.py, qt_wrapper.py, DataGrabber.py, LayerLoader.py, Pruefmanager.py, navigation.py, print_tab.py) tragen jetzt den Vermerk "von Test abgesehen, weil vernachlässigbar; HD 18.09.2026". Fehlalarme der Testkatalog-Heuristik (Dateipruefer._ist_leer/_handle_leere_eingabe, linkpruefer.py komplett, Pruefmanager._handle_datei_existiert) und der als Bug erfasste tote Code (Pruefmanager._ask_use_or_replace_pufferlayer, #60) bleiben unangetastet. 41 Funktionen im zur Grundüberarbeitung anstehenden Print-Bereich (print_logic.py, print_layout.py, print_layout_baufreigabe.py) tragen den Vermerk "Test ausgesetzt, zunächst Refactor". Reine Dokumentationsänderung, kein Verhalten geändert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
128 lines
3.4 KiB
Python
128 lines
3.4 KiB
Python
"""
|
|
sn_basis/ui/navigation.py
|
|
|
|
Zentrale Navigation (Menü + Toolbar) für sn_basis.
|
|
"""
|
|
|
|
from typing import Any, List, Tuple
|
|
|
|
from sn_basis.functions.qt_wrapper import (
|
|
QAction,
|
|
QMenu,
|
|
QToolBar,
|
|
QActionGroup,
|
|
)
|
|
from sn_basis.functions import (
|
|
get_main_window,
|
|
add_toolbar,
|
|
remove_toolbar,
|
|
add_menu,
|
|
remove_menu,
|
|
)
|
|
|
|
|
|
class Navigation:
|
|
def __init__(self):
|
|
self.actions = []
|
|
self.menu = None
|
|
self.toolbar = None
|
|
self.plugin_group = None
|
|
|
|
|
|
|
|
def init_ui(self):
|
|
"""von Test abgesehen, weil vernachlässigbar; HD 18.09.2026"""
|
|
print(">>> Navigation.init_ui() CALLED")
|
|
|
|
main_window = get_main_window()
|
|
if not main_window:
|
|
return
|
|
# -----------------------------------------
|
|
# Vorherige Toolbars entfernen
|
|
# -----------------------------------------
|
|
for tb in main_window.findChildren(QToolBar):
|
|
if tb.objectName() == "LnoSachsenToolbar":
|
|
remove_toolbar(tb)
|
|
tb.deleteLater()
|
|
|
|
# -----------------------------------------
|
|
# Menü und Toolbar neu erzeugen
|
|
# -----------------------------------------
|
|
self.menu = QMenu("LNO Sachsen", main_window)
|
|
add_menu(self.menu)
|
|
|
|
self.toolbar = QToolBar("LNO Sachsen", main_window)
|
|
self.toolbar.setObjectName("LnoSachsenToolbar")
|
|
add_toolbar(self.toolbar)
|
|
|
|
test_action = QAction("TEST ACTION", main_window)
|
|
self.menu.addAction(test_action)
|
|
self.toolbar.addAction(test_action)
|
|
self.plugin_group = QActionGroup(main_window)
|
|
self.plugin_group.setExclusive(True)
|
|
|
|
|
|
# -----------------------------------------------------
|
|
# Actions
|
|
# -----------------------------------------------------
|
|
|
|
def add_action(self, text, callback, tooltip="", priority=100):
|
|
if not self.plugin_group:
|
|
return None
|
|
|
|
action = QAction(text, get_main_window())
|
|
action.setToolTip(tooltip)
|
|
action.setCheckable(True)
|
|
action.triggered.connect(callback)
|
|
|
|
self.plugin_group.addAction(action)
|
|
self.actions.append((priority, action))
|
|
return action
|
|
|
|
def finalize_menu_and_toolbar(self):
|
|
if not self.menu or not self.toolbar:
|
|
return
|
|
|
|
self.actions.sort(key=lambda x: x[0])
|
|
|
|
self.menu.clear()
|
|
self.toolbar.clear()
|
|
|
|
for _, action in self.actions:
|
|
self.menu.addAction(action)
|
|
self.toolbar.addAction(action)
|
|
|
|
def set_active_plugin(self, active_action):
|
|
for _, action in self.actions:
|
|
action.setChecked(False)
|
|
if active_action:
|
|
active_action.setChecked(True)
|
|
|
|
# -----------------------------------------------------
|
|
# Cleanup
|
|
# -----------------------------------------------------
|
|
|
|
def remove_action(self, action):
|
|
if not action:
|
|
return
|
|
|
|
if self.menu:
|
|
self.menu.removeAction(action)
|
|
if self.toolbar:
|
|
self.toolbar.removeAction(action)
|
|
|
|
self.actions = [(p, a) for p, a in self.actions if a != action]
|
|
|
|
def remove_all(self):
|
|
if self.menu:
|
|
remove_menu(self.menu)
|
|
self.menu = None
|
|
|
|
if self.toolbar:
|
|
remove_toolbar(self.toolbar)
|
|
self.toolbar = None
|
|
|
|
self.actions.clear()
|
|
self.plugin_group = None
|
|
|