Yuya Nishihara  committed 75b8761

infobar: overlay infobar on top of revision graph (closes #2113)

If infobar is inserted to the layout, it's inevitable to change the vertical
position of the graph. Instead, this tries to overlay infobar like a tooltip.

Now infobar isn't managed by the layout system, we need to track resize event

  • Participants
  • Parent commits 54e0729
  • Branches default

Comments (0)

Files changed (2)

File tortoisehg/hgqt/

         super(InfoBar, self).keyPressEvent(event)
+    def heightForWidth(self, width):
+        # loosely based on the internal strategy of QBoxLayout
+        if self.layout().hasHeightForWidth():
+            return super(InfoBar, self).heightForWidth(width)
+        else:
+            return self.sizeHint().height()
 class StatusInfoBar(InfoBar):
     """Show status message"""
     def __init__(self, message, parent=None):

File tortoisehg/hgqt/

         self.layout().setContentsMargins(0, 0, 0, 0)
-        self._infobarlayout = QVBoxLayout()  # placeholder for InfoBar
-        self.layout().addLayout(self._infobarlayout)
         self._activeInfoBar = None
         self.filterbar = RepoFilterBar(self.repo, self)
         if not cleared:
         w = cls(*args, **kwargs)
+        w.setParent(self)
         self._activeInfoBar = w
-        self._infobarlayout.insertWidget(0, w)
+        self._updateInfoBarGeometry()
         w.setFocus()  # to handle key press by InfoBar
         return w
     def clearInfoBar(self, priority=None):
         """Close current infobar if available; return True if got empty"""
-        it = self._infobarlayout.itemAt(0)
-        assert it is self._activeInfoBar or it.widget() is self._activeInfoBar
         if not self._activeInfoBar:
             return True
         if priority is None or self._activeInfoBar.infobartype <= priority:
-            # removes current infobar explicitly, because close() seems to
-            # delay deletion until next eventloop.
-            self._infobarlayout.removeItem(it)
             self._freeInfoBar()  # call directly in case of event delay
     def _freeInfoBar(self):
         """Disown closed infobar"""
+        if not self._activeInfoBar:
+            return
+        self._activeInfoBar.setParent(None)
         self._activeInfoBar = None
+    def _updateInfoBarGeometry(self):
+        if not self._activeInfoBar:
+            return
+        w = self._activeInfoBar
+        w.setGeometry(0, 0, self.width(), w.heightForWidth(self.width()))
     @pyqtSlot(unicode, unicode)
     def _showOutputOnInfoBar(self, msg, label, maxlines=2, maxwidth=140):
         labelslist = unicode(label).split()
             self.dirty = False
+    def resizeEvent(self, event):
+        QWidget.resizeEvent(self, event)
+        self._updateInfoBarGeometry()
     def createActions(self):
         QShortcut(QKeySequence('CTRL+P'), self, self.gotoParent)