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