Added the function to close the unit test dialog by pressing the Esc key. 5_1_x

Sat, 10 Dec 2011 13:59:28 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 10 Dec 2011 13:59:28 +0100
branch
5_1_x
changeset 1485
b0d0ddac7012
parent 1484
ceb1e3cea618
child 1487
000d35ce20b6

Added the function to close the unit test dialog by pressing the Esc key.
(transplanted from eebaadaee21e78281a51a179094d6f86bf90c0a8)

PyUnit/UnittestDialog.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
--- a/PyUnit/UnittestDialog.py	Sat Dec 10 14:01:44 2011 +0100
+++ b/PyUnit/UnittestDialog.py	Sat Dec 10 13:59:28 2011 +0100
@@ -38,14 +38,17 @@
     """
     unittestFile = pyqtSignal(str, int, int)
     
-    def __init__(self,prog = None,dbs = None,ui = None,parent = None,name = None):
+    def __init__(self, prog = None, dbs = None, ui = None, fromEric = False,
+                 parent = None, name = None):
         """
         Constructor
         
         @param prog filename of the program to open
         @param dbs reference to the debug server object. It is an indication
-                whether we were called from within the eric5 IDE
+            whether we were called from within the eric5 IDE
         @param ui reference to the UI object
+        @param fromEric flag indicating an instantiation from within the
+            eric IDE (boolean)
         @param parent parent widget of this dialog (QWidget)
         @param name name of this dialog (string)
         """
@@ -70,6 +73,7 @@
         self.startButton.setDefault(True)
         
         self.dbs = dbs
+        self.__fromEric = fromEric
         
         self.setWindowFlags(
             self.windowFlags() | Qt.WindowFlags(Qt.WindowContextHelpButtonHint))
@@ -104,7 +108,16 @@
             self.dbs.utStopTest.connect(self.testFinished)
             self.dbs.utTestFailed.connect(self.testFailed)
             self.dbs.utTestErrored.connect(self.testErrored)
+    
+    def keyPressEvent(self, evt):
+        """
+        Protected slot to handle key press events.
         
+        @param evt key press event to handle (QKeyEvent)
+        """
+        if evt.key() == Qt.Key_Escape and self.__fromEric:
+            self.close()
+    
     def __setProgressColor(self, color):
         """
         Private methode to set the color of the progress color label.
--- a/UI/UserInterface.py	Sat Dec 10 14:01:44 2011 +0100
+++ b/UI/UserInterface.py	Sat Dec 10 13:59:28 2011 +0100
@@ -441,7 +441,8 @@
         self.numbersViewer.insertNumber.connect(self.viewmanager.insertNumber)
         
         # Generate the unittest dialog
-        self.unittestDialog = UnittestDialog(None, self.debuggerUI.debugServer, self)
+        self.unittestDialog = UnittestDialog(None, self.debuggerUI.debugServer, self,
+                                             fromEric=True)
         self.unittestDialog.unittestFile.connect(self.viewmanager.setFileLine)
         
         # Generate the find in project files dialog

eric ide

mercurial