Compare commits
8 Commits
4fc82bea71
...
25.11.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ad36c812f | ||
|
|
7f62696b51 | ||
|
|
617ee30650 | ||
|
|
f305eaeff8 | ||
|
|
a302ce2228 | ||
|
|
c36dc8cae9 | ||
| d60dbd13a5 | |||
|
|
dcb298cb4a |
@@ -1,3 +1,5 @@
|
||||
from .logic.variable_utils import get_variable
|
||||
|
||||
def classFactory(iface):
|
||||
from .main import lnoSachsenBasis
|
||||
return lnoSachsenBasis(iface)
|
||||
from .main import BasisPlugin
|
||||
return BasisPlugin(iface)
|
||||
|
||||
0
logic/__init__.py
Normal file
0
logic/__init__.py
Normal file
37
logic/settings_logic.py
Normal file
37
logic/settings_logic.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from qgis.core import QgsProject, QgsExpressionContextUtils
|
||||
|
||||
class SettingsLogic:
|
||||
def __init__(self):
|
||||
self.project = QgsProject.instance()
|
||||
|
||||
# Definition der Variablen-Namen
|
||||
self.global_vars = ["amt", "behoerde", "landkreis_user", "sachgebiet"]
|
||||
self.project_vars = ["bezeichnung", "verfahrensnummer", "gemeinden", "landkreise_proj"]
|
||||
|
||||
def save(self, fields: dict):
|
||||
"""Speichert Felder als globale und projektbezogene Ausdrucksvariablen."""
|
||||
|
||||
# Globale Variablen
|
||||
for key in self.global_vars:
|
||||
QgsExpressionContextUtils.setGlobalVariable(f"sn_{key}", fields.get(key, ""))
|
||||
|
||||
# Projektvariablen
|
||||
for key in self.project_vars:
|
||||
QgsExpressionContextUtils.setProjectVariable(self.project, f"sn_{key}", fields.get(key, ""))
|
||||
|
||||
print("✅ Ausdrucksvariablen gespeichert.")
|
||||
|
||||
def load(self) -> dict:
|
||||
"""Lädt Werte ausschließlich aus Ausdrucksvariablen (global + projektbezogen)."""
|
||||
|
||||
data = {}
|
||||
|
||||
# Globale Variablen
|
||||
for key in self.global_vars:
|
||||
data[key] = QgsExpressionContextUtils.globalScope().variable(f"sn_{key}") or ""
|
||||
|
||||
# Projektvariablen
|
||||
for key in self.project_vars:
|
||||
data[key] = QgsExpressionContextUtils.projectScope(self.project).variable(f"sn_{key}") or ""
|
||||
|
||||
return data
|
||||
35
logic/variable_utils.py
Normal file
35
logic/variable_utils.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from qgis.core import QgsProject, QgsExpressionContextUtils
|
||||
|
||||
def get_variable(key: str, scope: str = "project") -> str:
|
||||
"""
|
||||
Liefert den Wert einer sn_* Variable zurück.
|
||||
key: Name ohne Präfix, z.B. "verfahrensnummer"
|
||||
scope: 'project' oder 'global'
|
||||
"""
|
||||
projekt = QgsProject.instance()
|
||||
var_name = f"sn_{key}"
|
||||
|
||||
if scope == "project":
|
||||
return QgsExpressionContextUtils.projectScope(projekt).variable(var_name) or ""
|
||||
elif scope == "global":
|
||||
return QgsExpressionContextUtils.globalScope().variable(var_name) or ""
|
||||
else:
|
||||
raise ValueError("Scope muss 'project' oder 'global' sein.")
|
||||
|
||||
|
||||
def set_variable(key: str, value: str, scope: str = "project"):
|
||||
"""
|
||||
Schreibt den Wert einer sn_* Variable.
|
||||
key: Name ohne Präfix, z.B. "verfahrensnummer"
|
||||
value: Wert, der gespeichert werden soll
|
||||
scope: 'project' oder 'global'
|
||||
"""
|
||||
projekt = QgsProject.instance()
|
||||
var_name = f"sn_{key}"
|
||||
|
||||
if scope == "project":
|
||||
QgsExpressionContextUtils.setProjectVariable(projekt, var_name, value)
|
||||
elif scope == "global":
|
||||
QgsExpressionContextUtils.setGlobalVariable(var_name, value)
|
||||
else:
|
||||
raise ValueError("Scope muss 'project' oder 'global' sein.")
|
||||
34
main.py
34
main.py
@@ -1,22 +1,26 @@
|
||||
import os
|
||||
|
||||
class lnoSachsenBasis:
|
||||
"""
|
||||
Plugin-Klasse für Basisfunktionen. Stellt Funktionen und Klassen für andere Plugins bereit.
|
||||
"""
|
||||
from qgis.PyQt.QtCore import QCoreApplication
|
||||
from qgis.utils import plugins
|
||||
from sn_basis.ui.navigation import Navigation
|
||||
|
||||
class BasisPlugin:
|
||||
def __init__(self, iface):
|
||||
self.iface = iface
|
||||
self.plugin_dir = os.path.dirname(__file__)
|
||||
self.ui = None
|
||||
QCoreApplication.instance().aboutToQuit.connect(self.unload)
|
||||
|
||||
def initGui(self):
|
||||
"""
|
||||
Keine GUI-Integration nötig.
|
||||
"""
|
||||
pass
|
||||
# Basis-Navigation neu aufbauen
|
||||
self.ui = Navigation(self.iface)
|
||||
|
||||
# Alle Fachplugins mit "sn_" prüfen und neu initialisieren
|
||||
for name, plugin in plugins.items():
|
||||
if name.startswith("sn_") and name != "sn_basis":
|
||||
try:
|
||||
plugin.initGui()
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Neuinitialisieren von {name}: {e}")
|
||||
|
||||
def unload(self):
|
||||
"""
|
||||
Keine GUI-Elemente zu entfernen.
|
||||
"""
|
||||
pass
|
||||
if self.ui:
|
||||
self.ui.remove_all()
|
||||
self.ui = None
|
||||
|
||||
22
metadata.txt
22
metadata.txt
@@ -1,21 +1,13 @@
|
||||
[general]
|
||||
name=LNO Sachsen | Basisfunktionen
|
||||
qgisMinimumVersion=3.0
|
||||
description=Dieses Plugin ist ein Test
|
||||
version=25.10.3
|
||||
description=Plugin mit Basisfunktionen
|
||||
version=25.11.3
|
||||
author=Michael Otto
|
||||
email=michael.otto@landkreis-mittelsachsen.de
|
||||
|
||||
about=Provide a brief description of the plugin and its purpose.
|
||||
|
||||
hasProcessingProvider=no
|
||||
tags=python
|
||||
|
||||
about=Plugin mit Basisfunktionen
|
||||
category=Plugins
|
||||
icon=icon.png
|
||||
experimental=True
|
||||
|
||||
deprecated=False
|
||||
|
||||
server=False
|
||||
|
||||
homepage=https://entwicklung.vln-sn.de/AG_QGIS/Plugin_SN_Basis
|
||||
repository=https://entwicklung.vln-sn.de/AG_QGIS/Repository
|
||||
supportsQt6=true
|
||||
experimental=true
|
||||
@@ -1,2 +0,0 @@
|
||||
from .tab_projekt import TabProjektWidget
|
||||
from .dockmanager import DockManager
|
||||
28
ui/base_dockwidget.py
Normal file
28
ui/base_dockwidget.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from qgis.PyQt.QtWidgets import QDockWidget, QTabWidget
|
||||
|
||||
class BaseDockWidget(QDockWidget):
|
||||
base_title = "LNO Sachsen"
|
||||
tabs = []
|
||||
action = None # Referenz auf die Toolbar-Action
|
||||
|
||||
def __init__(self, parent=None, subtitle=""):
|
||||
super().__init__(parent)
|
||||
|
||||
# Titel zusammensetzen
|
||||
title = self.base_title if not subtitle else f"{self.base_title} | {subtitle}"
|
||||
self.setWindowTitle(title)
|
||||
|
||||
# Dock fixieren (nur schließen erlaubt)
|
||||
self.setFeatures(QDockWidget.DockWidgetFeature.DockWidgetClosable)
|
||||
|
||||
# Tabs hinzufügen
|
||||
tab_widget = QTabWidget()
|
||||
for tab_class in self.tabs:
|
||||
tab_widget.addTab(tab_class(), getattr(tab_class, "tab_title", tab_class.__name__))
|
||||
self.setWidget(tab_widget)
|
||||
|
||||
def closeEvent(self, event):
|
||||
"""Wird aufgerufen, wenn das Dock geschlossen wird."""
|
||||
if self.action:
|
||||
self.action.setChecked(False) # Toolbar-Button zurücksetzen
|
||||
super().closeEvent(event)
|
||||
@@ -1,60 +1,21 @@
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QDockWidget
|
||||
from qgis.utils import iface
|
||||
import inspect
|
||||
|
||||
|
||||
class DockManager:
|
||||
"""
|
||||
Zeigt ein Dockwidget an und schließt alle anderen mit dem Namensschema 'sn_dock_'.
|
||||
Der Dockname wird automatisch aus dem Pluginmodul abgeleitet.
|
||||
"""
|
||||
|
||||
# Standard-Dockbereich: Rechts (wie die Verarbeitungswerkzeuge)
|
||||
default_area = Qt.RightDockWidgetArea
|
||||
default_area = Qt.DockWidgetArea.RightDockWidgetArea
|
||||
|
||||
@classmethod
|
||||
def show(cls, dock_widget, area=None):
|
||||
# Falls kein Bereich übergeben wurde, verwende den Standardwert
|
||||
if area is None:
|
||||
area = cls.default_area
|
||||
area = area or cls.default_area
|
||||
|
||||
# Pluginname automatisch aus dem Modulpfad ableiten (z. B. 'sn_plugin1' → 'plugin1')
|
||||
caller_module = inspect.getmodule(inspect.stack()[1][0])
|
||||
full_module_name = caller_module.__name__ # z. B. 'sn_plugin1.main'
|
||||
plugin_name = full_module_name.split('.')[0] # → 'sn_plugin1'
|
||||
dock_name = f"sn_dock_{plugin_name.replace('sn_', '')}" # → 'sn_dock_plugin1'
|
||||
|
||||
# Objektname für das Dock setzen, damit es eindeutig identifizierbar ist
|
||||
dock_widget.setObjectName(dock_name)
|
||||
|
||||
# Nur rechts andocken erlauben, wie bei der Toolbox
|
||||
dock_widget.setAllowedAreas(Qt.RightDockWidgetArea)
|
||||
|
||||
# Dock-Features setzen: schließbar und verschiebbar
|
||||
dock_widget.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetMovable)
|
||||
|
||||
# Alle vorhandenen Dockwidgets im Hauptfenster durchsuchen
|
||||
# und solche mit dem Namensschema 'sn_dock_' schließen – außer dem aktuellen
|
||||
all_docks = iface.mainWindow().findChildren(QDockWidget)
|
||||
for widget in all_docks:
|
||||
if widget.objectName().startswith("sn_dock_") and widget != dock_widget:
|
||||
try:
|
||||
iface.removeDockWidget(widget)
|
||||
widget.close()
|
||||
except Exception:
|
||||
pass # Fehler beim Schließen ignorieren (z. B. falls bereits entfernt)
|
||||
# Bestehende Plugin-Docks mit Präfix schließen
|
||||
for widget in iface.mainWindow().findChildren(QDockWidget):
|
||||
if widget is not dock_widget and widget.objectName().startswith("sn_dock_"):
|
||||
iface.removeDockWidget(widget)
|
||||
widget.deleteLater()
|
||||
|
||||
# Neues Dock anzeigen
|
||||
iface.addDockWidget(area, dock_widget)
|
||||
|
||||
# Tabifizierung verhindern – andere Docks im selben Bereich entfernen
|
||||
for widget in iface.mainWindow().findChildren(QDockWidget):
|
||||
if widget != dock_widget and iface.mainWindow().dockWidgetArea(widget) == area:
|
||||
iface.mainWindow().removeDockWidget(widget)
|
||||
|
||||
# Breite setzen wie bei der Toolbox (optional, anpassbar)
|
||||
dock_widget.setMinimumWidth(300)
|
||||
dock_widget.setMaximumWidth(400)
|
||||
|
||||
# Höhe nicht erzwingen – Qt passt sie automatisch an
|
||||
dock_widget.show()
|
||||
|
||||
83
ui/navigation.py
Normal file
83
ui/navigation.py
Normal file
@@ -0,0 +1,83 @@
|
||||
from qgis.PyQt.QtWidgets import QAction, QMenu, QToolBar, QActionGroup
|
||||
|
||||
class Navigation:
|
||||
def __init__(self, iface):
|
||||
self.iface = iface
|
||||
self.actions = []
|
||||
|
||||
# Menü und Toolbar einmalig anlegen
|
||||
self.menu = QMenu("LNO Sachsen", iface.mainWindow())
|
||||
iface.mainWindow().menuBar().addMenu(self.menu)
|
||||
|
||||
self.toolbar = QToolBar("LNO Sachsen")
|
||||
self.toolbar.setObjectName("LnoSachsenToolbar")
|
||||
iface.addToolBar(self.toolbar)
|
||||
|
||||
# Gruppe für exklusive Auswahl (nur ein Plugin aktiv)
|
||||
self.plugin_group = QActionGroup(iface.mainWindow())
|
||||
self.plugin_group.setExclusive(True)
|
||||
|
||||
def add_action(self, text, callback, tooltip="", priority=100):
|
||||
action = QAction(text, self.iface.mainWindow())
|
||||
action.setToolTip(tooltip)
|
||||
action.setCheckable(True) # Button kann aktiv sein
|
||||
action.triggered.connect(callback)
|
||||
|
||||
# Action in Gruppe aufnehmen
|
||||
self.plugin_group.addAction(action)
|
||||
|
||||
# Action mit Priority speichern
|
||||
self.actions.append((priority, action))
|
||||
return action
|
||||
|
||||
def finalize_menu_and_toolbar(self):
|
||||
# Sortieren nach Priority
|
||||
self.actions.sort(key=lambda x: x[0])
|
||||
|
||||
# Menüeinträge
|
||||
self.menu.clear()
|
||||
for _, action in self.actions:
|
||||
self.menu.addAction(action)
|
||||
|
||||
# Toolbar-Einträge
|
||||
self.toolbar.clear()
|
||||
for _, action in self.actions:
|
||||
self.toolbar.addAction(action)
|
||||
|
||||
def set_active_plugin(self, active_action):
|
||||
# Alle zurücksetzen, dann aktives Plugin markieren
|
||||
for _, action in self.actions:
|
||||
action.setChecked(False)
|
||||
if active_action:
|
||||
active_action.setChecked(True)
|
||||
|
||||
def remove_all(self):
|
||||
"""Alles entfernen beim Entladen des Basisplugins"""
|
||||
# Menü entfernen
|
||||
if self.menu:
|
||||
self.iface.mainWindow().menuBar().removeAction(self.menu.menuAction())
|
||||
self.menu = None
|
||||
|
||||
# Toolbar entfernen
|
||||
if self.toolbar:
|
||||
self.iface.mainWindow().removeToolBar(self.toolbar)
|
||||
self.toolbar = None
|
||||
|
||||
# Actions zurücksetzen
|
||||
self.actions.clear()
|
||||
|
||||
# Gruppe leeren
|
||||
self.plugin_group = None
|
||||
|
||||
def remove_action(self, action):
|
||||
"""Entfernt eine einzelne Action aus Menü und Toolbar"""
|
||||
if not action:
|
||||
return
|
||||
# Menüeintrag entfernen
|
||||
if self.menu:
|
||||
self.menu.removeAction(action)
|
||||
# Toolbar-Eintrag entfernen
|
||||
if self.toolbar:
|
||||
self.toolbar.removeAction(action)
|
||||
# Aus der internen Liste löschen
|
||||
self.actions = [(p, a) for p, a in self.actions if a != action]
|
||||
@@ -1,20 +0,0 @@
|
||||
# tab_info.py
|
||||
from qgis.PyQt import uic
|
||||
from qgis.PyQt.QtWidgets import QWidget
|
||||
import os
|
||||
|
||||
FORM_CLASS, _ = uic.loadUiType(os.path.join(
|
||||
os.path.dirname(__file__), 'tab_projekt.ui'))
|
||||
|
||||
class TabProjektWidget(QWidget, FORM_CLASS):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
# Zugriff auf den Button
|
||||
self.btn_save.setText("Sichern") # Text ändern
|
||||
self.btn_save.setEnabled(True) # Aktivieren
|
||||
self.btn_save.clicked.connect(self.speichern) # Klick-Event verbinden
|
||||
|
||||
def speichern(self):
|
||||
print("Speichern wurde geklickt!")
|
||||
@@ -1,264 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>604</width>
|
||||
<height>939</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Benutzerspezifische Festlegungen___</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Amt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_5"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Behörde</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_4"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Landkreis</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sachgebiet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Projektspezifische Festlegungen</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bezeichnung</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_8"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Verfahrensnummer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_7"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Gemeinde(n)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Landkreis(e)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_6"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_save">
|
||||
<property name="text">
|
||||
<string>Speichern</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
0
ui/tabs/__init__.py
Normal file
0
ui/tabs/__init__.py
Normal file
72
ui/tabs/settings_tab.py
Normal file
72
ui/tabs/settings_tab.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from qgis.PyQt.QtWidgets import (
|
||||
QWidget, QGridLayout, QLabel, QLineEdit,
|
||||
QGroupBox, QVBoxLayout, QPushButton
|
||||
)
|
||||
from sn_basis.logic.settings_logic import SettingsLogic
|
||||
|
||||
|
||||
class SettingsTab(QWidget):
|
||||
tab_title = "Projekteigenschaften" # Titel für den Tab
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.logic = SettingsLogic()
|
||||
|
||||
main_layout = QVBoxLayout()
|
||||
|
||||
# Definition der Felder
|
||||
self.user_fields = {
|
||||
"amt": "Amt:",
|
||||
"behoerde": "Behörde:",
|
||||
"landkreis_user": "Landkreis:",
|
||||
"sachgebiet": "Sachgebiet:"
|
||||
}
|
||||
self.project_fields = {
|
||||
"bezeichnung": "Bezeichnung:",
|
||||
"verfahrensnummer": "Verfahrensnummer:",
|
||||
"gemeinden": "Gemeinde(n):",
|
||||
"landkreise_proj": "Landkreis(e):"
|
||||
}
|
||||
|
||||
# 🟦 Benutzerspezifische Festlegungen
|
||||
user_group = QGroupBox("Benutzerspezifische Festlegungen")
|
||||
user_layout = QGridLayout()
|
||||
self.user_inputs = {}
|
||||
for row, (key, label) in enumerate(self.user_fields.items()):
|
||||
self.user_inputs[key] = QLineEdit()
|
||||
user_layout.addWidget(QLabel(label), row, 0)
|
||||
user_layout.addWidget(self.user_inputs[key], row, 1)
|
||||
user_group.setLayout(user_layout)
|
||||
|
||||
# 🟨 Projektspezifische Festlegungen
|
||||
project_group = QGroupBox("Projektspezifische Festlegungen")
|
||||
project_layout = QGridLayout()
|
||||
self.project_inputs = {}
|
||||
for row, (key, label) in enumerate(self.project_fields.items()):
|
||||
self.project_inputs[key] = QLineEdit()
|
||||
project_layout.addWidget(QLabel(label), row, 0)
|
||||
project_layout.addWidget(self.project_inputs[key], row, 1)
|
||||
project_group.setLayout(project_layout)
|
||||
|
||||
# 🟩 Speichern-Button
|
||||
save_button = QPushButton("Speichern")
|
||||
save_button.clicked.connect(self.save_data)
|
||||
|
||||
# Layout zusammenfügen
|
||||
main_layout.addWidget(user_group)
|
||||
main_layout.addWidget(project_group)
|
||||
main_layout.addStretch()
|
||||
main_layout.addWidget(save_button)
|
||||
|
||||
self.setLayout(main_layout)
|
||||
self.load_data()
|
||||
|
||||
def save_data(self):
|
||||
# Alle Felder zusammenführen
|
||||
fields = {key: widget.text() for key, widget in {**self.user_inputs, **self.project_inputs}.items()}
|
||||
self.logic.save(fields)
|
||||
|
||||
def load_data(self):
|
||||
data = self.logic.load()
|
||||
for key, widget in {**self.user_inputs, **self.project_inputs}.items():
|
||||
widget.setText(data.get(key, ""))
|
||||
Reference in New Issue
Block a user