Move the collapse all button into the right click menu

This commit is contained in:
Kovid Goyal 2017-06-10 17:26:57 +05:30
parent 621f12fc8b
commit 938c79f0c8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 12 deletions

View File

@ -373,6 +373,8 @@ class TagBrowserWidget(QWidget): # {{{
self.search_button = QToolButton() self.search_button = QToolButton()
self.search_button.setCursor(Qt.PointingHandCursor) self.search_button.setCursor(Qt.PointingHandCursor)
self.search_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.search_button.setIcon(QIcon(I('search.png')))
self.search_button.setText(_('Find')) self.search_button.setText(_('Find'))
self.search_button.setToolTip(_('Find the first/next matching item')) self.search_button.setToolTip(_('Find the first/next matching item'))
search_layout.addWidget(self.search_button) search_layout.addWidget(self.search_button)
@ -383,21 +385,12 @@ class TagBrowserWidget(QWidget): # {{{
action=ac, group=_('Tag browser')) action=ac, group=_('Tag browser'))
ac.triggered.connect(self.search_button.click) ac.triggered.connect(self.search_button.click)
self.expand_button = QToolButton() self.collapse_all_action = ac = QAction(parent)
self.expand_button.setAutoRaise(True)
self.expand_button.setCursor(Qt.PointingHandCursor)
self.expand_button.setText('')
self.expand_button.setToolTip(_('Collapse all categories'))
search_layout.insertWidget(0, self.expand_button)
search_layout.setStretch(0, 10)
search_layout.setStretch(1, 1)
search_layout.setStretch(2, 1)
ac = QAction(parent)
parent.addAction(ac) parent.addAction(ac)
parent.keyboard.register_shortcut('tag browser collapse all', parent.keyboard.register_shortcut('tag browser collapse all',
_('Collapse all'), default_keys=(), _('Collapse all'), default_keys=(),
action=ac, group=_('Tag browser')) action=ac, group=_('Tag browser'))
ac.triggered.connect(self.expand_button.clicked) ac.triggered.connect(lambda : self.tags_view.collapseAll())
self.current_find_position = None self.current_find_position = None
self.search_button.clicked.connect(self.find) self.search_button.clicked.connect(self.find)
@ -409,7 +402,6 @@ class TagBrowserWidget(QWidget): # {{{
parent.tags_view = TagsView(parent) parent.tags_view = TagsView(parent)
self.tags_view = parent.tags_view self.tags_view = parent.tags_view
self.expand_button.clicked.connect(self.tags_view.collapseAll)
self._layout.addWidget(parent.tags_view) self._layout.addWidget(parent.tags_view)
# Now the floating 'not found' box # Now the floating 'not found' box

View File

@ -692,6 +692,8 @@ class TagsView(QTreeView): # {{{
self.context_menu.addSeparator() self.context_menu.addSeparator()
self.context_menu.addAction(_('E&xpand all children'), partial(self.expand_node_and_descendants, index)) self.context_menu.addAction(_('E&xpand all children'), partial(self.expand_node_and_descendants, index))
self.context_menu.addAction(_('Collapse all levels'), self.collapseAll)
if not self.context_menu.isEmpty(): if not self.context_menu.isEmpty():
self.context_menu.popup(self.mapToGlobal(point)) self.context_menu.popup(self.mapToGlobal(point))
return True return True