inline scheduling settings into preferences

This commit is contained in:
Damien Elmes 2021-03-10 14:11:59 +10:00
parent 4bcd2b68ab
commit 24ad7c1f35
4 changed files with 31 additions and 32 deletions

View file

@ -402,7 +402,7 @@ class DeckBrowser:
defaultno=True,
):
prefs = self.mw.col.get_preferences()
prefs.sched.new_timezone = False
prefs.scheduling.new_timezone = False
self.mw.col.set_preferences(prefs)
showInfo(tr(TR.SCHEDULING_UPDATE_DONE))

View file

@ -112,7 +112,7 @@ class Preferences(QDialog):
f.useCurrent.setCurrentIndex(int(not qc.get("addToCur", True)))
s = self.prefs.sched
s = self.prefs.scheduling
f.lrnCutoff.setValue(int(s.learn_ahead_secs / 60.0))
f.timeLimit.setValue(int(s.time_limit_secs / 60.0))
f.showEstimates.setChecked(s.show_intervals_on_buttons)
@ -153,7 +153,7 @@ class Preferences(QDialog):
qc = d.conf
qc["addToCur"] = not f.useCurrent.currentIndex()
s = self.prefs.sched
s = self.prefs.scheduling
s.show_remaining_due_counts = f.showProgress.isChecked()
s.show_intervals_on_buttons = f.showEstimates.isChecked()
s.new_review_mix = f.newSpread.currentIndex()

View file

@ -1022,30 +1022,30 @@ message CheckDatabaseOut {
repeated string problems = 1;
}
message CollectionSchedulingSettings {
enum NewReviewMix {
DISTRIBUTE = 0;
REVIEWS_FIRST = 1;
NEW_FIRST = 2;
message Preferences {
message Scheduling {
enum NewReviewMix {
DISTRIBUTE = 0;
REVIEWS_FIRST = 1;
NEW_FIRST = 2;
}
// read only
uint32 scheduler_version = 1;
uint32 rollover = 2;
uint32 learn_ahead_secs = 3;
NewReviewMix new_review_mix = 4;
bool show_remaining_due_counts = 5;
bool show_intervals_on_buttons = 6;
uint32 time_limit_secs = 7;
// v2 only
bool new_timezone = 8;
bool day_learn_first = 9;
}
// read only
uint32 scheduler_version = 1;
uint32 rollover = 2;
uint32 learn_ahead_secs = 3;
NewReviewMix new_review_mix = 4;
bool show_remaining_due_counts = 5;
bool show_intervals_on_buttons = 6;
uint32 time_limit_secs = 7;
// v2 only
bool new_timezone = 8;
bool day_learn_first = 9;
}
message Preferences {
CollectionSchedulingSettings sched = 1;
Scheduling scheduling = 1;
}
message ClozeNumbersInNoteOut {

View file

@ -3,8 +3,7 @@
use crate::{
backend_proto::{
collection_scheduling_settings::NewReviewMix as NewRevMixPB, CollectionSchedulingSettings,
Preferences,
preferences::scheduling::NewReviewMix as NewRevMixPB, preferences::Scheduling, Preferences,
},
collection::Collection,
config::BoolKey,
@ -15,20 +14,20 @@ use crate::{
impl Collection {
pub fn get_preferences(&self) -> Result<Preferences> {
Ok(Preferences {
sched: Some(self.get_collection_scheduling_settings()?),
scheduling: Some(self.get_collection_scheduling_settings()?),
})
}
pub fn set_preferences(&mut self, prefs: Preferences) -> Result<()> {
if let Some(sched) = prefs.sched {
if let Some(sched) = prefs.scheduling {
self.set_collection_scheduling_settings(sched)?;
}
Ok(())
}
pub fn get_collection_scheduling_settings(&self) -> Result<CollectionSchedulingSettings> {
Ok(CollectionSchedulingSettings {
pub fn get_collection_scheduling_settings(&self) -> Result<Scheduling> {
Ok(Scheduling {
scheduler_version: match self.scheduler_version() {
crate::config::SchedulerVersion::V1 => 1,
crate::config::SchedulerVersion::V2 => 2,
@ -50,7 +49,7 @@ impl Collection {
pub(crate) fn set_collection_scheduling_settings(
&mut self,
settings: CollectionSchedulingSettings,
settings: Scheduling,
) -> Result<()> {
let s = settings;