mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Rework display of available cards in custom study
In v3, it's more informative to show the count of child decks separately, since increasing the limit of the current deck does not increase the limits of child decks. When we rework the decks list in the future, a tooltip will hopefully provide an easier way for users to see where cards are available, and where limits are being applied. Closes #1868
This commit is contained in:
parent
aed3988d48
commit
82196753ec
5 changed files with 52 additions and 8 deletions
|
@ -24,8 +24,11 @@ custom-study-select = Select
|
|||
custom-study-select-tags-to-exclude = Select tags to exclude:
|
||||
custom-study-selective-study = Selective Study
|
||||
custom-study-study-by-card-state-or-tag = Study by card state or tag
|
||||
custom-study-available-new-cards = Available new cards: { $count }
|
||||
custom-study-available-review-cards = Available review cards: { $count }
|
||||
custom-study-available-new-cards-2 = Available new cards: { $countString }
|
||||
custom-study-available-review-cards-2 = Available review cards: { $countString }
|
||||
custom-study-available-child-count = ({ $count } in subdecks)
|
||||
|
||||
## DEPRECATED - you do not need to translate these.
|
||||
|
||||
custom-study-available-new-cards = Available new cards: { $count }
|
||||
custom-study-available-review-cards = Available review cards: { $count }
|
||||
|
|
|
@ -291,4 +291,7 @@ message CustomStudyDefaultsResponse {
|
|||
uint32 extend_review = 3;
|
||||
uint32 available_new = 4;
|
||||
uint32 available_review = 5;
|
||||
// in v3, counts for children are provided separately
|
||||
uint32 available_new_in_children = 6;
|
||||
uint32 available_review_in_children = 7;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import aqt
|
||||
|
@ -75,6 +77,12 @@ class CustomStudy(QDialog):
|
|||
qconnect(f.radioPreview.clicked, lambda: self.onRadioChange(RADIO_PREVIEW))
|
||||
qconnect(f.radioCram.clicked, lambda: self.onRadioChange(RADIO_CRAM))
|
||||
|
||||
def count_with_children(self, parent: int, children: int) -> str:
|
||||
if children:
|
||||
return f"{parent} {tr.custom_study_available_child_count(children)}"
|
||||
else:
|
||||
return str(parent)
|
||||
|
||||
def onRadioChange(self, idx: int) -> None:
|
||||
form = self.form
|
||||
min_spinner_value = 1
|
||||
|
@ -86,15 +94,21 @@ class CustomStudy(QDialog):
|
|||
ok = tr.custom_study_ok()
|
||||
|
||||
if idx == RADIO_NEW:
|
||||
title_text = tr.custom_study_available_new_cards(
|
||||
count=self.defaults.available_new
|
||||
title_text = tr.custom_study_available_new_cards_2(
|
||||
count_string=self.count_with_children(
|
||||
self.defaults.available_new,
|
||||
self.defaults.available_new_in_children,
|
||||
),
|
||||
)
|
||||
text_before_spinner = tr.custom_study_increase_todays_new_card_limit_by()
|
||||
current_spinner_value = self.defaults.extend_new
|
||||
min_spinner_value = -DYN_MAX_SIZE
|
||||
elif idx == RADIO_REV:
|
||||
title_text = tr.custom_study_available_review_cards(
|
||||
count=self.defaults.available_review
|
||||
title_text = tr.custom_study_available_review_cards_2(
|
||||
count_string=self.count_with_children(
|
||||
self.defaults.available_review,
|
||||
self.defaults.available_review_in_children,
|
||||
),
|
||||
)
|
||||
text_before_spinner = tr.custom_study_increase_todays_review_limit_by()
|
||||
current_spinner_value = self.defaults.extend_review
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import enum
|
||||
|
|
|
@ -34,8 +34,29 @@ impl Collection {
|
|||
.deck_tree(Some(TimestampSecs::now()))?
|
||||
.get_deck(deck_id)
|
||||
.ok_or(AnkiError::NotFound)?;
|
||||
let available_new = subtree.sum(|node| node.new_uncapped);
|
||||
let available_review = subtree.sum(|node| node.review_uncapped);
|
||||
let v3 = self.get_config_bool(BoolKey::Sched2021);
|
||||
let available_new_including_children = subtree.sum(|node| node.new_uncapped);
|
||||
let available_review_including_children = subtree.sum(|node| node.review_uncapped);
|
||||
let (
|
||||
available_new,
|
||||
available_new_in_children,
|
||||
available_review,
|
||||
available_review_in_children,
|
||||
) = if v3 {
|
||||
(
|
||||
subtree.new_uncapped,
|
||||
available_new_including_children - subtree.new_uncapped,
|
||||
subtree.review_uncapped,
|
||||
available_review_including_children - subtree.review_uncapped,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
available_new_including_children,
|
||||
0,
|
||||
available_review_including_children,
|
||||
0,
|
||||
)
|
||||
};
|
||||
// tags
|
||||
let include_tags: HashSet<String> = self.get_config_default(
|
||||
DeckConfigKey::CustomStudyIncludeTags
|
||||
|
@ -67,6 +88,8 @@ impl Collection {
|
|||
extend_review,
|
||||
available_new,
|
||||
available_review,
|
||||
available_new_in_children,
|
||||
available_review_in_children,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue