mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
modal info dialogs
This commit is contained in:
parent
04ffba2495
commit
ae9a21167b
2 changed files with 18 additions and 12 deletions
|
@ -151,7 +151,7 @@ class AnkiQt(QMainWindow):
|
|||
return
|
||||
self.web.setKeyHandler(None)
|
||||
self.web.setLinkHandler(lambda url: self.maybeReset())
|
||||
i = _("Close the editing window to resume.")
|
||||
i = _("Close the browser to resume.")
|
||||
b = self.button("refresh", _("Resume Now"))
|
||||
self.web.stdHtml("""
|
||||
<center><div style="height: 100%%">
|
||||
|
|
28
aqt/utils.py
28
aqt/utils.py
|
@ -19,21 +19,27 @@ 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):
|
||||
def showInfo(text, parent=None, help="", type="info"):
|
||||
"Show a small info window with an OK button."
|
||||
if not parent:
|
||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||
if not func:
|
||||
func = QMessageBox.information
|
||||
sb = QMessageBox.Ok
|
||||
if help:
|
||||
sb |= QMessageBox.Help
|
||||
while 1:
|
||||
ret = func(parent, "Anki", text, sb)
|
||||
if ret == QMessageBox.Help:
|
||||
aqt.openHelp(help)
|
||||
if type == "warning":
|
||||
icon = QMessageBox.Warning
|
||||
elif type == "critical":
|
||||
icon = QMessageBox.Critical
|
||||
else:
|
||||
break
|
||||
icon = QMessageBox.Information
|
||||
mb = QMessageBox(parent)
|
||||
mb.setText(text)
|
||||
mb.setIcon(icon)
|
||||
mb.setWindowModality(Qt.WindowModal)
|
||||
b = mb.addButton(QMessageBox.Ok)
|
||||
b.setDefault(True)
|
||||
if help:
|
||||
b = mb.addButton(QMessageBox.Help)
|
||||
b.connect(b, SIGNAL("clicked()"), lambda: aqt.openHelp(help))
|
||||
b.setAutoDefault(False)
|
||||
return mb.exec_()
|
||||
|
||||
def showText(txt, parent=None, type="text"):
|
||||
if not parent:
|
||||
|
|
Loading…
Reference in a new issue