mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Allow double clicking int he customize viewer toolbar dialog
This commit is contained in:
parent
9e34e107ab
commit
e5654c1c4f
@ -356,13 +356,16 @@ class ActionsList(QListWidget):
|
||||
for name in names:
|
||||
self.add_item_from_name(name)
|
||||
|
||||
def remove_item(self, item):
|
||||
action = item.data(Qt.ItemDataRole.UserRole)
|
||||
if action is not None or not self.is_source:
|
||||
self.takeItem(self.row(item))
|
||||
return action
|
||||
|
||||
def remove_selected(self):
|
||||
ans = []
|
||||
for item in tuple(self.selectedItems()):
|
||||
action = item.data(Qt.ItemDataRole.UserRole)
|
||||
if action is not None or not self.is_source:
|
||||
self.takeItem(self.row(item))
|
||||
ans.append(action)
|
||||
ans.append(self.remove_item(item))
|
||||
return ans
|
||||
|
||||
def add_names(self, names):
|
||||
@ -388,7 +391,9 @@ class ConfigureToolBar(Dialog):
|
||||
def setup_ui(self):
|
||||
acnames = all_actions().all_action_names
|
||||
self.available_actions = ActionsList(acnames - frozenset(current_actions()), parent=self)
|
||||
self.available_actions.itemDoubleClicked.connect(self.add_item)
|
||||
self.current_actions = ActionsList(current_actions(), parent=self, is_source=False)
|
||||
self.current_actions.itemDoubleClicked.connect(self.remove_item)
|
||||
self.l = l = QVBoxLayout(self)
|
||||
self.la = la = QLabel(_('Choose the actions you want on the toolbar.'
|
||||
' Drag and drop items in the right hand list to re-arrange the toolbar.'))
|
||||
@ -423,10 +428,18 @@ class ConfigureToolBar(Dialog):
|
||||
names = self.current_actions.remove_selected()
|
||||
self.available_actions.add_names(names)
|
||||
|
||||
def remove_item(self, item):
|
||||
names = self.current_actions.remove_item(item),
|
||||
self.available_actions.add_names(names)
|
||||
|
||||
def add_actions(self):
|
||||
names = self.available_actions.remove_selected()
|
||||
self.current_actions.add_names(names)
|
||||
|
||||
def add_item(self, item):
|
||||
names = self.available_actions.remove_item(item),
|
||||
self.current_actions.add_names(names)
|
||||
|
||||
def restore_defaults(self):
|
||||
self.current_actions.set_names(DEFAULT_ACTIONS)
|
||||
acnames = all_actions().all_action_names
|
||||
|
Loading…
x
Reference in New Issue
Block a user