Remove prompt when deleting from deckbrowser
This commit is contained in:
parent
5d93832713
commit
c11a394753
@ -115,7 +115,7 @@ browsing-note-deleted =
|
|||||||
[one] { $count } note deleted.
|
[one] { $count } note deleted.
|
||||||
*[other] { $count } notes deleted.
|
*[other] { $count } notes deleted.
|
||||||
}
|
}
|
||||||
browsing-notes-updated =
|
browsing-notes-updated =
|
||||||
{ $count ->
|
{ $count ->
|
||||||
[one] { $count } note updated.
|
[one] { $count } note updated.
|
||||||
*[other] { $count } notes updated.
|
*[other] { $count } notes updated.
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
decks-add-new-deck-ctrlandn = Add New Deck (Ctrl+N)
|
decks-add-new-deck-ctrlandn = Add New Deck (Ctrl+N)
|
||||||
decks-are-you-sure-you-wish-to = Are you sure you wish to delete { $val }?
|
|
||||||
decks-build = Build
|
decks-build = Build
|
||||||
decks-cards-selected-by = cards selected by
|
decks-cards-selected-by = cards selected by
|
||||||
decks-create-deck = Create Deck
|
decks-create-deck = Create Deck
|
||||||
@ -32,8 +31,3 @@ decks-study = Study
|
|||||||
decks-study-deck = Study Deck
|
decks-study-deck = Study Deck
|
||||||
decks-the-provided-search-did-not-match = The provided search did not match any cards. Would you like to revise it?
|
decks-the-provided-search-did-not-match = The provided search did not match any cards. Would you like to revise it?
|
||||||
decks-unmovable-cards = Show any excluded cards
|
decks-unmovable-cards = Show any excluded cards
|
||||||
decks-it-has-card =
|
|
||||||
{ $count ->
|
|
||||||
[one] It has { $count } card.
|
|
||||||
*[other] It has { $count } cards.
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, List
|
from typing import Any
|
||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
from anki.decks import DeckTreeNode
|
from anki.decks import DeckTreeNode
|
||||||
@ -23,6 +23,7 @@ from aqt.utils import (
|
|||||||
shortcut,
|
shortcut,
|
||||||
showInfo,
|
showInfo,
|
||||||
showWarning,
|
showWarning,
|
||||||
|
tooltip,
|
||||||
tr,
|
tr,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -295,38 +296,16 @@ class DeckBrowser:
|
|||||||
gui_hooks.sidebar_should_refresh_decks()
|
gui_hooks.sidebar_should_refresh_decks()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def ask_delete_deck(self, did: int) -> bool:
|
|
||||||
return self.ask_delete_decks([did])
|
|
||||||
|
|
||||||
def ask_delete_decks(self, dids: List[int]) -> bool:
|
|
||||||
decks = [self.mw.col.decks.get(did) for did in dids]
|
|
||||||
if all([deck["dyn"] for deck in decks]):
|
|
||||||
return True
|
|
||||||
|
|
||||||
count = self.mw.col.decks.card_count(dids, include_subdecks=True)
|
|
||||||
if not count:
|
|
||||||
return True
|
|
||||||
|
|
||||||
if len(dids) == 1:
|
|
||||||
extra = tr(TR.DECKS_IT_HAS_CARD, count=count)
|
|
||||||
return askUser(
|
|
||||||
f"{tr(TR.DECKS_ARE_YOU_SURE_YOU_WISH_TO, val=decks[0]['name'])} {extra}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return askUser(tr(TR.DECKS_CONFIRM_DELETION, count=count))
|
|
||||||
|
|
||||||
def _delete(self, did: int) -> None:
|
def _delete(self, did: int) -> None:
|
||||||
if self.ask_delete_deck(did):
|
def do_delete() -> int:
|
||||||
|
return self.mw.col.decks.remove([did])
|
||||||
|
|
||||||
def do_delete() -> None:
|
def on_done(fut: Future) -> None:
|
||||||
return self.mw.col.decks.rem(did, True)
|
self.show()
|
||||||
|
tooltip(tr(TR.BROWSING_CARDS_DELETED, count=fut.result()))
|
||||||
|
|
||||||
def on_done(fut: Future) -> None:
|
self.mw.checkpoint(tr(TR.DECKS_DELETE_DECK))
|
||||||
self.show()
|
self.mw.taskman.with_progress(do_delete, on_done)
|
||||||
res = fut.result() # Required to check for errors
|
|
||||||
|
|
||||||
self.mw.checkpoint(tr(TR.DECKS_DELETE_DECK))
|
|
||||||
self.mw.taskman.with_progress(do_delete, on_done)
|
|
||||||
|
|
||||||
# Top buttons
|
# Top buttons
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -1148,7 +1148,7 @@ class SidebarTreeView(QTreeView):
|
|||||||
def _remove_tags(self, _item: SidebarItem) -> None:
|
def _remove_tags(self, _item: SidebarItem) -> None:
|
||||||
tags = self._selected_tags()
|
tags = self._selected_tags()
|
||||||
|
|
||||||
def do_remove() -> None:
|
def do_remove() -> int:
|
||||||
return self.col._backend.expunge_tags(" ".join(tags))
|
return self.col._backend.expunge_tags(" ".join(tags))
|
||||||
|
|
||||||
def on_done(fut: Future) -> None:
|
def on_done(fut: Future) -> None:
|
||||||
@ -1199,7 +1199,7 @@ class SidebarTreeView(QTreeView):
|
|||||||
self.browser.editor.saveNow(self._delete_decks)
|
self.browser.editor.saveNow(self._delete_decks)
|
||||||
|
|
||||||
def _delete_decks(self) -> None:
|
def _delete_decks(self) -> None:
|
||||||
def do_delete() -> None:
|
def do_delete() -> int:
|
||||||
return self.mw.col.decks.remove(dids)
|
return self.mw.col.decks.remove(dids)
|
||||||
|
|
||||||
def on_done(fut: Future) -> None:
|
def on_done(fut: Future) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user