2025-12-19 14:29:52 +01:00
|
|
|
|
"""
|
2026-03-04 15:32:49 +01:00
|
|
|
|
sn_basis/functions/dialog_wrapper.py – Benutzer-Dialoge (Qt5/6/Mock-kompatibel)
|
2025-12-19 14:29:52 +01:00
|
|
|
|
"""
|
|
|
|
|
|
from typing import Any
|
|
|
|
|
|
from sn_basis.functions.qt_wrapper import (
|
2026-03-04 15:32:49 +01:00
|
|
|
|
QMessageBox, YES, NO, QT_VERSION
|
2025-12-19 14:29:52 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def ask_yes_no(
|
|
|
|
|
|
title: str,
|
|
|
|
|
|
message: str,
|
2026-03-04 15:32:49 +01:00
|
|
|
|
default: bool = True,
|
2025-12-19 14:29:52 +01:00
|
|
|
|
parent: Any = None,
|
|
|
|
|
|
) -> bool:
|
|
|
|
|
|
"""
|
2026-03-04 15:32:49 +01:00
|
|
|
|
Stellt Ja/Nein-Frage. Funktioniert in PyQt5/6 UND Mock-Modus.
|
2025-12-19 14:29:52 +01:00
|
|
|
|
"""
|
|
|
|
|
|
try:
|
2026-03-04 15:32:49 +01:00
|
|
|
|
if QT_VERSION == 0: # Mock-Modus
|
|
|
|
|
|
print(f"🔍 Mock-Modus: ask_yes_no('{title}') → {default}")
|
|
|
|
|
|
return default
|
|
|
|
|
|
|
|
|
|
|
|
# ✅ KORREKT: Verwende YES/NO-Aliase aus qt_wrapper!
|
|
|
|
|
|
buttons = YES | NO
|
|
|
|
|
|
default_button = YES if default else NO
|
|
|
|
|
|
|
2025-12-19 14:29:52 +01:00
|
|
|
|
result = QMessageBox.question(
|
2026-03-04 15:32:49 +01:00
|
|
|
|
parent, title, message, buttons, default_button
|
2025-12-19 14:29:52 +01:00
|
|
|
|
)
|
2026-03-04 15:32:49 +01:00
|
|
|
|
|
|
|
|
|
|
# ✅ int(result) == int(YES) funktioniert Qt5/6/Mock
|
|
|
|
|
|
print(f"DEBUG ask_yes_no: result={result}, YES={YES}, match={int(result) == int(YES)}")
|
|
|
|
|
|
return int(result) == int(YES)
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"⚠️ ask_yes_no Fehler: {e}")
|
2025-12-19 14:29:52 +01:00
|
|
|
|
return default
|