diff options
author | kali <kali@leap.se> | 2013-02-15 09:31:51 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-02-15 09:31:51 +0900 |
commit | 9cea9c8a34343f8792d65b96f93ae22bd8685878 (patch) | |
tree | 9f512367b1d47ced5614702a00f3ff0a8fe746d7 /src/leap/baseapp/dialogs.py | |
parent | 7159734ec6c0b76fc7f3737134cd22fdaaaa7d58 (diff) | |
parent | 1032e07a50c8bb265ff9bd31b3bb00e83ddb451e (diff) |
Merge branch 'release/v0.2.0'
Conflicts:
README.txt
Diffstat (limited to 'src/leap/baseapp/dialogs.py')
-rw-r--r-- | src/leap/baseapp/dialogs.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py new file mode 100644 index 00000000..d256fc99 --- /dev/null +++ b/src/leap/baseapp/dialogs.py @@ -0,0 +1,61 @@ +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 +import logging + +from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox) + +logger = logging.getLogger(name=__name__) + + +class ErrorDialog(QDialog): + def __init__(self, parent=None, errtype=None, msg=None, label=None): + super(ErrorDialog, self).__init__(parent) + frameStyle = QFrame.Sunken | QFrame.Panel + self.warningLabel = QLabel() + self.warningLabel.setFrameStyle(frameStyle) + self.warningButton = QPushButton("QMessageBox.&warning()") + + if msg is not None: + self.msg = msg + if label is not None: + self.label = label + if errtype == "critical": + self.criticalMessage(self.msg, self.label) + + def warningMessage(self, msg, label): + msgBox = QMessageBox(QMessageBox.Warning, + "LEAP Client Error", + msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + if msgBox.exec_() == QMessageBox.AcceptRole: + pass + # do whatever we want to do after + # closing the dialog. we can pass that + # in the constructor + + def criticalMessage(self, msg, label): + msgBox = QMessageBox(QMessageBox.Critical, + "LEAP Client Error", + msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + msgBox.exec_() + + # It's critical, so we exit. + # We should better emit a signal and connect it + # with the proper shutdownAndQuit method, but + # this suffices for now. + logger.info('Quitting') + import sys + sys.exit() + + def confirmMessage(self, msg, label, action): + msgBox = QMessageBox(QMessageBox.Critical, + self.tr("LEAP Client Error"), + msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + msgBox.addButton("&Cancel", QMessageBox.RejectRole) + + if msgBox.exec_() == QMessageBox.AcceptRole: + action() |