--- a/src/eric7/Preferences/MouseClickDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Preferences/MouseClickDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -20,10 +20,11 @@ Class implementing a dialog for the configuration of a mouse click sequence. """ + def __init__(self, modifiers, button, parent=None): """ Constructor - + @param modifiers keyboard modifiers of the handler @type Qt.KeyboardModifiers @param button mouse button of the handler @@ -34,24 +35,26 @@ super().__init__(parent) self.setupUi(self) self.setModal(True) - + self.clickGroup.installEventFilter(self) self.clearButton.installEventFilter(self) self.clickEdit.installEventFilter(self) - + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).installEventFilter( + self + ) self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).installEventFilter(self) - self.buttonBox.button( - QDialogButtonBox.StandardButton.Cancel).installEventFilter(self) - + QDialogButtonBox.StandardButton.Cancel + ).installEventFilter(self) + self.__modifiers = modifiers self.__button = button - + self.__showClickText() - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot() def on_clearButton_clicked(self): """ @@ -60,7 +63,7 @@ self.__modifiers = Qt.KeyboardModifier.NoModifier self.__button = Qt.MouseButton.NoButton self.__showClickText() - + def __showClickText(self): """ Private method to show a string representing the entered mouse click @@ -69,13 +72,16 @@ if self.__button == Qt.MouseButton.NoButton: self.clickEdit.setText("") else: - self.clickEdit.setText(MouseUtilities.MouseButtonModifier2String( - self.__modifiers, self.__button)) - + self.clickEdit.setText( + MouseUtilities.MouseButtonModifier2String( + self.__modifiers, self.__button + ) + ) + def eventFilter(self, watched, event): """ Public method called to filter the event queue. - + @param watched reference to the watched object @type QObject @param event reference to the event that occurred @@ -83,21 +89,18 @@ @return flag indicating a handled event @rtype bool """ - if ( - event.type() == QEvent.Type.MouseButtonRelease and - watched == self.clickEdit - ): + if event.type() == QEvent.Type.MouseButtonRelease and watched == self.clickEdit: self.__modifiers = event.modifiers() self.__button = event.button() self.__showClickText() return True - + return False - + def getClick(self): """ Public method to get the entered mouse click sequence. - + @return tuple containing the modifiers and the mouse button @rtype tuple of Qt.KeyboardModifiers and Qt.MouseButton """