diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py index e723acb5e9..277c45db3a 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py @@ -62,6 +62,12 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): hh.sectionClicked.connect(self.do_sort) hh.setSortIndicatorShown(True) + self.delete_button.clicked.connect(self.delete_rule) + self.undo_button.clicked.connect(self.undo_delete) + + self.tb_icon_rules_groupbox.setContentsMargins(0, 0, 0, 0) + self.tb_icon_rules_gridlayout.setContentsMargins(2, 2, 2, 2) + v = gprefs['tags_browser_value_icons'] row = 0 for category,vdict in v.items(): @@ -112,6 +118,27 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form): item.is_deleted = action == 'delete' self.changed_signal.emit() + def keyPressEvent(self, ev): + if ev.key() == Qt.Key.Key_Delete: + self.delete_rule() + ev.accept() + return + return super().keyPressEvent(ev) + + def delete_rule(self): + idx = self.rules_table.currentIndex() + if idx.isValid(): + item = self.rules_table.item(idx.row(), CATEGORY_COLUMN) + item.is_deleted = True + item.setIcon(QIcon.ic('trash.png')) + + def undo_delete(self): + idx = self.rules_table.currentIndex() + if idx.isValid(): + item = self.rules_table.item(idx.row(), CATEGORY_COLUMN) + item.is_deleted = False + item.setIcon(QIcon()) + def table_column_resized(self, col, old, new): self.table_column_widths = [] for c in range(0, self.rules_table.columnCount()): diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.ui b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.ui index 1bc9e6210d..5fb2d7f87f 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.ui +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.ui @@ -37,22 +37,48 @@ Icon value rules - - + + <p>View all the defined value icon rules, including template rules. Rules are defined and edited in the Tag browser context menus. Rules can be deleted in -this dialog using the context menu.</p> +this dialog using the button, the delete key, or the context menu.</p> true - + + + + + + + + :/images/trash.png:/images/trash.png + + + Delete the selected rule + + + + + + + + :/images/edit-undo.png:/images/edit-undo.png + + + Undelete the selected rule if it is deleted + + + + +