mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
unify deck load messages, add help, add critical msg box func
This commit is contained in:
parent
ba3298cf3b
commit
87d976a547
2 changed files with 19 additions and 22 deletions
|
@ -679,24 +679,17 @@ new:
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if hasattr(e, 'data') and e.data.get('type') == 'inuse':
|
if hasattr(e, 'data') and e.data.get('type') == 'inuse':
|
||||||
if interactive:
|
if interactive:
|
||||||
ui.utils.showInfo(_("Deck is already open."))
|
ui.utils.showWarning(_("Deck is already open."))
|
||||||
else:
|
else:
|
||||||
fmt = traceback.format_exc().split("\n")
|
|
||||||
fmt1 = "\n".join(fmt[0:3])
|
|
||||||
fmt2 = "\n".join(fmt[-3:])
|
|
||||||
ui.utils.showInfo(_("""\
|
|
||||||
Unable to load deck.
|
|
||||||
|
|
||||||
Possible reasons:
|
|
||||||
- file is not an Anki deck
|
|
||||||
- deck is read only
|
|
||||||
- directory is read only
|
|
||||||
- deck was created with Anki < 0.9
|
|
||||||
|
|
||||||
To upgrade an old deck, download Anki 0.9.8.7."""))
|
|
||||||
traceback.print_exc()
|
|
||||||
self.moveToState("noDeck")
|
|
||||||
return
|
return
|
||||||
|
elif hasattr(e, 'data') and e.data.get('type') == 'corrupt':
|
||||||
|
ui.utils.showCritical(_("\
|
||||||
|
File is corrupt.\nPlease restore from backup."), help="DeckErrors")
|
||||||
|
else:
|
||||||
|
ui.utils.showCritical(_("""\
|
||||||
|
File is corrupt or not an Anki database."""), help="DeckErrors")
|
||||||
|
self.moveToState("noDeck")
|
||||||
|
return 0
|
||||||
if media is not None:
|
if media is not None:
|
||||||
self.deck.forceMediaDir = media
|
self.deck.forceMediaDir = media
|
||||||
if uprecent:
|
if uprecent:
|
||||||
|
|
|
@ -17,21 +17,25 @@ def openLink(link):
|
||||||
def openWikiLink(page):
|
def openWikiLink(page):
|
||||||
openLink(ankiqt.appWiki + page)
|
openLink(ankiqt.appWiki + page)
|
||||||
|
|
||||||
def showWarning(text, parent=None):
|
def showWarning(text, parent=None, help=""):
|
||||||
"Show a small warning with an OK button."
|
"Show a small warning with an OK button."
|
||||||
if not parent:
|
return showInfo(text, parent, help, QMessageBox.warning)
|
||||||
parent = ankiqt.mw
|
|
||||||
QMessageBox.warning(parent, "Anki", text)
|
|
||||||
|
|
||||||
def showInfo(text, parent=None, help=""):
|
def showCritical(text, parent=None, help=""):
|
||||||
|
"Show a small critical error with an OK button."
|
||||||
|
return showInfo(text, parent, help, QMessageBox.critical)
|
||||||
|
|
||||||
|
def showInfo(text, parent=None, help="", func=None):
|
||||||
"Show a small info window with an OK button."
|
"Show a small info window with an OK button."
|
||||||
if not parent:
|
if not parent:
|
||||||
parent = ankiqt.mw
|
parent = ankiqt.mw
|
||||||
|
if not func:
|
||||||
|
func = QMessageBox.information
|
||||||
sb = QMessageBox.Ok
|
sb = QMessageBox.Ok
|
||||||
if help:
|
if help:
|
||||||
sb |= QMessageBox.Help
|
sb |= QMessageBox.Help
|
||||||
while 1:
|
while 1:
|
||||||
ret = QMessageBox.information(parent, "Anki", text, sb)
|
ret = func(parent, "Anki", text, sb)
|
||||||
if ret == QMessageBox.Help:
|
if ret == QMessageBox.Help:
|
||||||
openWikiLink(help)
|
openWikiLink(help)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue