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
|
return
|
||||||
self.web.setKeyHandler(None)
|
self.web.setKeyHandler(None)
|
||||||
self.web.setLinkHandler(lambda url: self.maybeReset())
|
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"))
|
b = self.button("refresh", _("Resume Now"))
|
||||||
self.web.stdHtml("""
|
self.web.stdHtml("""
|
||||||
<center><div style="height: 100%%">
|
<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."
|
"Show a small critical error with an OK button."
|
||||||
return showInfo(text, parent, help, QMessageBox.critical)
|
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."
|
"Show a small info window with an OK button."
|
||||||
if not parent:
|
if not parent:
|
||||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||||
if not func:
|
if type == "warning":
|
||||||
func = QMessageBox.information
|
icon = QMessageBox.Warning
|
||||||
sb = QMessageBox.Ok
|
elif type == "critical":
|
||||||
|
icon = QMessageBox.Critical
|
||||||
|
else:
|
||||||
|
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:
|
if help:
|
||||||
sb |= QMessageBox.Help
|
b = mb.addButton(QMessageBox.Help)
|
||||||
while 1:
|
b.connect(b, SIGNAL("clicked()"), lambda: aqt.openHelp(help))
|
||||||
ret = func(parent, "Anki", text, sb)
|
b.setAutoDefault(False)
|
||||||
if ret == QMessageBox.Help:
|
return mb.exec_()
|
||||||
aqt.openHelp(help)
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
def showText(txt, parent=None, type="text"):
|
def showText(txt, parent=None, type="text"):
|
||||||
if not parent:
|
if not parent:
|
||||||
|
|
Loading…
Reference in a new issue