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