mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Clean up the icon removal dialog box
This commit is contained in:
parent
375eebf783
commit
b8c95130c2
@ -319,20 +319,20 @@ class ConditionEditor(QWidget): # {{{
|
|||||||
|
|
||||||
class RemoveIconFileDialog(QDialog): # {{{
|
class RemoveIconFileDialog(QDialog): # {{{
|
||||||
def __init__(self, parent, icon_file_names, icon_folder):
|
def __init__(self, parent, icon_file_names, icon_folder):
|
||||||
|
self.files_to_remove = []
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
self.setWindowTitle(_('Remove icons'))
|
self.setWindowTitle(_('Remove icons'))
|
||||||
self.setWindowFlags(self.windowFlags()&(~Qt.WindowType.WindowContextHelpButtonHint))
|
self.setWindowFlags(self.windowFlags()&(~Qt.WindowType.WindowContextHelpButtonHint))
|
||||||
l = QVBoxLayout(self)
|
l = QVBoxLayout(self)
|
||||||
t = QLabel('<p>' + _('Check the icons you wish to remove. The icon files will be '
|
t = QLabel('<p>' + _('Select the icons you wish to remove. The icon files will be '
|
||||||
'removed when you press OK. There is no undo.') + '</p>')
|
'removed when you press OK. There is no undo.') + '</p>')
|
||||||
t.setWordWrap(True)
|
t.setWordWrap(True)
|
||||||
t.setTextFormat(Qt.TextFormat.RichText)
|
t.setTextFormat(Qt.TextFormat.RichText)
|
||||||
l.addWidget(t)
|
l.addWidget(t)
|
||||||
self.listbox = lw = QListWidget(parent)
|
self.listbox = lw = QListWidget(parent)
|
||||||
|
lw.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
|
||||||
for fn in icon_file_names:
|
for fn in icon_file_names:
|
||||||
item = QListWidgetItem(fn)
|
item = QListWidgetItem(fn)
|
||||||
item.setFlags(Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled)
|
|
||||||
item.setCheckState(Qt.CheckState.Unchecked)
|
|
||||||
item.setIcon(QIcon(os.path.join(icon_folder, fn)))
|
item.setIcon(QIcon(os.path.join(icon_folder, fn)))
|
||||||
lw.addItem(item)
|
lw.addItem(item)
|
||||||
l.addWidget(lw)
|
l.addWidget(lw)
|
||||||
@ -342,26 +342,24 @@ class RemoveIconFileDialog(QDialog): # {{{
|
|||||||
bb.rejected.connect(self.reject)
|
bb.rejected.connect(self.reject)
|
||||||
l.addWidget(bb)
|
l.addWidget(bb)
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
return QSize(700, 600)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.files_to_remove = []
|
self.files_to_remove = [item.text() for item in self.listbox.selectedItems()]
|
||||||
for dex in range(self.listbox.count()):
|
if not self.files_to_remove:
|
||||||
item = self.listbox.item(dex)
|
return error_dialog(self, _('No icons selected'), _(
|
||||||
if item.checkState() == Qt.CheckState.Checked:
|
'You must select at least one icon to remove'), show=True)
|
||||||
self.files_to_remove.append(item.text())
|
if question_dialog(self,
|
||||||
if (len(self.files_to_remove) == 0 or
|
|
||||||
question_dialog(self,
|
|
||||||
_('Remove icons'),
|
_('Remove icons'),
|
||||||
_('{count} {icon_word} will be removed. Are you '
|
ngettext('One icon will be removed.', '{} icons will be removed.', len(self.files_to_remove)
|
||||||
'sure?').format(count=len(self.files_to_remove),
|
).format(len(self.files_to_remove)) + ' ' + _('This will prevent any rules that use this icon from working. Are you sure?'),
|
||||||
icon_word=_('icon') if len(self.files_to_remove) == 1 else _('icons')),
|
|
||||||
yes_text=_('Yes'),
|
yes_text=_('Yes'),
|
||||||
no_text=_('No'),
|
no_text=_('No'),
|
||||||
det_msg='\n'.join(self.files_to_remove),
|
det_msg='\n'.join(self.files_to_remove),
|
||||||
skip_dialog_name='remove_icon_confirmation_dialog')):
|
skip_dialog_name='remove_icon_confirmation_dialog'
|
||||||
|
):
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
QDialog.reject(self)
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@ -494,7 +492,7 @@ class RuleEditor(QDialog): # {{{
|
|||||||
bb.rejected.connect(self.reject)
|
bb.rejected.connect(self.reject)
|
||||||
l.addWidget(bb, 9, 0, 1, 8)
|
l.addWidget(bb, 9, 0, 1, 8)
|
||||||
if self.rule_kind != 'color':
|
if self.rule_kind != 'color':
|
||||||
self.remove_button = b = bb.addButton(_('&Remove icon'), QDialogButtonBox.ButtonRole.ActionRole)
|
self.remove_button = b = bb.addButton(_('&Remove icons'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||||
b.setIcon(QIcon(I('minus.png')))
|
b.setIcon(QIcon(I('minus.png')))
|
||||||
b.clicked.connect(self.remove_icon_file_dialog)
|
b.clicked.connect(self.remove_icon_file_dialog)
|
||||||
b.setToolTip('<p>' + _('Remove previously added icons. Note that removing an '
|
b.setToolTip('<p>' + _('Remove previously added icons. Note that removing an '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user