mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #7967 (Specific format actions show non-existent formats)
This commit is contained in:
parent
2719075963
commit
8ea848312c
@ -321,7 +321,7 @@ class LinuxFreeze(Command):
|
|||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
except:
|
except:
|
||||||
print 'WARNING: Failed to set default libc locale, using en_US'
|
print 'WARNING: Failed to set default libc locale, using en_US.UTF-8'
|
||||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||||
enc = locale.getdefaultlocale()[1]
|
enc = locale.getdefaultlocale()[1]
|
||||||
if not enc:
|
if not enc:
|
||||||
|
@ -97,10 +97,15 @@ class DeleteAction(InterfaceAction):
|
|||||||
for action in list(self.delete_menu.actions())[1:]:
|
for action in list(self.delete_menu.actions())[1:]:
|
||||||
action.setEnabled(enabled)
|
action.setEnabled(enabled)
|
||||||
|
|
||||||
def _get_selected_formats(self, msg):
|
def _get_selected_formats(self, msg, ids):
|
||||||
from calibre.gui2.dialogs.select_formats import SelectFormats
|
from calibre.gui2.dialogs.select_formats import SelectFormats
|
||||||
fmts = self.gui.library_view.model().db.all_formats()
|
fmts = set([])
|
||||||
d = SelectFormats([x.lower() for x in fmts], msg, parent=self.gui)
|
db = self.gui.library_view.model().db
|
||||||
|
for x in ids:
|
||||||
|
fmts_ = db.formats(x, index_is_id=True, verify_formats=False)
|
||||||
|
if fmts_:
|
||||||
|
fmts.update(frozenset([x.lower() for x in fmts_.split(',')]))
|
||||||
|
d = SelectFormats(list(sorted(fmts)), msg, parent=self.gui)
|
||||||
if d.exec_() != d.Accepted:
|
if d.exec_() != d.Accepted:
|
||||||
return None
|
return None
|
||||||
return d.selected_formats
|
return d.selected_formats
|
||||||
@ -118,7 +123,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
if not ids:
|
if not ids:
|
||||||
return
|
return
|
||||||
fmts = self._get_selected_formats(
|
fmts = self._get_selected_formats(
|
||||||
_('Choose formats to be deleted'))
|
_('Choose formats to be deleted'), ids)
|
||||||
if not fmts:
|
if not fmts:
|
||||||
return
|
return
|
||||||
for id in ids:
|
for id in ids:
|
||||||
@ -136,7 +141,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
if not ids:
|
if not ids:
|
||||||
return
|
return
|
||||||
fmts = self._get_selected_formats(
|
fmts = self._get_selected_formats(
|
||||||
'<p>'+_('Choose formats <b>not</b> to be deleted'))
|
'<p>'+_('Choose formats <b>not</b> to be deleted'), ids)
|
||||||
if fmts is None:
|
if fmts is None:
|
||||||
return
|
return
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user