forked from AG_QGIS/Plugin_SN_Basis
Refactoring Aufgrund Fehler beim Beenden.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
def classFactory(iface):
|
def classFactory(iface):
|
||||||
from .main import lnoSachsenBasis
|
from .main import BasisPlugin
|
||||||
return lnoSachsenBasis(iface)
|
return BasisPlugin(iface)
|
||||||
|
|||||||
0
logic/__init__.py
Normal file
0
logic/__init__.py
Normal file
40
logic/settings_logic.py
Normal file
40
logic/settings_logic.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from qgis.core import QgsProject, QgsExpressionContextUtils
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsLogic:
|
||||||
|
def __init__(self):
|
||||||
|
self.project = QgsProject.instance()
|
||||||
|
|
||||||
|
def save(self, fields: dict):
|
||||||
|
"""Speichert Felder als globale und projektbezogene Ausdrucksvariablen."""
|
||||||
|
|
||||||
|
# 🟦 Globale Ausdrucksvariablen (nutzerspezifisch, Sitzungsspeicher)
|
||||||
|
QgsExpressionContextUtils.setGlobalVariable("sn_amt", fields["amt"])
|
||||||
|
QgsExpressionContextUtils.setGlobalVariable("sn_behoerde", fields["behoerde"])
|
||||||
|
QgsExpressionContextUtils.setGlobalVariable("sn_landkreis_user", fields["landkreis_user"])
|
||||||
|
QgsExpressionContextUtils.setGlobalVariable("sn_sachgebiet", fields["sachgebiet"])
|
||||||
|
|
||||||
|
# 🟨 Projektvariablen (sichtbar in Projekt → Eigenschaften → Variablen)
|
||||||
|
QgsExpressionContextUtils.setProjectVariable(self.project, "sn_bezeichnung", fields["bezeichnung"])
|
||||||
|
QgsExpressionContextUtils.setProjectVariable(self.project, "sn_verfahrensnummer", fields["verfahrensnummer"])
|
||||||
|
QgsExpressionContextUtils.setProjectVariable(self.project, "sn_gemeinden", fields["gemeinden"])
|
||||||
|
QgsExpressionContextUtils.setProjectVariable(self.project, "sn_landkreise_proj", fields["landkreise_proj"])
|
||||||
|
|
||||||
|
print("✅ Ausdrucksvariablen gespeichert.")
|
||||||
|
|
||||||
|
def load(self) -> dict:
|
||||||
|
"""Lädt Werte ausschließlich aus Ausdrucksvariablen (global + projektbezogen)."""
|
||||||
|
|
||||||
|
return {
|
||||||
|
# Globale Variablen (nutzerspezifisch)
|
||||||
|
"amt": QgsExpressionContextUtils.globalScope().variable("sn_amt") or "",
|
||||||
|
"behoerde": QgsExpressionContextUtils.globalScope().variable("sn_behoerde") or "",
|
||||||
|
"landkreis_user": QgsExpressionContextUtils.globalScope().variable("sn_landkreis_user") or "",
|
||||||
|
"sachgebiet": QgsExpressionContextUtils.globalScope().variable("sn_sachgebiet") or "",
|
||||||
|
|
||||||
|
# Projektvariablen
|
||||||
|
"bezeichnung": QgsExpressionContextUtils.projectScope(self.project).variable("sn_bezeichnung") or "",
|
||||||
|
"verfahrensnummer": QgsExpressionContextUtils.projectScope(self.project).variable("sn_verfahrensnummer") or "",
|
||||||
|
"gemeinden": QgsExpressionContextUtils.projectScope(self.project).variable("sn_gemeinden") or "",
|
||||||
|
"landkreise_proj": QgsExpressionContextUtils.projectScope(self.project).variable("sn_landkreise_proj") or ""
|
||||||
|
}
|
||||||
29
main.py
29
main.py
@@ -1,22 +1,21 @@
|
|||||||
import os
|
from qgis.PyQt.QtCore import QCoreApplication
|
||||||
|
from qgis.PyQt.QtGui import QIcon
|
||||||
class lnoSachsenBasis:
|
from sn_basis.ui.navigation import Navigation
|
||||||
"""
|
from sn_basis.ui.dockmanager import DockManager
|
||||||
Plugin-Klasse für Basisfunktionen. Stellt Funktionen und Klassen für andere Plugins bereit.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
class BasisPlugin:
|
||||||
def __init__(self, iface):
|
def __init__(self, iface):
|
||||||
self.iface = iface
|
self.iface = iface
|
||||||
self.plugin_dir = os.path.dirname(__file__)
|
self.ui = None
|
||||||
|
self.quitting = False
|
||||||
|
QCoreApplication.instance().aboutToQuit.connect(self._on_quit)
|
||||||
|
|
||||||
|
def _on_quit(self):
|
||||||
|
self.quitting = True
|
||||||
|
|
||||||
def initGui(self):
|
def initGui(self):
|
||||||
"""
|
self.ui = Navigation(self.iface)
|
||||||
Keine GUI-Integration nötig.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def unload(self):
|
def unload(self):
|
||||||
"""
|
if not self.quitting and self.ui:
|
||||||
Keine GUI-Elemente zu entfernen.
|
self.ui.remove_all()
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|||||||
24
metadata.txt
24
metadata.txt
@@ -1,23 +1,13 @@
|
|||||||
[general]
|
[general]
|
||||||
name=LNO Sachsen | Basisfunktionen
|
name=LNO Sachsen | Basisfunktionen
|
||||||
qgisMinimumVersion=3.0
|
qgisMinimumVersion=3.0
|
||||||
description=Dieses Plugin ist ein Test
|
description=Plugin mit Basisfunktionen
|
||||||
version=25.10.3
|
version=25.11.1
|
||||||
author=Michael Otto
|
author=Michael Otto
|
||||||
email=michael.otto@landkreis-mittelsachsen.de
|
email=michael.otto@landkreis-mittelsachsen.de
|
||||||
|
about=Plugin mit Basisfunktionen
|
||||||
about=Provide a brief description of the plugin and its purpose.
|
|
||||||
|
|
||||||
supportsQt6=True
|
|
||||||
|
|
||||||
hasProcessingProvider=no
|
|
||||||
tags=python
|
|
||||||
|
|
||||||
category=Plugins
|
category=Plugins
|
||||||
icon=icon.png
|
homepage=https://entwicklung.vln-sn.de/AG_QGIS/Plugin_SN_Basis
|
||||||
experimental=True
|
repository=https://entwicklung.vln-sn.de/AG_QGIS/Repository
|
||||||
|
supportsQt6=true
|
||||||
deprecated=False
|
experimental=true
|
||||||
|
|
||||||
server=False
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from .tab_projekt import TabProjektWidget
|
|
||||||
from .dockmanager import DockManager
|
|
||||||
from .navigation import Navigation
|
|
||||||
@@ -1,67 +1,21 @@
|
|||||||
from qgis.PyQt.QtCore import Qt
|
from qgis.PyQt.QtCore import Qt
|
||||||
from qgis.PyQt.QtWidgets import QDockWidget
|
from qgis.PyQt.QtWidgets import QDockWidget
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import inspect
|
|
||||||
|
|
||||||
class DockManager:
|
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 #Qt6
|
|
||||||
default_area = Qt.DockWidgetArea.RightDockWidgetArea
|
default_area = Qt.DockWidgetArea.RightDockWidgetArea
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def show(cls, dock_widget, area=None):
|
def show(cls, dock_widget, area=None):
|
||||||
# Falls kein Bereich übergeben wurde, verwende den Standardwert
|
|
||||||
if area is None:
|
if area is None:
|
||||||
area = cls.default_area
|
area = cls.default_area
|
||||||
|
|
||||||
# Pluginname automatisch aus dem Modulpfad ableiten (z. B. 'sn_plugin1' → 'plugin1')
|
# Alle vorhandenen Plugin-Docks schließen
|
||||||
caller_module = inspect.getmodule(inspect.stack()[1][0])
|
for widget in iface.mainWindow().findChildren(QDockWidget):
|
||||||
full_module_name = caller_module.__name__ # z. B. 'sn_plugin1.main'
|
if widget != dock_widget and widget.objectName().startswith("sn_dock_"):
|
||||||
plugin_name = full_module_name.split('.')[0] # → 'sn_plugin1'
|
iface.removeDockWidget(widget)
|
||||||
dock_name = f"sn_dock_{plugin_name.replace('sn_', '')}" # → 'sn_dock_plugin1'
|
widget.deleteLater()
|
||||||
|
|
||||||
# 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) #Qt6
|
|
||||||
dock_widget.setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea)
|
|
||||||
|
|
||||||
# Dock-Features setzen: schließbar und verschiebbar
|
|
||||||
#dock_widget.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetMovable) #Qt6
|
|
||||||
dock_widget.setFeatures(
|
|
||||||
QDockWidget.DockWidgetFeature.DockWidgetClosable |
|
|
||||||
QDockWidget.DockWidgetFeature.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)
|
|
||||||
|
|
||||||
# Neues Dock anzeigen
|
# Neues Dock anzeigen
|
||||||
iface.addDockWidget(area, dock_widget)
|
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()
|
dock_widget.show()
|
||||||
|
|||||||
@@ -1,75 +1,37 @@
|
|||||||
from qgis.PyQt.QtWidgets import QMenu, QToolBar, QAction
|
from qgis.PyQt.QtWidgets import QAction, QMenu, QToolBar
|
||||||
from qgis.PyQt.QtGui import QIcon
|
|
||||||
from qgis.utils import iface
|
|
||||||
|
|
||||||
_shared_toolbar = None # globale Toolbar-Instanz
|
|
||||||
_shared_menu = None # globale Menü-Instanz
|
|
||||||
|
|
||||||
class Navigation:
|
class Navigation:
|
||||||
TITLE = "LNO Sachsen"
|
def __init__(self, iface):
|
||||||
|
self.iface = iface
|
||||||
|
self.actions = []
|
||||||
|
|
||||||
def __init__(self):
|
# Menü und Toolbar einmalig anlegen
|
||||||
self.menu = self._get_or_create_menu()
|
self.menu = QMenu("LNO Sachsen", iface.mainWindow())
|
||||||
self.toolbar = self._get_or_create_toolbar()
|
iface.mainWindow().menuBar().addMenu(self.menu)
|
||||||
|
|
||||||
def _get_or_create_menu(self):
|
self.toolbar = QToolBar("LNO Sachsen")
|
||||||
global _shared_menu
|
iface.addToolBar(self.toolbar)
|
||||||
if _shared_menu:
|
|
||||||
return _shared_menu
|
|
||||||
|
|
||||||
menubar = iface.mainWindow().menuBar()
|
def add_action(self, text, callback, tooltip="", priority=100, icon=None):
|
||||||
for action in menubar.actions():
|
action = QAction(icon, text, self.iface.mainWindow()) if icon else QAction(text, self.iface.mainWindow())
|
||||||
if action.menu() and action.text() == self.TITLE:
|
if tooltip:
|
||||||
_shared_menu = action.menu()
|
action.setToolTip(tooltip)
|
||||||
return _shared_menu
|
action.triggered.connect(callback)
|
||||||
|
|
||||||
menu = QMenu(self.TITLE, iface.mainWindow())
|
# Action mit Priority speichern
|
||||||
menu.setObjectName(self.TITLE)
|
self.actions.append((priority, action))
|
||||||
menubar.addMenu(menu)
|
return action
|
||||||
_shared_menu = menu
|
|
||||||
return menu
|
|
||||||
|
|
||||||
def _get_or_create_toolbar(self):
|
def finalize_menu_and_toolbar(self):
|
||||||
global _shared_toolbar
|
# Sortieren nach Priority
|
||||||
if _shared_toolbar:
|
self.actions.sort(key=lambda x: x[0])
|
||||||
return _shared_toolbar
|
|
||||||
|
|
||||||
main_window = iface.mainWindow()
|
# Menüeinträge
|
||||||
toolbar = main_window.findChild(QToolBar, self.TITLE)
|
self.menu.clear()
|
||||||
if not toolbar:
|
for _, action in self.actions:
|
||||||
toolbar = QToolBar(self.TITLE, main_window)
|
|
||||||
toolbar.setObjectName(self.TITLE)
|
|
||||||
main_window.addToolBar(toolbar)
|
|
||||||
|
|
||||||
_shared_toolbar = toolbar
|
|
||||||
return toolbar
|
|
||||||
|
|
||||||
def add_action(self, text, callback, icon=None, tooltip=None):
|
|
||||||
# Menüeintrag
|
|
||||||
if not any(a.text() == text for a in self.menu.actions()):
|
|
||||||
action = QAction(icon, text, iface.mainWindow()) if icon else QAction(text, iface.mainWindow())
|
|
||||||
if tooltip:
|
|
||||||
action.setToolTip(tooltip)
|
|
||||||
action.triggered.connect(callback)
|
|
||||||
self.menu.addAction(action)
|
self.menu.addAction(action)
|
||||||
|
|
||||||
# Symbolleistenaktion
|
# Toolbar-Einträge
|
||||||
if not any(a.text() == text for a in self.toolbar.actions()):
|
self.toolbar.clear()
|
||||||
action = QAction(icon, text, iface.mainWindow()) if icon else QAction(text, iface.mainWindow())
|
for _, action in self.actions:
|
||||||
if tooltip:
|
|
||||||
action.setToolTip(tooltip)
|
|
||||||
action.triggered.connect(callback)
|
|
||||||
self.toolbar.addAction(action)
|
self.toolbar.addAction(action)
|
||||||
|
|
||||||
def remove_action(self, text):
|
|
||||||
# Menüeintrag entfernen
|
|
||||||
for act in self.menu.actions():
|
|
||||||
if act.text() == text:
|
|
||||||
self.menu.removeAction(act)
|
|
||||||
break
|
|
||||||
|
|
||||||
# Symbolleistenaktion entfernen
|
|
||||||
for act in self.toolbar.actions():
|
|
||||||
if act.text() == text:
|
|
||||||
self.toolbar.removeAction(act)
|
|
||||||
break
|
|
||||||
|
|||||||
@@ -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
84
ui/tabs/settings_tab.py
Normal file
84
ui/tabs/settings_tab.py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
from qgis.PyQt.QtWidgets import (
|
||||||
|
QWidget, QGridLayout, QLabel, QLineEdit,
|
||||||
|
QGroupBox, QVBoxLayout, QPushButton
|
||||||
|
)
|
||||||
|
from sn_basis.logic.settings_logic import SettingsLogic
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsTab(QWidget):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.logic = SettingsLogic()
|
||||||
|
|
||||||
|
main_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# 🟦 Benutzerspezifische Festlegungen
|
||||||
|
user_group = QGroupBox("Benutzerspezifische Festlegungen")
|
||||||
|
user_layout = QGridLayout()
|
||||||
|
self.amt = QLineEdit()
|
||||||
|
self.behoerde = QLineEdit()
|
||||||
|
self.landkreis_user = QLineEdit()
|
||||||
|
self.sachgebiet = QLineEdit()
|
||||||
|
user_layout.addWidget(QLabel("Amt:"), 0, 0)
|
||||||
|
user_layout.addWidget(self.amt, 0, 1)
|
||||||
|
user_layout.addWidget(QLabel("Behörde:"), 1, 0)
|
||||||
|
user_layout.addWidget(self.behoerde, 1, 1)
|
||||||
|
user_layout.addWidget(QLabel("Landkreis:"), 2, 0)
|
||||||
|
user_layout.addWidget(self.landkreis_user, 2, 1)
|
||||||
|
user_layout.addWidget(QLabel("Sachgebiet:"), 3, 0)
|
||||||
|
user_layout.addWidget(self.sachgebiet, 3, 1)
|
||||||
|
user_group.setLayout(user_layout)
|
||||||
|
|
||||||
|
# 🟨 Projektspezifische Festlegungen
|
||||||
|
project_group = QGroupBox("Projektspezifische Festlegungen")
|
||||||
|
project_layout = QGridLayout()
|
||||||
|
self.bezeichnung = QLineEdit()
|
||||||
|
self.verfahrensnummer = QLineEdit()
|
||||||
|
self.gemeinden = QLineEdit()
|
||||||
|
self.landkreise_proj = QLineEdit()
|
||||||
|
project_layout.addWidget(QLabel("Bezeichnung:"), 0, 0)
|
||||||
|
project_layout.addWidget(self.bezeichnung, 0, 1)
|
||||||
|
project_layout.addWidget(QLabel("Verfahrensnummer:"), 1, 0)
|
||||||
|
project_layout.addWidget(self.verfahrensnummer, 1, 1)
|
||||||
|
project_layout.addWidget(QLabel("Gemeinde(n):"), 2, 0)
|
||||||
|
project_layout.addWidget(self.gemeinden, 2, 1)
|
||||||
|
project_layout.addWidget(QLabel("Landkreis(e):"), 3, 0)
|
||||||
|
project_layout.addWidget(self.landkreise_proj, 3, 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):
|
||||||
|
fields = {
|
||||||
|
"amt": self.amt.text(),
|
||||||
|
"behoerde": self.behoerde.text(),
|
||||||
|
"landkreis_user": self.landkreis_user.text(),
|
||||||
|
"sachgebiet": self.sachgebiet.text(),
|
||||||
|
"bezeichnung": self.bezeichnung.text(),
|
||||||
|
"verfahrensnummer": self.verfahrensnummer.text(),
|
||||||
|
"gemeinden": self.gemeinden.text(),
|
||||||
|
"landkreise_proj": self.landkreise_proj.text()
|
||||||
|
}
|
||||||
|
self.logic.save(fields)
|
||||||
|
|
||||||
|
def load_data(self):
|
||||||
|
data = self.logic.load()
|
||||||
|
self.amt.setText(data["amt"])
|
||||||
|
self.behoerde.setText(data["behoerde"])
|
||||||
|
self.landkreis_user.setText(data["landkreis_user"])
|
||||||
|
self.sachgebiet.setText(data["sachgebiet"])
|
||||||
|
self.bezeichnung.setText(data["bezeichnung"])
|
||||||
|
self.verfahrensnummer.setText(data["verfahrensnummer"])
|
||||||
|
self.gemeinden.setText(data["gemeinden"])
|
||||||
|
self.landkreise_proj.setText(data["landkreise_proj"])
|
||||||
Reference in New Issue
Block a user