~ubuntu-branches/ubuntu/utopic/anki/utopic

« back to all changes in this revision

Viewing changes to .pc/no-version-nag/aqt/main.py

  • Committer: Package Import Robot
  • Author(s): Andreas Bombe
  • Date: 2014-05-11 17:13:36 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140511171336-2vxrcfclmfjedas2
Tags: 2.0.26+dfsg-1
ImportedĀ UpstreamĀ versionĀ 2.0.26+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import re
6
6
import signal
7
 
import  zipfile
 
7
import zipfile
8
8
 
9
9
from send2trash import send2trash
10
10
from aqt.qt import *
63
63
            self.onAppMsg(unicode(args[0], sys.getfilesystemencoding(), "ignore"))
64
64
        # Load profile in a timer so we can let the window finish init and not
65
65
        # close on profile load error.
 
66
        if isMac and qtmajor >= 5:
 
67
            self.show()
66
68
        self.progress.timer(10, self.setupProfile, False)
67
69
 
68
70
    def setupUI(self):
264
266
 
265
267
    def loadCollection(self):
266
268
        self.hideSchemaMsg = True
 
269
        cpath = self.pm.collectionPath()
267
270
        try:
268
 
            self.col = Collection(self.pm.collectionPath(), log=True)
 
271
            self.col = Collection(cpath, log=True)
269
272
        except anki.db.Error:
270
 
            # move back to profile manager
 
273
            # warn user
271
274
            showWarning("""\
272
275
Your collection is corrupt. Please see the manual for \
273
276
how to restore from a backup.""")
274
 
            self.unloadProfile()
275
 
            raise
 
277
            # move it out of the way so the profile can be used again
 
278
            newpath = cpath+str(intTime())
 
279
            os.rename(cpath, newpath)
 
280
            # then close
 
281
            sys.exit(1)
276
282
        except Exception, e:
277
283
            # the custom exception handler won't catch this if we immediately
278
284
            # unload, so we have to manually handle it
377
383
        if cleanup:
378
384
            cleanup(state)
379
385
        self.state = state
 
386
        runHook('beforeStateChange', state, oldState, *args)
380
387
        getattr(self, "_"+state+"State")(oldState, *args)
 
388
        runHook('afterStateChange', state, oldState, *args)
381
389
 
382
390
    def _deckBrowserState(self, oldState):
383
391
        self.deckBrowser.show()
405
413
 
406
414
    def _reviewState(self, oldState):
407
415
        self.reviewer.show()
 
416
        self.web.setCanFocus(True)
408
417
 
409
418
    def _reviewCleanup(self, newState):
410
419
        if newState != "resetRequired" and newState != "review":
411
420
            self.reviewer.cleanup()
 
421
            self.web.setCanFocus(False)
412
422
 
413
423
    def noteChanged(self, nid):
414
424
        "Called when a card or note is edited (but not deleted)."
504
514
        self.toolbar = aqt.toolbar.Toolbar(self, tweb)
505
515
        self.toolbar.draw()
506
516
        # main area
507
 
        self.web = aqt.webview.AnkiWebView()
 
517
        self.web = aqt.webview.AnkiWebView(canFocus=True)
508
518
        self.web.setObjectName("mainText")
509
519
        self.web.setFocusPolicy(Qt.WheelFocus)
510
520
        self.web.setMinimumWidth(400)