forked from M-Labs/artiq
gui: Fix occasional wrong fuzzy select menu position on KDE/Linux
This commit is contained in:
parent
fc59791583
commit
b7f3eaebf9
|
@ -66,23 +66,30 @@ class FuzzySelectWidget(LayoutWidget):
|
||||||
if self.menu:
|
if self.menu:
|
||||||
self._update_menu()
|
self._update_menu()
|
||||||
|
|
||||||
|
def resizeEvent(self, ev):
|
||||||
|
# Reposition menu once widget position and layout are known. Qt triggers a
|
||||||
|
# resizeEvent then. (This is relevant for the Quick Open dialog on KDE/Linux,
|
||||||
|
# which sometimes shows at (0, 0) instead because the layout wasn't ready yet.)
|
||||||
|
if self.menu:
|
||||||
|
self._popup_menu()
|
||||||
|
return super().resizeEvent(ev)
|
||||||
|
|
||||||
def _activate(self):
|
def _activate(self):
|
||||||
self.update_when_text_changed = True
|
self.update_when_text_changed = True
|
||||||
if not self.menu:
|
if not self.menu:
|
||||||
# Show menu after initial layout is complete.
|
self._update_menu()
|
||||||
QtCore.QTimer.singleShot(0, self._update_menu)
|
|
||||||
|
def _popup_menu(self):
|
||||||
|
# Display menu with search results beneath line edit.
|
||||||
|
menu_pos = self.line_edit.mapToGlobal(self.line_edit.pos())
|
||||||
|
menu_pos.setY(menu_pos.y() + self.line_edit.height())
|
||||||
|
self.menu.popup(menu_pos)
|
||||||
|
|
||||||
def _ensure_menu(self):
|
def _ensure_menu(self):
|
||||||
if self.menu:
|
if self.menu:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.menu = QtWidgets.QMenu(self)
|
self.menu = QtWidgets.QMenu(self)
|
||||||
|
self._popup_menu()
|
||||||
# Display menu with search results beneath line edit.
|
|
||||||
menu_pos = self.line_edit.mapToGlobal(self.line_edit.pos())
|
|
||||||
menu_pos.setY(menu_pos.y() + self.line_edit.height())
|
|
||||||
|
|
||||||
self.menu.popup(menu_pos)
|
|
||||||
self.menu.aboutToHide.connect(self._menu_hidden)
|
self.menu.aboutToHide.connect(self._menu_hidden)
|
||||||
|
|
||||||
def _menu_hidden(self):
|
def _menu_hidden(self):
|
||||||
|
|
Loading…
Reference in New Issue