Preferences/ShortcutsDialog.py

changeset 7
c679fb30c8f3
parent 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
6:52e8c820d0dd 7:c679fb30c8f3
90 """ 90 """
91 itm = QTreeWidgetItem(category, 91 itm = QTreeWidgetItem(category,
92 [action.iconText(), action.shortcut().toString(), 92 [action.iconText(), action.shortcut().toString(),
93 action.alternateShortcut().toString()]) 93 action.alternateShortcut().toString()])
94 itm.setIcon(0, action.icon()) 94 itm.setIcon(0, action.icon())
95 itm.setData(0, self.objectNameRole, QVariant(action.objectName())) 95 itm.setData(0, self.objectNameRole, action.objectName())
96 itm.setData(0, self.noCheckRole, QVariant(noCheck)) 96 itm.setData(0, self.noCheckRole, noCheck)
97 if objectType: 97 if objectType:
98 itm.setData(0, self.objectTypeRole, QVariant(objectType)) 98 itm.setData(0, self.objectTypeRole, objectType)
99 else: 99 else:
100 itm.setData(0, self.objectTypeRole, QVariant()) 100 itm.setData(0, self.objectTypeRole, None)
101 101
102 def populate(self): 102 def populate(self):
103 """ 103 """
104 Public method to populate the dialog. 104 Public method to populate the dialog.
105 """ 105 """
193 return 193 return
194 194
195 self.__editTopItem = itm.parent() 195 self.__editTopItem = itm.parent()
196 196
197 self.shortcutDialog.setKeys(QKeySequence(itm.text(1)), QKeySequence(itm.text(2)), 197 self.shortcutDialog.setKeys(QKeySequence(itm.text(1)), QKeySequence(itm.text(2)),
198 itm.data(0, self.noCheckRole).toBool(), 198 itm.data(0, self.noCheckRole),
199 itm.data(0, self.objectTypeRole).toString()) 199 itm.data(0, self.objectTypeRole))
200 self.shortcutDialog.show() 200 self.shortcutDialog.show()
201 201
202 def on_shortcutsList_itemClicked(self, itm, column): 202 def on_shortcutsList_itemClicked(self, itm, column):
203 """ 203 """
204 Private slot to handle a click in the shortcuts list. 204 Private slot to handle a click in the shortcuts list.
218 @param itm reference to the item changed (QTreeWidgetItem) 218 @param itm reference to the item changed (QTreeWidgetItem)
219 @param column column changed (integer) 219 @param column column changed (integer)
220 """ 220 """
221 if column != 0: 221 if column != 0:
222 keystr = itm.text(column).title() 222 keystr = itm.text(column).title()
223 if not itm.data(0, self.noCheckRole).toBool() and \ 223 if not itm.data(0, self.noCheckRole) and \
224 not self.__checkShortcut(QKeySequence(keystr), 224 not self.__checkShortcut(QKeySequence(keystr),
225 itm.data(0, self.objectTypeRole).toString(), 225 itm.data(0, self.objectTypeRole),
226 itm.parent()): 226 itm.parent()):
227 itm.setText(column, "") 227 itm.setText(column, "")
228 else: 228 else:
229 itm.setText(column, keystr) 229 itm.setText(column, keystr)
230 self.shortcutsList.closePersistentEditor(itm, column) 230 self.shortcutsList.closePersistentEditor(itm, column)
271 topItem = self.shortcutsList.topLevelItem(topIndex) 271 topItem = self.shortcutsList.topLevelItem(topIndex)
272 for index in range(topItem.childCount()): 272 for index in range(topItem.childCount()):
273 itm = topItem.child(index) 273 itm = topItem.child(index)
274 274
275 # 1. shall a check be performed? 275 # 1. shall a check be performed?
276 if itm.data(0, self.noCheckRole).toBool(): 276 if itm.data(0, self.noCheckRole):
277 continue 277 continue
278 278
279 # 2. check object type 279 # 2. check object type
280 itmObjectType = itm.data(0, self.objectTypeRole).toString() 280 itmObjectType = itm.data(0, self.objectTypeRole)
281 if itmObjectType and \ 281 if itmObjectType and \
282 itmObjectType == objectType and \ 282 itmObjectType == objectType and \
283 topItem != origTopItem: 283 topItem != origTopItem:
284 continue 284 continue
285 285
355 @param category reference to the category item (QTreeWidgetItem) 355 @param category reference to the category item (QTreeWidgetItem)
356 @param actions list of actions for the category (list of E4Action) 356 @param actions list of actions for the category (list of E4Action)
357 """ 357 """
358 for index in range(category.childCount()): 358 for index in range(category.childCount()):
359 itm = category.child(index) 359 itm = category.child(index)
360 ## txt = itm.text(4) # this is one more due to empty last section 360 txt = itm.data(0, self.objectNameRole)
361 txt = itm.data(0, self.objectNameRole).toString()
362 for act in actions: 361 for act in actions:
363 if txt == act.objectName(): 362 if txt == act.objectName():
364 act.setShortcut(QKeySequence(itm.text(1))) 363 act.setShortcut(QKeySequence(itm.text(1)))
365 act.setAlternateShortcut(QKeySequence(itm.text(2))) 364 act.setAlternateShortcut(QKeySequence(itm.text(2)))
366 break 365 break

eric ide

mercurial