Move completion widget when statusbar moves.

This commit is contained in:
Florian Bruhin 2014-02-09 21:43:24 +01:00
parent 1a74cbee74
commit 9636432bd5
3 changed files with 22 additions and 2 deletions

View File

@ -83,6 +83,7 @@ class CompletionView(QTreeView):
ignore_next = False
enabled = True
completing = False
height = QPoint(0, 200)
def __init__(self, parent=None):
super().__init__(parent)
@ -128,12 +129,20 @@ class CompletionView(QTreeView):
"""
bottomleft = geom.topLeft()
bottomright = geom.topRight()
delta = QPoint(0, 200)
topleft = bottomleft - delta
topleft = bottomleft - self.height
assert topleft.x() < bottomright.x()
assert topleft.y() < bottomright.y()
self.setGeometry(QRect(topleft, bottomright))
def move_to_bar(self, pos):
"""Move the completion area to the statusbar geometry.
Slot for the moved signal of the statusbar.
pos -- A QPoint containing the statusbar position.
"""
self.move(pos - self.height)
def cmd_text_changed(self, text):
"""Check if completions are available and activate them.

View File

@ -61,6 +61,7 @@ class MainWindow(QMainWindow):
self.vbox.addWidget(self.status)
self.status.resized.connect(self.completion.resize_to_bar)
self.status.moved.connect(self.completion.move_to_bar)
self.tabs.cur_progress.connect(self.status.prog.set_progress)
self.tabs.cur_load_finished.connect(self.status.prog.load_finished)
self.tabs.cur_load_started.connect(lambda:

View File

@ -35,6 +35,7 @@ class StatusBar(QWidget):
txt = None
prog = None
resized = pyqtSignal('QRect')
moved = pyqtSignal('QPoint')
fgcolor = None
bgcolor = None
_stylesheet = """
@ -98,3 +99,12 @@ class StatusBar(QWidget):
"""
super().resizeEvent(e)
self.resized.emit(self.geometry())
def moveEvent(self, e):
"""Extend moveEvent of QWidget to emit a moved signal afterwards.
e -- The QMoveEvent.
"""
super().moveEvent(e)
self.moved.emit(e.pos())