diff --git a/ftl/core/errors.ftl b/ftl/core/errors.ftl index a00923d4c..c2cfe9e82 100644 --- a/ftl/core/errors.ftl +++ b/ftl/core/errors.ftl @@ -3,3 +3,7 @@ errors-invalid-input-details = Invalid input: { $details } errors-parse-number-fail = A number was invalid or out of range. errors-filtered-parent-deck = Filtered decks can not have child decks. errors-filtered-deck-required = This action can only be used on a filtered deck. +errors-100-tags-max = + A maximum of 100 tags can be selected. Listing the + tags you want instead of the ones you don't want is usually simpler, and there + is no need to select child tags if you have selected a parent tag. diff --git a/pylib/anki/lang.py b/pylib/anki/lang.py index 32fdbcdc1..fb7539f30 100644 --- a/pylib/anki/lang.py +++ b/pylib/anki/lang.py @@ -211,3 +211,7 @@ def is_rtl(lang: str) -> bool: # for testing purposes def without_unicode_isolation(s: str) -> str: return s.replace("\u2068", "").replace("\u2069", "") + + +def with_collapsed_whitespace(s: str) -> str: + return re.sub(r"\s+", " ", s) diff --git a/qt/aqt/taglimit.py b/qt/aqt/taglimit.py index 64459a7f1..d0d4706a8 100644 --- a/qt/aqt/taglimit.py +++ b/qt/aqt/taglimit.py @@ -3,10 +3,11 @@ from typing import List, Optional import aqt +from anki.lang import with_collapsed_whitespace from aqt.customstudy import CustomStudy from aqt.main import AnkiQt from aqt.qt import * -from aqt.utils import disable_help_button, restoreGeom, saveGeom +from aqt.utils import disable_help_button, restoreGeom, saveGeom, showWarning, tr class TagLimit(QDialog): @@ -73,7 +74,6 @@ class TagLimit(QDialog): QDialog.reject(self) def accept(self) -> None: - self.hide() # gather yes/no tags yes = [] no = [] @@ -89,6 +89,10 @@ class TagLimit(QDialog): idx = self.dialog.inactiveList.indexFromItem(item) if self.dialog.inactiveList.selectionModel().isSelected(idx): no.append(self.tags_list[c]) + if (len(yes) + len(no)) > 100: + showWarning(with_collapsed_whitespace(tr.errors_100_tags_max())) + return + self.hide() # save in the deck for future invocations self.deck["activeTags"] = yes self.deck["inactiveTags"] = no