src/eric7/Preferences/MouseClickDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 class MouseClickDialog(QDialog, Ui_MouseClickDialog): 18 class MouseClickDialog(QDialog, Ui_MouseClickDialog):
19 """ 19 """
20 Class implementing a dialog for the configuration of a mouse click 20 Class implementing a dialog for the configuration of a mouse click
21 sequence. 21 sequence.
22 """ 22 """
23
23 def __init__(self, modifiers, button, parent=None): 24 def __init__(self, modifiers, button, parent=None):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param modifiers keyboard modifiers of the handler 28 @param modifiers keyboard modifiers of the handler
28 @type Qt.KeyboardModifiers 29 @type Qt.KeyboardModifiers
29 @param button mouse button of the handler 30 @param button mouse button of the handler
30 @type Qt.MouseButton 31 @type Qt.MouseButton
31 @param parent reference to the parent widget 32 @param parent reference to the parent widget
32 @type QWidget 33 @type QWidget
33 """ 34 """
34 super().__init__(parent) 35 super().__init__(parent)
35 self.setupUi(self) 36 self.setupUi(self)
36 self.setModal(True) 37 self.setModal(True)
37 38
38 self.clickGroup.installEventFilter(self) 39 self.clickGroup.installEventFilter(self)
39 self.clearButton.installEventFilter(self) 40 self.clearButton.installEventFilter(self)
40 self.clickEdit.installEventFilter(self) 41 self.clickEdit.installEventFilter(self)
41 42
43 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).installEventFilter(
44 self
45 )
42 self.buttonBox.button( 46 self.buttonBox.button(
43 QDialogButtonBox.StandardButton.Ok).installEventFilter(self) 47 QDialogButtonBox.StandardButton.Cancel
44 self.buttonBox.button( 48 ).installEventFilter(self)
45 QDialogButtonBox.StandardButton.Cancel).installEventFilter(self) 49
46
47 self.__modifiers = modifiers 50 self.__modifiers = modifiers
48 self.__button = button 51 self.__button = button
49 52
50 self.__showClickText() 53 self.__showClickText()
51 54
52 msh = self.minimumSizeHint() 55 msh = self.minimumSizeHint()
53 self.resize(max(self.width(), msh.width()), msh.height()) 56 self.resize(max(self.width(), msh.width()), msh.height())
54 57
55 @pyqtSlot() 58 @pyqtSlot()
56 def on_clearButton_clicked(self): 59 def on_clearButton_clicked(self):
57 """ 60 """
58 Private slot to clear the entered sequence. 61 Private slot to clear the entered sequence.
59 """ 62 """
60 self.__modifiers = Qt.KeyboardModifier.NoModifier 63 self.__modifiers = Qt.KeyboardModifier.NoModifier
61 self.__button = Qt.MouseButton.NoButton 64 self.__button = Qt.MouseButton.NoButton
62 self.__showClickText() 65 self.__showClickText()
63 66
64 def __showClickText(self): 67 def __showClickText(self):
65 """ 68 """
66 Private method to show a string representing the entered mouse click 69 Private method to show a string representing the entered mouse click
67 sequence. 70 sequence.
68 """ 71 """
69 if self.__button == Qt.MouseButton.NoButton: 72 if self.__button == Qt.MouseButton.NoButton:
70 self.clickEdit.setText("") 73 self.clickEdit.setText("")
71 else: 74 else:
72 self.clickEdit.setText(MouseUtilities.MouseButtonModifier2String( 75 self.clickEdit.setText(
73 self.__modifiers, self.__button)) 76 MouseUtilities.MouseButtonModifier2String(
74 77 self.__modifiers, self.__button
78 )
79 )
80
75 def eventFilter(self, watched, event): 81 def eventFilter(self, watched, event):
76 """ 82 """
77 Public method called to filter the event queue. 83 Public method called to filter the event queue.
78 84
79 @param watched reference to the watched object 85 @param watched reference to the watched object
80 @type QObject 86 @type QObject
81 @param event reference to the event that occurred 87 @param event reference to the event that occurred
82 @type QEvent 88 @type QEvent
83 @return flag indicating a handled event 89 @return flag indicating a handled event
84 @rtype bool 90 @rtype bool
85 """ 91 """
86 if ( 92 if event.type() == QEvent.Type.MouseButtonRelease and watched == self.clickEdit:
87 event.type() == QEvent.Type.MouseButtonRelease and
88 watched == self.clickEdit
89 ):
90 self.__modifiers = event.modifiers() 93 self.__modifiers = event.modifiers()
91 self.__button = event.button() 94 self.__button = event.button()
92 self.__showClickText() 95 self.__showClickText()
93 return True 96 return True
94 97
95 return False 98 return False
96 99
97 def getClick(self): 100 def getClick(self):
98 """ 101 """
99 Public method to get the entered mouse click sequence. 102 Public method to get the entered mouse click sequence.
100 103
101 @return tuple containing the modifiers and the mouse button 104 @return tuple containing the modifiers and the mouse button
102 @rtype tuple of Qt.KeyboardModifiers and Qt.MouseButton 105 @rtype tuple of Qt.KeyboardModifiers and Qt.MouseButton
103 """ 106 """
104 return (self.__modifiers, self.__button) 107 return (self.__modifiers, self.__button)

eric ide

mercurial