Files
Plugin_SN_Basis/functions/dialog_wrapper.py

38 lines
1.1 KiB
Python
Raw Normal View History

"""
sn_basis/functions/dialog_wrapper.py Benutzer-Dialoge (Qt5/6/Mock-kompatibel)
"""
from typing import Any
from sn_basis.functions.qt_wrapper import (
QMessageBox, YES, NO, QT_VERSION
)
def ask_yes_no(
title: str,
message: str,
default: bool = True,
parent: Any = None,
) -> bool:
"""
Stellt Ja/Nein-Frage. Funktioniert in PyQt5/6 UND Mock-Modus.
"""
try:
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
result = QMessageBox.question(
parent, title, message, buttons, default_button
)
# ✅ 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}")
return default