Laden der Project.yaml aus dem Projekt-Verzeichnis

This commit is contained in:
2025-06-22 14:47:17 +02:00
parent 51e3453f92
commit b8441d1ab4
4 changed files with 72 additions and 15 deletions
+35 -14
View File
@@ -10,7 +10,7 @@ from PySide6.QtPdf import QPdfDocument
from ui.MainWinddow_ui import Ui_MainWindow
from ui.AppSettings import AppSettingsDlg
from ui.PdfProject import PdfProjectDlg
from conf import app_settings, PdfProject
from conf import app_settings, PdfProject, PdfProjectSettings
from pathlib import Path
@@ -139,15 +139,31 @@ class MainWindow(QMainWindow):
print(f"Öffne Projekt: {project.name}")
print(f"Projekt-Ordner: {project.project_dir}")
# Hier könnte die Logik zum Laden des Projekts implementiert werden
# Zum Beispiel:
# - PDF-Dateien aus dem Projekt-Ordner laden
# - Projekt-spezifische Einstellungen anwenden
# - UI entsprechend aktualisieren
# Für jetzt nur eine Meldung ausgeben
print(f"Projekt '{project.name}' wurde ausgewählt")
# TODO: Implementiere Projekt-Lade-Logik
try:
# Prüfe ob project.yaml existiert und nicht leer ist
project_yaml_path = Path(project.project_dir) / 'project.yaml'
if project_yaml_path.exists() and project_yaml_path.stat().st_size > 0:
# Versuche die Projekt-Einstellungen zu laden
self.pdf_project = PdfProjectSettings.readSettings(project_dir=project.project_dir)
print(f"Projekt-Einstellungen aus {project_yaml_path} geladen!")
else:
# Erstelle Standard-Projekt-Einstellungen wenn Datei leer oder nicht vorhanden
print("project.yaml ist leer oder nicht vorhanden, erstelle Standard-Einstellungen")
self.pdf_project = PdfProjectSettings()
# Speichere die Standard-Einstellungen in die project.yaml
self.pdf_project.writeSettings(project_dir=project.project_dir)
print(f"Standard-Projekt-Einstellungen in {project_yaml_path} gespeichert")
except Exception as e:
print(f"Fehler beim Laden des Projekts '{project.name}': {e}")
# Fallback: Erstelle Standard-Einstellungen
try:
self.pdf_project = PdfProjectSettings()
print("Fallback: Standard-Projekt-Einstellungen erstellt")
except Exception as fallback_error:
print(f"Fehler beim Erstellen der Fallback-Einstellungen: {fallback_error}")
def change_theme(self, theme_name):
"""
@@ -605,11 +621,16 @@ class MainWindow(QMainWindow):
project_yaml_path = project_dir / 'project.yaml'
# Projekt-Datei erstellen, wenn nicht vorhanden
# Erstelle Standard-Projekt-Einstellungen und speichere sie
if not project_yaml_path.exists():
project_yaml_path.touch()
print(f"project.yaml erstellt: {project_yaml_path}")
# Erstelle Standard-PdfProjectSettings
default_settings = PdfProjectSettings()
# Speichere die Standard-Einstellungen in die project.yaml
default_settings.writeSettings(project_dir=project_dir)
print(f"project.yaml mit Standard-Einstellungen erstellt: {project_yaml_path}")
else:
print(f"project.yaml existiert bereits: {project_yaml_path}")
except Exception as e:
print(f"Fehler beim Erstellen der Projekt-Struktur: {e}")