use different constructor to more reliably set the parent for menus and actions

This may make rendering menus more stable on hi-dpi monitors.
It worked before, but sometimes it had some weird glitches.
This commit is contained in:
2022-08-28 12:00:10 +02:00
parent fd840a2c95
commit e405e908db
2 changed files with 4 additions and 2 deletions

View File

@@ -67,7 +67,8 @@ class MainWindow(QMainWindow):
] ]
for (menu_id, menu_label) in known_menus: for (menu_id, menu_label) in known_menus:
menu = QMenu(menu_label, self) menu = QMenu(self)
menu.setTitle(menu_label)
mcs: [MenuContribution] = [mc for mc in menu_contributions if mc.menu_id == menu_id] mcs: [MenuContribution] = [mc for mc in menu_contributions if mc.menu_id == menu_id]
if len(mcs) == 0: if len(mcs) == 0:
continue continue

View File

@@ -76,7 +76,8 @@ class RAction():
self._action.setText(label) self._action.setText(label)
def to_qaction(self, qmenu: QMenu) -> QAction: def to_qaction(self, qmenu: QMenu) -> QAction:
action = QAction(self.label, qmenu) action = QAction(qmenu)
action.setText(self.label)
self._action = action self._action = action
if self.icon_from_theme: if self.icon_from_theme:
action.setIcon(Icon.fromTheme(self.icon_from_theme)) action.setIcon(Icon.fromTheme(self.icon_from_theme))