Implement "stop timer on answer" as a preset option (#2686)

* Implement "stop timer on answer" as a preset option

* Hide timer setting on AnkiMobile (dae)
This commit is contained in:
Abdo 2023-09-27 09:10:14 +03:00 committed by GitHub
parent ab4e820608
commit ab7e64865e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 36 additions and 27 deletions

View file

@ -234,7 +234,10 @@ deck-config-skip-question-when-replaying = Skip question when replaying answer
deck-config-always-include-question-audio-tooltip = deck-config-always-include-question-audio-tooltip =
Whether the question audio should be included when the Replay action is Whether the question audio should be included when the Replay action is
used while looking at the answer side of a card. used while looking at the answer side of a card.
deck-config-stop-timer-on-answer = Stop timer on answer
deck-config-stop-timer-on-answer-tooltip =
Whether to stop the timer when the answer is revealed.
This doesn't affect statistics.
## Advanced section ## Advanced section
deck-config-advanced-title = Advanced deck-config-advanced-title = Advanced

View file

@ -73,7 +73,6 @@ preferences-network-timeout = Network timeout
preferences-reset-window-sizes = Reset Window Sizes preferences-reset-window-sizes = Reset Window Sizes
preferences-reset-window-sizes-complete = Window sizes and locations have been reset. preferences-reset-window-sizes-complete = Window sizes and locations have been reset.
preferences-shortcut-placeholder = Enter an unused shortcut key, or leave empty to disable. preferences-shortcut-placeholder = Enter an unused shortcut key, or leave empty to disable.
preferences-stop-timer-on-answer = Stop timer on answer
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future. ## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.

View file

@ -53,7 +53,6 @@ message ConfigKey {
RESET_COUNTS_REVIEWER = 22; RESET_COUNTS_REVIEWER = 22;
RANDOM_ORDER_REPOSITION = 23; RANDOM_ORDER_REPOSITION = 23;
SHIFT_POSITION_OF_EXISTING_CARDS = 24; SHIFT_POSITION_OF_EXISTING_CARDS = 24;
STOP_TIMER_ON_ANSWER = 25;
} }
enum String { enum String {
SET_DUE_BROWSER = 0; SET_DUE_BROWSER = 0;
@ -118,7 +117,6 @@ message Preferences {
bool show_remaining_due_counts = 3; bool show_remaining_due_counts = 3;
bool show_intervals_on_buttons = 4; bool show_intervals_on_buttons = 4;
uint32 time_limit_secs = 5; uint32 time_limit_secs = 5;
bool stop_timer_on_answer = 6;
} }
message Editing { message Editing {
bool adding_defaults_to_current_deck = 1; bool adding_defaults_to_current_deck = 1;

View file

@ -132,6 +132,7 @@ message DeckConfig {
bool disable_autoplay = 23; bool disable_autoplay = 23;
uint32 cap_answer_time_to_secs = 24; uint32 cap_answer_time_to_secs = 24;
bool show_timer = 25; bool show_timer = 25;
bool stop_timer_on_answer = 38;
bool skip_question_when_replaying_answer = 26; bool skip_question_when_replaying_answer = 26;
bool bury_new = 27; bool bury_new = 27;

View file

@ -410,19 +410,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="stop_timer_on_answer">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>preferences_stop_timer_on_answer</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -1099,7 +1086,6 @@
<tabstop>showProgress</tabstop> <tabstop>showProgress</tabstop>
<tabstop>showEstimates</tabstop> <tabstop>showEstimates</tabstop>
<tabstop>spacebar_rates_card</tabstop> <tabstop>spacebar_rates_card</tabstop>
<tabstop>stop_timer_on_answer</tabstop>
<tabstop>pastePNG</tabstop> <tabstop>pastePNG</tabstop>
<tabstop>paste_strips_formatting</tabstop> <tabstop>paste_strips_formatting</tabstop>
<tabstop>useCurrent</tabstop> <tabstop>useCurrent</tabstop>

View file

@ -113,7 +113,6 @@ class Preferences(QDialog):
form.showProgress.setChecked(reviewing.show_remaining_due_counts) form.showProgress.setChecked(reviewing.show_remaining_due_counts)
form.showPlayButtons.setChecked(not reviewing.hide_audio_play_buttons) form.showPlayButtons.setChecked(not reviewing.hide_audio_play_buttons)
form.interrupt_audio.setChecked(reviewing.interrupt_audio_when_answering) form.interrupt_audio.setChecked(reviewing.interrupt_audio_when_answering)
form.stop_timer_on_answer.setChecked(reviewing.stop_timer_on_answer)
editing = self.prefs.editing editing = self.prefs.editing
form.useCurrent.setCurrentIndex( form.useCurrent.setCurrentIndex(
@ -145,7 +144,6 @@ class Preferences(QDialog):
reviewing.time_limit_secs = form.timeLimit.value() * 60 reviewing.time_limit_secs = form.timeLimit.value() * 60
reviewing.hide_audio_play_buttons = not self.form.showPlayButtons.isChecked() reviewing.hide_audio_play_buttons = not self.form.showPlayButtons.isChecked()
reviewing.interrupt_audio_when_answering = self.form.interrupt_audio.isChecked() reviewing.interrupt_audio_when_answering = self.form.interrupt_audio.isChecked()
reviewing.stop_timer_on_answer = self.form.stop_timer_on_answer.isChecked()
editing = self.prefs.editing editing = self.prefs.editing
editing.adding_defaults_to_current_deck = not form.useCurrent.currentIndex() editing.adding_defaults_to_current_deck = not form.useCurrent.currentIndex()

View file

@ -741,9 +741,9 @@ timerStopped = false;
self.mw.progress.single_shot(50, self._showEaseButtons) self.mw.progress.single_shot(50, self._showEaseButtons)
return return
middle = self._answerButtons() middle = self._answerButtons()
stop_timer = self.mw.col.get_config_bool(Config.Bool.STOP_TIMER_ON_ANSWER) conf = self.mw.col.decks.config_dict_for_deck_id(self.card.current_deck_id())
self.bottom.web.eval( self.bottom.web.eval(
f"showAnswer({json.dumps(middle)}, {json.dumps(stop_timer)});" f"showAnswer({json.dumps(middle)}, {json.dumps(conf['stopTimerOnAnswer'])});"
) )
def _remaining(self) -> str: def _remaining(self) -> str:

View file

@ -36,7 +36,6 @@ impl From<BoolKeyProto> for BoolKey {
BoolKeyProto::ResetCountsReviewer => BoolKey::ResetCountsReviewer, BoolKeyProto::ResetCountsReviewer => BoolKey::ResetCountsReviewer,
BoolKeyProto::RandomOrderReposition => BoolKey::RandomOrderReposition, BoolKeyProto::RandomOrderReposition => BoolKey::RandomOrderReposition,
BoolKeyProto::ShiftPositionOfExistingCards => BoolKey::ShiftPositionOfExistingCards, BoolKeyProto::ShiftPositionOfExistingCards => BoolKey::ShiftPositionOfExistingCards,
BoolKeyProto::StopTimerOnAnswer => BoolKey::StopTimerOnAnswer,
} }
} }
} }

View file

@ -36,9 +36,7 @@ pub enum BoolKey {
ShiftPositionOfExistingCards, ShiftPositionOfExistingCards,
MergeNotetypes, MergeNotetypes,
WithScheduling, WithScheduling,
StopTimerOnAnswer,
Fsrs, Fsrs,
#[strum(to_string = "normalize_note_text")] #[strum(to_string = "normalize_note_text")]
NormalizeNoteText, NormalizeNoteText,
#[strum(to_string = "dayLearnFirst")] #[strum(to_string = "dayLearnFirst")]

View file

@ -62,6 +62,7 @@ const DEFAULT_DECK_CONFIG_INNER: DeckConfigInner = DeckConfigInner {
disable_autoplay: false, disable_autoplay: false,
cap_answer_time_to_secs: 60, cap_answer_time_to_secs: 60,
show_timer: false, show_timer: false,
stop_timer_on_answer: false,
skip_question_when_replaying_answer: false, skip_question_when_replaying_answer: false,
bury_new: false, bury_new: false,
bury_reviews: false, bury_reviews: false,

View file

@ -69,6 +69,8 @@ pub struct DeckConfSchema11 {
fsrs_weights: Vec<f32>, fsrs_weights: Vec<f32>,
#[serde(default)] #[serde(default)]
desired_retention: f32, desired_retention: f32,
#[serde(default)]
stop_timer_on_answer: bool,
#[serde(flatten)] #[serde(flatten)]
other: HashMap<String, Value>, other: HashMap<String, Value>,
@ -242,6 +244,7 @@ impl Default for DeckConfSchema11 {
max_taken: 60, max_taken: 60,
autoplay: true, autoplay: true,
timer: 0, timer: 0,
stop_timer_on_answer: false,
replayq: true, replayq: true,
dynamic: false, dynamic: false,
new: Default::default(), new: Default::default(),
@ -321,6 +324,7 @@ impl From<DeckConfSchema11> for DeckConfig {
disable_autoplay: !c.autoplay, disable_autoplay: !c.autoplay,
cap_answer_time_to_secs: c.max_taken.max(0) as u32, cap_answer_time_to_secs: c.max_taken.max(0) as u32,
show_timer: c.timer != 0, show_timer: c.timer != 0,
stop_timer_on_answer: c.stop_timer_on_answer,
skip_question_when_replaying_answer: !c.replayq, skip_question_when_replaying_answer: !c.replayq,
bury_new: c.new.bury, bury_new: c.new.bury,
bury_reviews: c.rev.bury, bury_reviews: c.rev.bury,
@ -372,6 +376,7 @@ impl From<DeckConfig> for DeckConfSchema11 {
max_taken: i.cap_answer_time_to_secs as i32, max_taken: i.cap_answer_time_to_secs as i32,
autoplay: !i.disable_autoplay, autoplay: !i.disable_autoplay,
timer: i.show_timer.into(), timer: i.show_timer.into(),
stop_timer_on_answer: i.stop_timer_on_answer,
replayq: !i.skip_question_when_replaying_answer, replayq: !i.skip_question_when_replaying_answer,
dynamic: false, dynamic: false,
new: NewConfSchema11 { new: NewConfSchema11 {
@ -443,6 +448,7 @@ static RESERVED_DECKCONF_KEYS: Set<&'static str> = phf_set! {
"newGatherPriority", "newGatherPriority",
"fsrsWeights", "fsrsWeights",
"desiredRetention", "desiredRetention",
"stopTimerOnAnswer",
}; };
static RESERVED_DECKCONF_NEW_KEYS: Set<&'static str> = phf_set! { static RESERVED_DECKCONF_NEW_KEYS: Set<&'static str> = phf_set! {

View file

@ -108,7 +108,6 @@ impl Collection {
show_intervals_on_buttons: self show_intervals_on_buttons: self
.get_config_bool(BoolKey::ShowIntervalsAboveAnswerButtons), .get_config_bool(BoolKey::ShowIntervalsAboveAnswerButtons),
time_limit_secs: self.get_answer_time_limit_secs(), time_limit_secs: self.get_answer_time_limit_secs(),
stop_timer_on_answer: self.get_config_bool(BoolKey::StopTimerOnAnswer),
}) })
} }
@ -128,7 +127,6 @@ impl Collection {
s.show_intervals_on_buttons, s.show_intervals_on_buttons,
)?; )?;
self.set_answer_time_limit_secs(s.time_limit_secs)?; self.set_answer_time_limit_secs(s.time_limit_secs)?;
self.set_config_bool_inner(BoolKey::StopTimerOnAnswer, s.stop_timer_on_answer)?;
Ok(()) Ok(())
} }

View file

@ -39,6 +39,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title: tr.schedulingShowAnswerTimer(), title: tr.schedulingShowAnswerTimer(),
help: tr.deckConfigShowAnswerTimerTooltip(), help: tr.deckConfigShowAnswerTimerTooltip(),
}, },
stopTimerOnAnswer: {
title: tr.deckConfigStopTimerOnAnswer(),
help: tr.deckConfigStopTimerOnAnswerTooltip(),
},
}; };
const helpSections = Object.values(settings) as HelpItem[]; const helpSections = Object.values(settings) as HelpItem[];
@ -103,5 +107,23 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</SwitchRow> </SwitchRow>
</div> </div>
</Item> </Item>
<Item>
<div class="show-timer-switch" style="display: contents;">
<SwitchRow
bind:value={$config.stopTimerOnAnswer}
defaultValue={defaults.stopTimerOnAnswer}
>
<SettingTitle
on:click={() =>
openHelpModal(
Object.keys(settings).indexOf("stopTimerOnAnswer"),
)}
>
{settings.stopTimerOnAnswer.title}
</SettingTitle>
</SwitchRow>
</div>
</Item>
</DynamicallySlottable> </DynamicallySlottable>
</TitledContainer> </TitledContainer>