mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -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:
|
||||
if hasattr(e, 'data') and e.data.get('type') == 'inuse':
|
||||
if interactive:
|
||||
ui.utils.showInfo(_("Deck is already open."))
|
||||
ui.utils.showWarning(_("Deck is already open."))
|
||||
else:
|
||||
return
|
||||
elif hasattr(e, 'data') and e.data.get('type') == 'corrupt':
|
||||
ui.utils.showCritical(_("\
|
||||
File is corrupt.\nPlease restore from backup."), help="DeckErrors")
|
||||
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()
|
||||
ui.utils.showCritical(_("""\
|
||||
File is corrupt or not an Anki database."""), help="DeckErrors")
|
||||
self.moveToState("noDeck")
|
||||
return
|
||||
return 0
|
||||
if media is not None:
|
||||
self.deck.forceMediaDir = media
|
||||
if uprecent:
|
||||
|
|
|
@ -17,21 +17,25 @@ def openLink(link):
|
|||
def openWikiLink(page):
|
||||
openLink(ankiqt.appWiki + page)
|
||||
|
||||
def showWarning(text, parent=None):
|
||||
def showWarning(text, parent=None, help=""):
|
||||
"Show a small warning with an OK button."
|
||||
if not parent:
|
||||
parent = ankiqt.mw
|
||||
QMessageBox.warning(parent, "Anki", text)
|
||||
return showInfo(text, parent, help, QMessageBox.warning)
|
||||
|
||||
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."
|
||||
if not parent:
|
||||
parent = ankiqt.mw
|
||||
if not func:
|
||||
func = QMessageBox.information
|
||||
sb = QMessageBox.Ok
|
||||
if help:
|
||||
sb |= QMessageBox.Help
|
||||
while 1:
|
||||
ret = QMessageBox.information(parent, "Anki", text, sb)
|
||||
ret = func(parent, "Anki", text, sb)
|
||||
if ret == QMessageBox.Help:
|
||||
openWikiLink(help)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue