Preferences/ConfigurationDialog.py

changeset 1791
3e946bfda98a
parent 1789
ebf61384cfdb
child 1964
6a6a53f2d086
child 2303
0ed4ed026c16
--- a/Preferences/ConfigurationDialog.py	Sun Apr 15 11:29:32 2012 +0200
+++ b/Preferences/ConfigurationDialog.py	Sun Apr 15 12:58:17 2012 +0200
@@ -62,9 +62,13 @@
     @signal preferencesChanged() emitted after settings have been changed
     @signal masterPasswordChanged(str, str) emitted after the master
         password has been changed with the old and the new password
+    @signal accepted() emitted to indicate acceptance of the changes
+    @signal rejected() emitted to indicate rejection of the changes
     """
     preferencesChanged = pyqtSignal()
     masterPasswordChanged = pyqtSignal(str, str)
+    accepted = pyqtSignal()
+    rejected = pyqtSignal()
     
     DefaultMode = 0
     HelpBrowserMode = 1
@@ -358,10 +362,22 @@
         
         self.configList.itemActivated.connect(self.__showConfigurationPage)
         self.configList.itemClicked.connect(self.__showConfigurationPage)
+        self.buttonBox.accepted.connect(self.accept)
+        self.buttonBox.rejected.connect(self.rejected)
         
         if displayMode != ConfigurationWidget.TrayStarterMode:
             self.__initLexers()
         
+    def accept(self):
+        """
+        Public slot to accept the buttonBox accept signal.
+        """
+        wdg = self.focusWidget()
+        if wdg == self.configList:
+            return
+        
+        self.accepted.emit()
+        
     def __setupUi(self):
         """
         Private method to perform the general setup of the configuration widget.
@@ -689,8 +705,8 @@
         self.layout.addWidget(self.cw)
         self.resize(size)
         
-        self.cw.buttonBox.accepted[()].connect(self.accept)
-        self.cw.buttonBox.rejected[()].connect(self.reject)
+        self.cw.accepted[()].connect(self.accept)
+        self.cw.rejected[()].connect(self.reject)
         self.cw.preferencesChanged.connect(self.__preferencesChanged)
         self.cw.masterPasswordChanged.connect(self.__masterPasswordChanged)
         
@@ -730,6 +746,9 @@
         Public method called to store the selected values into the preferences storage.
         """
         self.cw.setPreferences()
+    
+    def accept(self):
+        super().accept()
 
 
 class ConfigurationWindow(QMainWindow):
@@ -749,8 +768,8 @@
         self.setCentralWidget(self.cw)
         self.resize(size)
         
-        self.cw.buttonBox.accepted[()].connect(self.accept)
-        self.cw.buttonBox.rejected[()].connect(self.close)
+        self.cw.accepted[()].connect(self.accept)
+        self.cw.rejected[()].connect(self.close)
         
     def showConfigurationPageByName(self, pageName):
         """

eric ide

mercurial