mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Set a different background color when choosing formats to not delete as opposed to choosing format to delete. Fixes #1001741 (Enhancement - Remove Book Formats)
This commit is contained in:
parent
5abc74f570
commit
4694adb923
@ -116,7 +116,7 @@ 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, ids):
|
def _get_selected_formats(self, msg, ids, exclude=False):
|
||||||
from calibre.gui2.dialogs.select_formats import SelectFormats
|
from calibre.gui2.dialogs.select_formats import SelectFormats
|
||||||
c = Counter()
|
c = Counter()
|
||||||
db = self.gui.library_view.model().db
|
db = self.gui.library_view.model().db
|
||||||
@ -125,7 +125,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
if fmts_:
|
if fmts_:
|
||||||
for x in frozenset([x.lower() for x in fmts_.split(',')]):
|
for x in frozenset([x.lower() for x in fmts_.split(',')]):
|
||||||
c[x] += 1
|
c[x] += 1
|
||||||
d = SelectFormats(c, msg, parent=self.gui)
|
d = SelectFormats(c, msg, parent=self.gui, exclude=exclude)
|
||||||
if d.exec_() != d.Accepted:
|
if d.exec_() != d.Accepted:
|
||||||
return None
|
return None
|
||||||
return d.selected_formats
|
return d.selected_formats
|
||||||
@ -162,7 +162,8 @@ class DeleteAction(InterfaceAction):
|
|||||||
return
|
return
|
||||||
fmts = self._get_selected_formats(
|
fmts = self._get_selected_formats(
|
||||||
'<p>'+_('Choose formats <b>not</b> to be deleted.<p>Note that '
|
'<p>'+_('Choose formats <b>not</b> to be deleted.<p>Note that '
|
||||||
'this will never remove all formats from a book.'), ids)
|
'this will never remove all formats from a book.'), ids,
|
||||||
|
exclude=True)
|
||||||
if fmts is None:
|
if fmts is None:
|
||||||
return
|
return
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
@ -47,7 +47,7 @@ class Formats(QAbstractListModel):
|
|||||||
|
|
||||||
class SelectFormats(QDialog):
|
class SelectFormats(QDialog):
|
||||||
|
|
||||||
def __init__(self, fmt_count, msg, single=False, parent=None):
|
def __init__(self, fmt_count, msg, single=False, parent=None, exclude=False):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
self._l = QVBoxLayout(self)
|
self._l = QVBoxLayout(self)
|
||||||
self.setLayout(self._l)
|
self.setLayout(self._l)
|
||||||
@ -57,6 +57,10 @@ class SelectFormats(QDialog):
|
|||||||
self._l.addWidget(self._m)
|
self._l.addWidget(self._m)
|
||||||
self.formats = Formats(fmt_count)
|
self.formats = Formats(fmt_count)
|
||||||
self.fview = QListView(self)
|
self.fview = QListView(self)
|
||||||
|
if exclude:
|
||||||
|
self.fview.setStyleSheet('''
|
||||||
|
QListView { background-color: #FAE7B5}
|
||||||
|
''')
|
||||||
self._l.addWidget(self.fview)
|
self._l.addWidget(self.fview)
|
||||||
self.fview.setModel(self.formats)
|
self.fview.setModel(self.formats)
|
||||||
self.fview.setSelectionMode(self.fview.SingleSelection if single else
|
self.fview.setSelectionMode(self.fview.SingleSelection if single else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user