--- a/Preferences/ShortcutsDialog.py Tue Oct 15 22:03:54 2013 +0200 +++ b/Preferences/ShortcutsDialog.py Fri Oct 18 23:00:41 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing a dialog for the configuration of eric5s keyboard shortcuts. +Module implementing a dialog for the configuration of eric5's keyboard +shortcuts. """ from __future__ import unicode_literals # __IGNORE_WARNING__ @@ -23,9 +24,11 @@ class ShortcutsDialog(QDialog, Ui_ShortcutsDialog): """ - Class implementing a dialog for the configuration of eric5s keyboard shortcuts. + Class implementing a dialog for the configuration of eric5's keyboard + shortcuts. - @signal updateShortcuts() emitted when the user pressed the dialogs OK button + @signal updateShortcuts() emitted when the user pressed the dialogs OK + button """ updateShortcuts = pyqtSignal() @@ -47,7 +50,8 @@ self.setModal(modal) self.setupUi(self) - self.shortcutsList.headerItem().setText(self.shortcutsList.columnCount(), "") + self.shortcutsList.headerItem().setText( + self.shortcutsList.columnCount(), "") self.shortcutsList.header().setSortIndicator(0, Qt.AscendingOrder) from .ShortcutDialog import ShortcutDialog @@ -65,7 +69,8 @@ """ Private method to resize the list columns. """ - self.shortcutsList.header().resizeSections(QHeaderView.ResizeToContents) + self.shortcutsList.header().resizeSections( + QHeaderView.ResizeToContents) self.shortcutsList.header().setStretchLastSection(True) def __generateCategoryItem(self, title): @@ -88,8 +93,8 @@ @param action reference to the keyboard action (E5Action) @keyparam noCheck flag indicating that no uniqueness check should be performed (boolean) - @keyparam objectType type of the object (string). Objects of the same type - are not checked for duplicate shortcuts. + @keyparam objectType type of the object (string). Objects of the same + type are not checked for duplicate shortcuts. """ itm = QTreeWidgetItem(category, [action.iconText(), action.shortcut().toString(), @@ -152,17 +157,20 @@ for act in e5App().getObject("ViewManager").getActions('macro'): self.__generateShortcutItem(self.macroItem, act) - self.bookmarkItem = self.__generateCategoryItem(self.trUtf8("Bookmarks")) + self.bookmarkItem = self.__generateCategoryItem( + self.trUtf8("Bookmarks")) for act in e5App().getObject("ViewManager").getActions('bookmark'): self.__generateShortcutItem(self.bookmarkItem, act) - self.spellingItem = self.__generateCategoryItem(self.trUtf8("Spelling")) + self.spellingItem = self.__generateCategoryItem( + self.trUtf8("Spelling")) for act in e5App().getObject("ViewManager").getActions('spelling'): self.__generateShortcutItem(self.spellingItem, act) actions = e5App().getObject("ViewManager").getActions('window') if actions: - self.windowItem = self.__generateCategoryItem(self.trUtf8("Window")) + self.windowItem = self.__generateCategoryItem( + self.trUtf8("Window")) for act in actions: self.__generateShortcutItem(self.windowItem, act) @@ -198,7 +206,9 @@ self.__editTopItem = itm.parent() - self.shortcutDialog.setKeys(QKeySequence(itm.text(1)), QKeySequence(itm.text(2)), + self.shortcutDialog.setKeys( + QKeySequence(itm.text(1)), + QKeySequence(itm.text(2)), itm.data(0, self.noCheckRole), itm.data(0, self.objectTypeRole)) self.shortcutDialog.show() @@ -233,9 +243,11 @@ itm.setText(column, keystr) self.shortcutsList.closePersistentEditor(itm, column) - def __shortcutChanged(self, keysequence, altKeysequence, noCheck, objectType): + def __shortcutChanged(self, keysequence, altKeysequence, noCheck, + objectType): """ - Private slot to handle the shortcutChanged signal of the shortcut dialog. + Private slot to handle the shortcutChanged signal of the shortcut + dialog. @param keysequence the keysequence of the changed action (QKeySequence) @param altKeysequence the alternative keysequence of the changed @@ -245,8 +257,10 @@ @param objectType type of the object (string). """ if not noCheck and \ - (not self.__checkShortcut(keysequence, objectType, self.__editTopItem) or \ - not self.__checkShortcut(altKeysequence, objectType, self.__editTopItem)): + (not self.__checkShortcut( + keysequence, objectType, self.__editTopItem) or \ + not self.__checkShortcut( + altKeysequence, objectType, self.__editTopItem)): return self.shortcutsList.currentItem().setText(1, keysequence.toString()) @@ -289,15 +303,16 @@ # 3. check key name if itm.text(0) != keyname: - for col in [1, 2]: # check against primary, then alternative binding + for col in [1, 2]: # check against primary, + # then alternative binding itmseq = itm.text(col) # step 1: check if shortcut is already allocated if keystr == itmseq: res = E5MessageBox.yesNo(self, self.trUtf8("Edit shortcuts"), self.trUtf8( - """<p><b>{0}</b> has already been allocated""" - """ to the <b>{1}</b> action. """ + """<p><b>{0}</b> has already been""" + """ allocated to the <b>{1}</b> action. """ """Remove this binding?</p>""") .format(keystr, itm.text(0)), icon=E5MessageBox.Warning) @@ -315,8 +330,8 @@ res = E5MessageBox.yesNo(self, self.trUtf8("Edit shortcuts"), self.trUtf8( - """<p><b>{0}</b> hides the <b>{1}</b> action. """ - """Remove this binding?</p>""") + """<p><b>{0}</b> hides the <b>{1}</b>""" + """ action. Remove this binding?</p>""") .format(keystr, itm.text(0)), icon=E5MessageBox.Warning) if res: @@ -325,7 +340,8 @@ else: return False - # step 3: check if shortcut is hidden by an already allocated + # step 3: check if shortcut is hidden by an + # already allocated if keystr.startswith("{0}+".format(itmseq)): res = E5MessageBox.yesNo(self, self.trUtf8("Edit shortcuts"), @@ -356,7 +372,8 @@ for act in actions: if txt == act.objectName(): act.setShortcut(QKeySequence(itm.text(1))) - act.setAlternateShortcut(QKeySequence(itm.text(2)), removeEmpty=True) + act.setAlternateShortcut( + QKeySequence(itm.text(2)), removeEmpty=True) break def on_buttonBox_accepted(self): @@ -418,7 +435,8 @@ for index in range(topItem.childCount()): itm = topItem.child(index) if (self.actionButton.isChecked() and \ - not QRegExp(txt, Qt.CaseInsensitive).indexIn(itm.text(0)) > -1) or \ + not QRegExp(txt, Qt.CaseInsensitive).indexIn(itm.text(0)) > + -1) or \ (self.shortcutButton.isChecked() and \ not txt.lower() in itm.text(1).lower() and \ not txt.lower() in itm.text(2).lower()):