tweak config and startup

This commit is contained in:
Damien Elmes 2011-04-24 12:06:20 +09:00
parent f4ee17a5c6
commit e28f5fe931
3 changed files with 11 additions and 42 deletions

View file

@ -3,9 +3,9 @@
# User configuration handling # User configuration handling
########################################################################## ##########################################################################
# The majority of the config is serialized into a string, both for easy access # The majority of the config is serialized into a string, so we can access it
# and backwards compatibility. A separate table keeps track of seen decks, so # easily and pickle objects like window state. A separate table keeps track of
# that multiple instances can update the recent decks list. # seen decks, so that multiple instances can update the recent decks list.
import os, sys, time, random, cPickle import os, sys, time, random, cPickle
from anki.db import DB from anki.db import DB
@ -13,19 +13,11 @@ from anki.utils import isMac
defaultConf = { defaultConf = {
'confVer': 3, 'confVer': 3,
# remove?
'colourTimes': True,
# too long?
'deckBrowserRefreshPeriod': 3600,
'factEditorAdvanced': False,
'showStudyScreen': True,
'interfaceLang': "en", 'interfaceLang': "en",
'fullSearch': False, 'fullSearch': False,
'autoplaySounds': True, 'autoplaySounds': True,
'searchHistory': [], 'searchHistory': [],
'checkForUpdates': True, 'checkForUpdates': True, # ui?
'created': time.time(), 'created': time.time(),
'deleteMedia': False, 'deleteMedia': False,
'documentDir': u"", 'documentDir': u"",
@ -33,7 +25,6 @@ defaultConf = {
'editFontFamily': 'Arial', 'editFontFamily': 'Arial',
'editFontSize': 12, 'editFontSize': 12,
'editLineSize': 20, 'editLineSize': 20,
'editorReverseOrder': False,
'iconSize': 32, 'iconSize': 32,
'id': random.randrange(0, 2**63), 'id': random.randrange(0, 2**63),
'lastMsg': -1, 'lastMsg': -1,
@ -48,19 +39,13 @@ defaultConf = {
'proxyPort': 8080, 'proxyPort': 8080,
'proxyUser': '', 'proxyUser': '',
'recentColours': ["#000000", "#0000ff"], 'recentColours': ["#000000", "#0000ff"],
'repeatQuestionAudio': True,
'scrollToAnswer': True,
'showCardTimer': True,
'showProgress': True, 'showProgress': True,
'showTimer': True,
'showToolbar': True, 'showToolbar': True,
'centerQA': True, 'centerQA': True,
'stripHTML': True, 'stripHTML': True,
'studyOptionsTab': 0,
'suppressEstimates': False, 'suppressEstimates': False,
'suppressUpdate': False, 'suppressUpdate': False,
'syncDisableWhenMoved': True, 'syncDisableWhenMoved': True,
'syncOnLoad': False,
'syncOnProgramOpen': True, 'syncOnProgramOpen': True,
'syncPassword': "", 'syncPassword': "",
'syncUsername': "", 'syncUsername': "",
@ -148,10 +133,3 @@ create table if not exists config (conf text not null);
os.mkdir(x) os.mkdir(x)
except: except:
pass pass
def _importOldData(self):
# compatability
def unpickleWxFont(*args):
pass
def pickleWxFont(*args):
pass

View file

@ -27,13 +27,7 @@ class DeckBrowser(object):
self.web.setKeyHandler(self._keyHandler) self.web.setKeyHandler(self._keyHandler)
self._setupToolbar() self._setupToolbar()
# refresh or reorder # refresh or reorder
if (time.time() - self._browserLastRefreshed > self._checkDecks()
self.mw.config['deckBrowserRefreshPeriod']):
t = time.time()
self._checkDecks()
print "check decks", time.time() - t
else:
self._reorderDecks()
# show # show
self._renderPage() self._renderPage()

View file

@ -53,15 +53,11 @@ class AnkiQt(QMainWindow):
# if self.config['syncOnProgramOpen']: # if self.config['syncOnProgramOpen']:
# if self.syncDeck(interactive=False): # if self.syncDeck(interactive=False):
# return # return
# load a deck?
if (args or self.config['loadLastDeck'] or # delay load so deck errors don't cause program to close
len(self.config['recentDeckPaths']) == 1): self.progress.timer(10, lambda a=args: \
# delay load so deck errors don't cause program to close self.maybeLoadLastDeck(a),
self.progress.timer(10, lambda a=args: \ False)
self.maybeLoadLastDeck(a),
False)
else:
self.moveToState("deckBrowser")
except: except:
showInfo("Error during startup:\n%s" % traceback.format_exc()) showInfo("Error during startup:\n%s" % traceback.format_exc())
sys.exit(1) sys.exit(1)
@ -343,6 +339,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
r = self.loadDeck(path, showErrors=False) r = self.loadDeck(path, showErrors=False)
if r: if r:
return r return r
self.moveToState("deckBrowser")
# Open recent # Open recent
########################################################################## ##########################################################################