Exemple #1
0
    def onRadioChange(self, idx: int) -> None:
        form = self.form
        min_spinner_value = 1
        max_spinner_value = DYN_MAX_SIZE
        current_spinner_value = 1
        text_after_spinner = tr.custom_study_cards()
        title_text = ""
        show_cram_type = False
        ok = tr.custom_study_ok()

        if idx == RADIO_NEW:
            title_text = tr.custom_study_available_new_cards(
                count=self.defaults.available_new)
            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)
            text_before_spinner = tr.custom_study_increase_todays_review_limit_by(
            )
            current_spinner_value = self.defaults.extend_review
            min_spinner_value = -DYN_MAX_SIZE
        elif idx == RADIO_FORGOT:
            text_before_spinner = tr.custom_study_review_cards_forgotten_in_last(
            )
            text_after_spinner = tr.scheduling_days()
            max_spinner_value = 30
        elif idx == RADIO_AHEAD:
            text_before_spinner = tr.custom_study_review_ahead_by()
            text_after_spinner = tr.scheduling_days()
        elif idx == RADIO_PREVIEW:
            text_before_spinner = tr.custom_study_preview_new_cards_added_in_the(
            )
            text_after_spinner = tr.scheduling_days()
            current_spinner_value = 1
        elif idx == RADIO_CRAM:
            text_before_spinner = tr.custom_study_select()
            text_after_spinner = tr.custom_study_cards_from_the_deck()
            ok = tr.custom_study_choose_tags()
            current_spinner_value = 100
            show_cram_type = True

        form.spin.setVisible(True)
        form.cardType.setVisible(show_cram_type)
        form.title.setText(title_text)
        form.title.setVisible(not not title_text)
        form.spin.setMinimum(min_spinner_value)
        form.spin.setMaximum(max_spinner_value)
        if max_spinner_value > 0:
            form.spin.setEnabled(True)
        else:
            form.spin.setEnabled(False)
        form.spin.setValue(current_spinner_value)
        form.preSpin.setText(text_before_spinner)
        form.postSpin.setText(text_after_spinner)
        form.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setText(ok)
        self.radioIdx = idx
Exemple #2
0
    def onRadioChange(self, idx: int) -> None:
        f = self.form
        sp = f.spin
        smin = 1
        smax = DYN_MAX_SIZE
        sval = 1
        post = tr.custom_study_cards()
        tit = ""
        spShow = True
        typeShow = False
        ok = tr.custom_study_ok()

        def plus(num: Union[int, str]) -> str:
            if num == 1000:
                num = "1000+"
            return f"<b>{str(num)}</b>"

        if idx == RADIO_NEW:
            new = self.mw.col.sched.totalNewForCurrentDeck()
            # get the number of new cards in deck that exceed the new cards limit
            newUnderLearning = min(
                new, self.conf["new"]["perDay"] - self.deck["newToday"][1])
            newExceeding = min(new, new - newUnderLearning)
            tit = tr.custom_study_new_cards_in_deck_over_today(
                val=plus(newExceeding))
            pre = tr.custom_study_increase_todays_new_card_limit_by()
            sval = min(new, self.deck.get("extendNew", 10))
            smin = -DYN_MAX_SIZE
            smax = newExceeding
        elif idx == RADIO_REV:
            rev = self.mw.col.sched.totalRevForCurrentDeck()
            # get the number of review due in deck that exceed the review due limit
            revUnderLearning = min(
                rev, self.conf["rev"]["perDay"] - self.deck["revToday"][1])
            revExceeding = min(rev, rev - revUnderLearning)
            tit = tr.custom_study_reviews_due_in_deck_over_today(
                val=plus(revExceeding))
            pre = tr.custom_study_increase_todays_review_limit_by()
            sval = min(rev, self.deck.get("extendRev", 10))
            smin = -DYN_MAX_SIZE
            smax = revExceeding
        elif idx == RADIO_FORGOT:
            pre = tr.custom_study_review_cards_forgotten_in_last()
            post = tr.scheduling_days()
            smax = 30
        elif idx == RADIO_AHEAD:
            pre = tr.custom_study_review_ahead_by()
            post = tr.scheduling_days()
        elif idx == RADIO_PREVIEW:
            pre = tr.custom_study_preview_new_cards_added_in_the()
            post = tr.scheduling_days()
            sval = 1
        elif idx == RADIO_CRAM:
            pre = tr.custom_study_select()
            post = tr.custom_study_cards_from_the_deck()
            # tit = _("After pressing OK, you can choose which tags to include.")
            ok = tr.custom_study_choose_tags()
            sval = 100
            typeShow = True
        sp.setVisible(spShow)
        f.cardType.setVisible(typeShow)
        f.title.setText(tit)
        f.title.setVisible(not not tit)
        f.spin.setMinimum(smin)
        f.spin.setMaximum(smax)
        if smax > 0:
            f.spin.setEnabled(True)
        else:
            f.spin.setEnabled(False)
        f.spin.setValue(sval)
        f.preSpin.setText(pre)
        f.postSpin.setText(post)
        f.buttonBox.button(QDialogButtonBox.Ok).setText(ok)
        self.radioIdx = idx