48 self.shortcutsGroup.installEventFilter(self) |
48 self.shortcutsGroup.installEventFilter(self) |
49 self.primaryButton.installEventFilter(self) |
49 self.primaryButton.installEventFilter(self) |
50 self.alternateButton.installEventFilter(self) |
50 self.alternateButton.installEventFilter(self) |
51 self.primaryClearButton.installEventFilter(self) |
51 self.primaryClearButton.installEventFilter(self) |
52 self.alternateClearButton.installEventFilter(self) |
52 self.alternateClearButton.installEventFilter(self) |
|
53 self.keyEdit.installEventFilter(self) |
|
54 self.alternateKeyEdit.installEventFilter(self) |
53 |
55 |
54 self.buttonBox.button(QDialogButtonBox.Ok).installEventFilter(self) |
56 self.buttonBox.button(QDialogButtonBox.Ok).installEventFilter(self) |
55 self.buttonBox.button(QDialogButtonBox.Cancel).installEventFilter(self) |
57 self.buttonBox.button(QDialogButtonBox.Cancel).installEventFilter(self) |
56 |
58 |
57 def setKeys(self, key, alternateKey, noCheck, objectType): |
59 def setKeys(self, key, alternateKey, noCheck, objectType): |
64 be performed (boolean) |
66 be performed (boolean) |
65 @param objectType type of the object (string). |
67 @param objectType type of the object (string). |
66 """ |
68 """ |
67 self.keyIndex = 0 |
69 self.keyIndex = 0 |
68 self.keys = [0, 0, 0, 0] |
70 self.keys = [0, 0, 0, 0] |
69 self.keyLabel.setText(key.toString()) |
71 self.keyEdit.setText(key.toString()) |
70 self.alternateKeyLabel.setText(alternateKey.toString()) |
72 self.alternateKeyEdit.setText(alternateKey.toString()) |
71 self.primaryButton.setChecked(True) |
73 self.primaryButton.setChecked(True) |
72 self.noCheck = noCheck |
74 self.noCheck = noCheck |
73 self.objectType = objectType |
75 self.objectType = objectType |
74 |
76 |
75 def on_buttonBox_accepted(self): |
77 def on_buttonBox_accepted(self): |
76 """ |
78 """ |
77 Private slot to handle the OK button press. |
79 Private slot to handle the OK button press. |
78 """ |
80 """ |
79 self.hide() |
81 self.hide() |
80 self.shortcutChanged.emit( |
82 self.shortcutChanged.emit( |
81 QKeySequence(self.keyLabel.text()), |
83 QKeySequence(self.keyEdit.text()), |
82 QKeySequence(self.alternateKeyLabel.text()), |
84 QKeySequence(self.alternateKeyEdit.text()), |
83 self.noCheck, self.objectType) |
85 self.noCheck, self.objectType) |
84 |
86 |
85 def __clear(self): |
87 def __clear(self): |
86 """ |
88 """ |
87 Private slot to handle the Clear button press. |
89 Private slot to handle the Clear button press. |
88 """ |
90 """ |
89 self.keyIndex = 0 |
91 self.keyIndex = 0 |
90 self.keys = [0, 0, 0, 0] |
92 self.keys = [0, 0, 0, 0] |
91 self.__setKeyLabelText("") |
93 self.__setKeyEditText("") |
92 |
94 |
93 def __typeChanged(self): |
95 def __typeChanged(self): |
94 """ |
96 """ |
95 Private slot to handle the change of the shortcuts type. |
97 Private slot to handle the change of the shortcuts type. |
96 """ |
98 """ |
97 self.keyIndex = 0 |
99 self.keyIndex = 0 |
98 self.keys = [0, 0, 0, 0] |
100 self.keys = [0, 0, 0, 0] |
99 |
101 |
100 def __setKeyLabelText(self, txt): |
102 def __setKeyEditText(self, txt): |
101 """ |
103 """ |
102 Private method to set the text of a key label. |
104 Private method to set the text of a key label. |
103 |
105 |
104 @param txt text to be set (string) |
106 @param txt text to be set (string) |
105 """ |
107 """ |
106 if self.primaryButton.isChecked(): |
108 if self.primaryButton.isChecked(): |
107 self.keyLabel.setText(txt) |
109 self.keyEdit.setText(txt) |
108 else: |
110 else: |
109 self.alternateKeyLabel.setText(txt) |
111 self.alternateKeyEdit.setText(txt) |
110 |
112 |
111 def eventFilter(self, watched, event): |
113 def eventFilter(self, watched, event): |
112 """ |
114 """ |
113 Method called to filter the event queue. |
115 Method called to filter the event queue. |
114 |
116 |
158 self.keys[self.keyIndex] += Qt.META |
160 self.keys[self.keyIndex] += Qt.META |
159 |
161 |
160 self.keyIndex += 1 |
162 self.keyIndex += 1 |
161 |
163 |
162 if self.keyIndex == 1: |
164 if self.keyIndex == 1: |
163 self.__setKeyLabelText(QKeySequence(self.keys[0]).toString()) |
165 self.__setKeyEditText(QKeySequence(self.keys[0]).toString()) |
164 elif self.keyIndex == 2: |
166 elif self.keyIndex == 2: |
165 self.__setKeyLabelText(QKeySequence(self.keys[0], self.keys[1]).toString()) |
167 self.__setKeyEditText(QKeySequence(self.keys[0], self.keys[1]).toString()) |
166 elif self.keyIndex == 3: |
168 elif self.keyIndex == 3: |
167 self.__setKeyLabelText(QKeySequence(self.keys[0], self.keys[1], |
169 self.__setKeyEditText(QKeySequence(self.keys[0], self.keys[1], |
168 self.keys[2]).toString()) |
170 self.keys[2]).toString()) |
169 elif self.keyIndex == 4: |
171 elif self.keyIndex == 4: |
170 self.__setKeyLabelText(QKeySequence(self.keys[0], self.keys[1], |
172 self.__setKeyEditText(QKeySequence(self.keys[0], self.keys[1], |
171 self.keys[2], self.keys[3]).toString()) |
173 self.keys[2], self.keys[3]).toString()) |