From 3d045fb230faa12e5dc4bcda9e3dcb805d35d743 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Sep 2023 10:24:25 +0530 Subject: [PATCH] Fix #2037172 [[Enhancement] "Find item in the Tag browser" input field should have a "Clear search history" context menu item](https://bugs.launchpad.net/calibre/+bug/2037172) --- src/calibre/gui2/widgets.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index 476494742b..3724271843 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -733,6 +733,16 @@ class HistoryLineEdit(QComboBox): # {{{ def setPlaceholderText(self, txt): return self.lineEdit().setPlaceholderText(txt) + def contextMenuEvent(self, event): + menu = self.lineEdit().createStandardContextMenu() + menu.addSeparator() + menu.addAction(_('Clear history'), self.clear_history_default_impl) + menu.exec(event.globalPos()) + + def clear_history_default_impl(self): + self.clear() + history.set(self.store_name, []) + @property def store_name(self): return 'lineedit_history_'+self._name