mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1918045 [[Enhancement] Double click to add/remove actions in Toolbars & menus preferences](https://bugs.launchpad.net/calibre/+bug/1918045)
This commit is contained in:
parent
1d68b65b9c
commit
69d70d9797
@ -259,6 +259,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def genesis(self, gui):
|
def genesis(self, gui):
|
||||||
|
self.all_actions.doubleClicked.connect(self.add_single_action)
|
||||||
|
self.current_actions.doubleClicked.connect(self.remove_single_action)
|
||||||
self.models = {}
|
self.models = {}
|
||||||
self.what.addItem(_('Click to choose toolbar or menu to customize'),
|
self.what.addItem(_('Click to choose toolbar or menu to customize'),
|
||||||
'blank')
|
'blank')
|
||||||
@ -300,13 +302,18 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.current_actions.setModel(self.models[key][1])
|
self.current_actions.setModel(self.models[key][1])
|
||||||
|
|
||||||
def add_action(self, *args):
|
def add_action(self, *args):
|
||||||
x = self.all_actions.selectionModel().selectedIndexes()
|
self._add_action(self.all_actions.selectionModel().selectedIndexes())
|
||||||
names = self.all_actions.model().names(x)
|
|
||||||
|
def add_single_action(self, index):
|
||||||
|
self._add_action([index])
|
||||||
|
|
||||||
|
def _add_action(self, indices):
|
||||||
|
names = self.all_actions.model().names(indices)
|
||||||
if names:
|
if names:
|
||||||
not_added = self.current_actions.model().add(names)
|
not_added = self.current_actions.model().add(names)
|
||||||
ns = {y.name for y in not_added}
|
ns = {y.name for y in not_added}
|
||||||
added = set(names) - ns
|
added = set(names) - ns
|
||||||
self.all_actions.model().remove(x, added)
|
self.all_actions.model().remove(indices, added)
|
||||||
if not_added:
|
if not_added:
|
||||||
warning_dialog(self, _('Cannot add'),
|
warning_dialog(self, _('Cannot add'),
|
||||||
_('Cannot add the actions %s to this location') %
|
_('Cannot add the actions %s to this location') %
|
||||||
@ -319,10 +326,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
|
||||||
def remove_action(self, *args):
|
def remove_action(self, *args):
|
||||||
x = self.current_actions.selectionModel().selectedIndexes()
|
self._remove_action(self.current_actions.selectionModel().selectedIndexes())
|
||||||
names = self.current_actions.model().names(x)
|
|
||||||
|
def remove_single_action(self, index):
|
||||||
|
self._remove_action([index])
|
||||||
|
|
||||||
|
def _remove_action(self, indices):
|
||||||
|
names = self.current_actions.model().names(indices)
|
||||||
if names:
|
if names:
|
||||||
not_removed = self.current_actions.model().remove(x)
|
not_removed = self.current_actions.model().remove(indices)
|
||||||
ns = {y.name for y in not_removed}
|
ns = {y.name for y in not_removed}
|
||||||
removed = set(names) - ns
|
removed = set(names) - ns
|
||||||
self.all_actions.model().add(removed)
|
self.all_actions.model().add(removed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user