mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix sync errors not being reported in some cases (#4281)
* Set parent of sync error dialog * Explicitly mention parent arg in show_info() functions
This commit is contained in:
parent
2879dc63c3
commit
79932aad41
2 changed files with 22 additions and 6 deletions
|
@ -73,7 +73,7 @@ def handle_sync_error(mw: aqt.main.AnkiQt, err: Exception) -> None:
|
||||||
elif isinstance(err, Interrupted):
|
elif isinstance(err, Interrupted):
|
||||||
# no message to show
|
# no message to show
|
||||||
return
|
return
|
||||||
show_warning(str(err))
|
show_warning(str(err), parent=mw)
|
||||||
|
|
||||||
|
|
||||||
def on_normal_sync_timer(mw: aqt.main.AnkiQt) -> None:
|
def on_normal_sync_timer(mw: aqt.main.AnkiQt) -> None:
|
||||||
|
|
|
@ -226,29 +226,45 @@ def ask_user_dialog(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def show_info(text: str, callback: Callable | None = None, **kwargs: Any) -> MessageBox:
|
def show_info(
|
||||||
|
text: str,
|
||||||
|
callback: Callable | None = None,
|
||||||
|
parent: QWidget | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> MessageBox:
|
||||||
"Show a small info window with an OK button."
|
"Show a small info window with an OK button."
|
||||||
if "icon" not in kwargs:
|
if "icon" not in kwargs:
|
||||||
kwargs["icon"] = QMessageBox.Icon.Information
|
kwargs["icon"] = QMessageBox.Icon.Information
|
||||||
return MessageBox(
|
return MessageBox(
|
||||||
text,
|
text,
|
||||||
callback=(lambda _: callback()) if callback is not None else None,
|
callback=(lambda _: callback()) if callback is not None else None,
|
||||||
|
parent=parent,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def show_warning(
|
def show_warning(
|
||||||
text: str, callback: Callable | None = None, **kwargs: Any
|
text: str,
|
||||||
|
callback: Callable | None = None,
|
||||||
|
parent: QWidget | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
) -> MessageBox:
|
) -> MessageBox:
|
||||||
"Show a small warning window with an OK button."
|
"Show a small warning window with an OK button."
|
||||||
return show_info(text, icon=QMessageBox.Icon.Warning, callback=callback, **kwargs)
|
return show_info(
|
||||||
|
text, icon=QMessageBox.Icon.Warning, callback=callback, parent=parent, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def show_critical(
|
def show_critical(
|
||||||
text: str, callback: Callable | None = None, **kwargs: Any
|
text: str,
|
||||||
|
callback: Callable | None = None,
|
||||||
|
parent: QWidget | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
) -> MessageBox:
|
) -> MessageBox:
|
||||||
"Show a small critical error window with an OK button."
|
"Show a small critical error window with an OK button."
|
||||||
return show_info(text, icon=QMessageBox.Icon.Critical, callback=callback, **kwargs)
|
return show_info(
|
||||||
|
text, icon=QMessageBox.Icon.Critical, callback=callback, parent=parent, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def showWarning(
|
def showWarning(
|
||||||
|
|
Loading…
Reference in a new issue