Source

thg-qt-mq / repowidget-actions.diff

# HG changeset patch
# Parent 8779ea2c596f507cadbcb070c3d51476ca1d44a9

diff --git a/tortoisehg/hgqt/quickbar.py b/tortoisehg/hgqt/quickbar.py
--- a/tortoisehg/hgqt/quickbar.py
+++ b/tortoisehg/hgqt/quickbar.py
@@ -47,7 +47,7 @@ class QuickBar(QToolBar):
         self._actions = {'open': openact}
 
     def createContent(self):
-        self.parent().addAction(self._actions['open'])
+        pass # XXX self.parent().addAction(self._actions['open'])
 
     def hide(self):
         self.setVisible(False)
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -189,25 +189,28 @@ class RepoWidget(QWidget):
         else:
             return self.repo.shortname
 
-    @pyqtSlot()
-    def toggleSearchBar(self):
+    @pyqtSlot(bool)
+    def toggleSearchBar(self, visible):
         """Toggle display of tasktab-specific search bar if available"""
+        # XXX handle visibility correctly; maybe toggleSearchBar action
+        # should also be implemented at each taskTabsWidget, and we need
+        # to reconnect it on taskTabsWidget.currentChanged signal.
         curtt = self.taskTabsWidget.currentWidget()
         show = getattr(curtt, 'toggleSearchBar', None)
         if show:
             show()
 
-    @pyqtSlot()
-    def toggleFilterBar(self):
+    @pyqtSlot(bool)
+    def toggleFilterBar(self, visible):
         """Toggle display repowidget filter bar"""
-        vis = self.filterbar.isVisible()
-        self.filterbar.setVisible(not vis)
+        self.filterbar.setVisible(visible)
+        self._action_toggleFilterBar.setChecked(visible)
 
-    @pyqtSlot()
-    def toggleGotoBar(self):
+    @pyqtSlot(bool)
+    def toggleGotoBar(self, visible):
         """Toggle display repowidget goto bar"""
-        vis = self.gototb.isVisible()
-        self.gototb.setVisible(not vis)
+        self.gototb.setVisible(visible)
+        self._action_toggleGotoBar.setChecked(visible)
 
     @pyqtSlot(unicode)
     def _openLink(self, link):
@@ -403,6 +406,25 @@ class RepoWidget(QWidget):
     def createActions(self):
         QShortcut(QKeySequence('CTRL+P'), self, self.gotoParent)
 
+        # XXX This can be implemented as a decorator?
+        self._action_toggleFilterBar = QAction(
+            geticon('find'), _('Filter Toolbar'), self,
+            checkable=True, shortcut='Ctrl+S')
+        self._action_toggleFilterBar.toggled.connect(self.toggleFilterBar)
+        self.addAction(self._action_toggleFilterBar)
+
+        self._action_toggleGotoBar = QAction(
+            geticon('go-jump'), _('Goto Toolbar'), self,
+            checkable=True, shortcut='Ctrl+T')
+        self._action_toggleGotoBar.toggled.connect(self.toggleGotoBar)
+        self.addAction(self._action_toggleGotoBar)
+
+        self._action_toggleSearchBar = QAction(
+            geticon('edit-find'), _('Find in File'), self,
+            checkable=True, shortcut=QKeySequence.Find)
+        self._action_toggleSearchBar.toggled.connect(self.toggleSearchBar)
+        self.addAction(self._action_toggleSearchBar)
+
     def dragEnterEvent(self, event):
         paths = [unicode(u.toLocalFile()) for u in event.mimeData().urls()]
         if util.any(os.path.isfile(p) for p in paths):
diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py
+++ b/tortoisehg/hgqt/workbench.py
@@ -284,18 +284,6 @@ class Workbench(QMainWindow):
                   enabled='repoopen', toolbar='edit',
                   tooltip=_('Load all revisions into graph'))
         newseparator(toolbar='edit', menu='View')
-        newaction(_('Filter Toolbar'), self._repofwd('toggleFilterBar'),
-                  icon='find', shortcut='Ctrl+S', enabled='repoopen',
-                  toolbar='edit', menu='View',
-                  tooltip=_('Filter graph with revision sets or branches'))
-        newaction(_('Goto Toolbar'), self._repofwd('toggleGotoBar'),
-                  icon='go-jump', shortcut='Ctrl+T', enabled='repoopen',
-                  toolbar='edit', menu='View',
-                  tooltip=_('Jump to a specific revision'))
-        newaction(_('Find in File'), self._repofwd('toggleSearchBar'),
-                  icon='edit-find', shortcut='Find', enabled='repoopen',
-                  toolbar='edit', menu='View', checkable=False,
-                  tooltip=_('Search file and revision contents for keyword'))
 
         newaction(_('Incoming'), self._repofwd('incoming'), icon='incoming',
                   tooltip=_('Check for incoming changes from default pull target'),
@@ -446,8 +434,16 @@ class Workbench(QMainWindow):
         if w:
             self.updateHistoryActions()
             self.updateMenu()
+        self.updateRepoTabActions()
         self.log.setRepository(w and w.repo or None)
 
+    def updateRepoTabActions(self):
+        # XXX: update menu, etc. QActionGroup may help something, not sure.
+        self.edittbar.clear()
+        w = self.repoTabsWidget.currentWidget()
+        if w:
+            self.edittbar.addActions(w.actions())
+
     def addRepoTab(self, repo):
         '''opens the given repo in a new tab'''
         rw = RepoWidget(repo, self)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.