mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
fix closing
This commit is contained in:
parent
47f9b79632
commit
0085c9fc6c
1 changed files with 14 additions and 29 deletions
37
aqt/main.py
37
aqt/main.py
|
@ -100,7 +100,7 @@ class AnkiQt(QMainWindow):
|
|||
f = self.profileForm = aqt.forms.profiles.Ui_Dialog()
|
||||
f.setupUi(d)
|
||||
d.connect(f.login, SIGNAL("clicked()"), self.onOpenProfile)
|
||||
d.connect(f.quit, SIGNAL("clicked()"), lambda: sys.exit(0))
|
||||
d.connect(f.quit, SIGNAL("clicked()"), self.onQuit)
|
||||
d.connect(f.add, SIGNAL("clicked()"), self.onAddProfile)
|
||||
d.connect(f.delete_2, SIGNAL("clicked()"), self.onRemProfile)
|
||||
d.connect(d, SIGNAL("rejected()"), lambda: d.close())
|
||||
|
@ -190,8 +190,6 @@ Are you sure?"""):
|
|||
self.activateWindow()
|
||||
self.raise_()
|
||||
# maybe sync (will load DB)
|
||||
self.pm.profile['syncMedia'] = False
|
||||
self.pm.save()
|
||||
self.onSync(auto=True)
|
||||
# skip the reset step; open overview directly
|
||||
self.moveToState("overview")
|
||||
|
@ -341,7 +339,7 @@ title="%s">%s</button>''' % (
|
|||
self.mainLayout.addWidget(sweb)
|
||||
self.form.centralwidget.setLayout(self.mainLayout)
|
||||
|
||||
def closeAllWindows(self):
|
||||
def closeAllCollectionWindows(self):
|
||||
aqt.dialogs.closeAll()
|
||||
|
||||
# Components
|
||||
|
@ -441,7 +439,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
runHook("deckClosing")
|
||||
#self.col.close()
|
||||
self.backup()
|
||||
self.closeAllWindows()
|
||||
self.closeAllCollectionWindows()
|
||||
self.col.close()
|
||||
self.col = None
|
||||
|
||||
|
@ -454,13 +452,14 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
# Syncing
|
||||
##########################################################################
|
||||
|
||||
def onSync(self, auto=False):
|
||||
def onSync(self, auto=False, reload=True):
|
||||
from aqt.sync import SyncManager
|
||||
# close collection if loaded
|
||||
if self.col:
|
||||
self.col.close()
|
||||
self.syncer = SyncManager(self, self.pm)
|
||||
self.syncer.sync(auto)
|
||||
if reload:
|
||||
self.loadCollection()
|
||||
|
||||
def loadCollection(self):
|
||||
|
@ -519,17 +518,15 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
# App exit
|
||||
##########################################################################
|
||||
|
||||
def onQuit(self):
|
||||
self.app.closeAllWindows()
|
||||
|
||||
def prepareForExit(self):
|
||||
"Save config and window geometry."
|
||||
runHook("quit")
|
||||
self.pm.profile['mainWindowGeom'] = self.saveGeometry()
|
||||
self.pm.profile['mainWindowState'] = self.saveState()
|
||||
# save config
|
||||
try:
|
||||
self.pm.save()
|
||||
except (IOError, OSError), e:
|
||||
showWarning(_("Anki was unable to save your "
|
||||
"configuration file:\n%s" % e))
|
||||
|
||||
def closeEvent(self, event):
|
||||
"User hit the X button, etc."
|
||||
|
@ -538,6 +535,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
# self.showBrowser = False
|
||||
# self.syncDeck(interactive=False)
|
||||
self.prepareForExit()
|
||||
if event:
|
||||
event.accept()
|
||||
self.app.quit()
|
||||
|
||||
|
@ -745,24 +743,11 @@ Please choose a new deck name:"""))
|
|||
# Menu, title bar & status
|
||||
##########################################################################
|
||||
|
||||
deckRelatedMenuItems = (
|
||||
"Add",
|
||||
"Browse",
|
||||
"Undo",
|
||||
"Export",
|
||||
"Stats",
|
||||
"Cstats",
|
||||
"StudyOptions",
|
||||
"Overview",
|
||||
"Groups",
|
||||
"Models",
|
||||
)
|
||||
|
||||
def setupMenus(self):
|
||||
m = self.form
|
||||
s = SIGNAL("triggered()")
|
||||
#self.connect(m.actionDownloadSharedPlugin, s, self.onGetSharedPlugin)
|
||||
self.connect(m.actionExit, s, self, SLOT("close()"))
|
||||
self.connect(m.actionExit, s, self.onQuit)
|
||||
self.connect(m.actionPreferences, s, self.onPrefs)
|
||||
self.connect(m.actionCstats, s, self.onCardStats)
|
||||
self.connect(m.actionAbout, s, self.onAbout)
|
||||
|
@ -807,7 +792,7 @@ This can be because the \
|
|||
clock is slow or fast, because the date is set incorrectly, or because \
|
||||
the timezone or daylight savings information is incorrect. Please correct \
|
||||
the problem and restart Anki.""")
|
||||
sys.exit(0)
|
||||
self.onQuit()
|
||||
|
||||
# Schema modifications
|
||||
##########################################################################
|
||||
|
|
Loading…
Reference in a new issue