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)

This commit is contained in:
Kovid Goyal 2023-09-24 10:24:25 +05:30
parent 34b3ee1138
commit 3d045fb230
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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