add option to disable media syncing

https://forums.ankiweb.net/t/error-when-adding-audio-file/495/2
This commit is contained in:
Damien Elmes 2020-07-01 11:35:24 +10:00
parent 05fb67d409
commit bedd9dadb1
4 changed files with 21 additions and 2 deletions

View file

@ -1231,8 +1231,10 @@ Difference to correct time: %s."""
def on_autosync_timer(self):
elap = self.media_syncer.seconds_since_last_sync()
# autosync if 15 minutes have elapsed since last sync
if elap > 15 * 60:
minutes = self.pm.auto_sync_media_minutes()
if not minutes:
return
if elap > minutes * 60:
self.maybe_auto_sync_media()
# Permanent libanki hooks

View file

@ -169,6 +169,7 @@ class Preferences(QDialog):
qconnect(self.form.media_log.clicked, self.on_media_log)
self.form.syncOnProgramOpen.setChecked(self.prof["autoSync"])
self.form.syncMedia.setChecked(self.prof["syncMedia"])
self.form.autoSyncMedia.setChecked(self.mw.pm.auto_sync_media_minutes() != 0)
if not self.prof["syncKey"]:
self._hideAuth()
else:
@ -200,6 +201,7 @@ Not currently enabled; click the sync button in the main window to enable."""
def updateNetwork(self):
self.prof["autoSync"] = self.form.syncOnProgramOpen.isChecked()
self.prof["syncMedia"] = self.form.syncMedia.isChecked()
self.mw.pm.set_auto_sync_media_minutes(self.form.autoSyncMedia.isChecked() and 15 or 0)
if self.form.fullSync.isChecked():
self.mw.col.modSchema(check=False)
self.mw.col.setMod()

View file

@ -635,6 +635,12 @@ create table if not exists profiles
self.profile["syncUser"] = None
self.profile["hostNum"] = 0
def auto_sync_media_minutes(self) -> int:
return self.profile.get("autoSyncMediaMinutes", 15)
def set_auto_sync_media_minutes(self, val: int):
self.profile["autoSyncMediaMinutes"] = val
######################################################################
def apply_profile_options(self) -> None:

View file

@ -363,6 +363,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoSyncMedia">
<property name="text">
<string>Periodically sync media</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fullSync">
<property name="text">
@ -581,6 +588,7 @@
</layout>
</widget>
<tabstops>
<tabstop>lang</tabstop>
<tabstop>hwAccel</tabstop>
<tabstop>showPlayButtons</tabstop>
<tabstop>interrupt_audio</tabstop>
@ -600,6 +608,7 @@
<tabstop>timeLimit</tabstop>
<tabstop>syncMedia</tabstop>
<tabstop>syncOnProgramOpen</tabstop>
<tabstop>autoSyncMedia</tabstop>
<tabstop>fullSync</tabstop>
<tabstop>syncDeauth</tabstop>
<tabstop>media_log</tabstop>