Fix #2106093 [[Enhancement] Add 'Remove format' action to context menu](https://bugs.launchpad.net/calibre/+bug/2106093)

This commit is contained in:
Kovid Goyal 2025-04-10 08:49:23 +05:30
parent d8ac21b896
commit 024a60ef20
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -890,6 +890,9 @@ class FormatList(_FormatList):
action = EditAction(item, cm) action = EditAction(item, cm)
action.edit_fmt.connect(self.edit_fmt, type=Qt.ConnectionType.QueuedConnection) action.edit_fmt.connect(self.edit_fmt, type=Qt.ConnectionType.QueuedConnection)
cm.addAction(action) cm.addAction(action)
ac = cm.addAction(QIcon.ic('trash.png'), _('&Remove {} format').format(item.ext.upper()))
ac.setObjectName(item.ext)
ac.triggered.connect(self.remove_cm_fmt)
if item and originals: if item and originals:
cm.addSeparator() cm.addSeparator()
@ -904,6 +907,9 @@ class FormatList(_FormatList):
cm.popup(event.globalPos()) cm.popup(event.globalPos())
event.accept() event.accept()
def remove_cm_fmt(self):
self.remove_format(self.sender().objectName())
def remove_format(self, fmt): def remove_format(self, fmt):
for i in range(self.count()): for i in range(self.count()):
f = self.item(i) f = self.item(i)