Merge branch 'main' into use-proper-minus

This commit is contained in:
Abdo 2025-12-16 19:25:38 +03:00 committed by GitHub
commit 7d3e26238a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 19 deletions

View file

@ -14,7 +14,7 @@ from markdown import markdown
import aqt import aqt
from anki.collection import HelpPage from anki.collection import HelpPage
from anki.errors import BackendError, Interrupted from anki.errors import BackendError, CardTypeError, Interrupted
from anki.utils import is_win from anki.utils import is_win
from aqt.addons import AddonManager, AddonMeta from aqt.addons import AddonManager, AddonMeta
from aqt.qt import * from aqt.qt import *
@ -36,6 +36,14 @@ def show_exception(*, parent: QWidget, exception: Exception) -> None:
global _mbox global _mbox
error_lines = [] error_lines = []
help_page = HelpPage.TROUBLESHOOTING help_page = HelpPage.TROUBLESHOOTING
# default to PlainText
text_format = Qt.TextFormat.PlainText
# set CardTypeError messages as rich text to allow HTML formatting
if isinstance(exception, CardTypeError):
text_format = Qt.TextFormat.RichText
if isinstance(exception, BackendError): if isinstance(exception, BackendError):
if exception.context: if exception.context:
error_lines.append(exception.context) error_lines.append(exception.context)
@ -51,7 +59,7 @@ def show_exception(*, parent: QWidget, exception: Exception) -> None:
) )
error_text = "\n".join(error_lines) error_text = "\n".join(error_lines)
print(error_lines) print(error_lines)
_mbox = _init_message_box(str(exception), error_text, help_page) _mbox = _init_message_box(str(exception), error_text, help_page, text_format)
_mbox.show() _mbox.show()
@ -171,7 +179,10 @@ if not os.environ.get("DEBUG"):
def _init_message_box( def _init_message_box(
user_text: str, debug_text: str, help_page=HelpPage.TROUBLESHOOTING user_text: str,
debug_text: str,
help_page=HelpPage.TROUBLESHOOTING,
text_format=Qt.TextFormat.PlainText,
): ):
global _mbox global _mbox
@ -179,7 +190,7 @@ def _init_message_box(
_mbox.setWindowTitle("Anki") _mbox.setWindowTitle("Anki")
_mbox.setText(user_text) _mbox.setText(user_text)
_mbox.setIcon(QMessageBox.Icon.Warning) _mbox.setIcon(QMessageBox.Icon.Warning)
_mbox.setTextFormat(Qt.TextFormat.PlainText) _mbox.setTextFormat(text_format)
def show_help(): def show_help():
openHelp(help_page) openHelp(help_page)

View file

@ -202,7 +202,7 @@ fn sveltekit_temp_file(path: &str) -> bool {
} }
fn check_cargo_deny() -> Result<()> { fn check_cargo_deny() -> Result<()> {
Command::run("cargo install cargo-deny@0.18.3")?; Command::run("cargo install cargo-deny@0.18.6")?;
Command::run("cargo deny check")?; Command::run("cargo deny check")?;
Ok(()) Ok(())
} }

View file

@ -37,7 +37,9 @@ export const addOrUpdateNote = async function(
backExtra, backExtra,
tags, tags,
}); });
if (result.note) {
showResult(mode.noteId, result, noteCount); showResult(mode.noteId, result, noteCount);
}
} else { } else {
const result = await addImageOcclusionNote({ const result = await addImageOcclusionNote({
// IOCloningMode is not used on mobile // IOCloningMode is not used on mobile
@ -55,23 +57,12 @@ export const addOrUpdateNote = async function(
// show toast message // show toast message
const showResult = (noteId: number | null, result: OpChanges, count: number) => { const showResult = (noteId: number | null, result: OpChanges, count: number) => {
const props = $state({ const props = $state({
message: "", message: noteId ? tr.browsingCardsUpdated({ count: count }) : tr.importingCardsAdded({ count: count }),
type: "error" as "error" | "success", type: "success" as "error" | "success",
showToast: true, showToast: true,
}); });
mount(Toast, { mount(Toast, {
target: document.body, target: document.body,
props, props,
}); });
if (result.note) {
const msg = noteId ? tr.browsingCardsUpdated({ count: count }) : tr.importingCardsAdded({ count: count });
props.message = msg;
props.type = "success";
props.showToast = true;
} else {
const msg = tr.notetypesErrorGeneratingCloze();
props.message = msg;
props.showToast = true;
}
}; };