summaryrefslogtreecommitdiff
path: root/src/leap/baseapp/dialogs.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-06 02:34:40 +0900
committerkali <kali@leap.se>2012-09-06 02:34:40 +0900
commitbd26d30f34104898dd6c5314dee688e27c82529b (patch)
tree226ed4f238369f8937c28e3d0f11258cbfb7b506 /src/leap/baseapp/dialogs.py
parent6ef92e257ce1e605194cb26ff6cb804c7d2c3418 (diff)
parent8148bc9c8c113c41fcb18b397669b1f13447c653 (diff)
Merge branch 'feature/error-handling' into develop
Closes #504: design generic error handling solution. * app-wide logging config. * --logfile command line argument. * created basic exception hierarchy * conductor pushes exceptions to error queue * in Qt, error dialogs are created from exception attributes
Diffstat (limited to 'src/leap/baseapp/dialogs.py')
-rw-r--r--src/leap/baseapp/dialogs.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py
index 4b1b5b62..d4acb09d 100644
--- a/src/leap/baseapp/dialogs.py
+++ b/src/leap/baseapp/dialogs.py
@@ -1,33 +1,47 @@
+import logging
+
from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox)
+logger = logging.getLogger(name=__name__)
+
class ErrorDialog(QDialog):
- def __init__(self, parent=None):
+ 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,
"QMessageBox.warning()", msg,
QMessageBox.NoButton, self)
msgBox.addButton("&Ok", QMessageBox.AcceptRole)
- msgBox.addButton("&Cancel", QMessageBox.RejectRole)
if msgBox.exec_() == QMessageBox.AcceptRole:
- self.warningLabel.setText("Save Again")
- else:
- self.warningLabel.setText("Continue")
+ 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,
"QMessageBox.critical()", msg,
QMessageBox.NoButton, self)
msgBox.addButton("&Ok", QMessageBox.AcceptRole)
- msgBox.addButton("&Cancel", QMessageBox.RejectRole)
- if msgBox.exec_() == QMessageBox.AcceptRole:
- self.warningLabel.setText("Save Again")
- else:
- self.warningLabel.setText("Continue")
+ 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()