Add menubar/toolbar context menu explicitly

Previously it was somehow automatically generated. Unfortunately it
caused SEGV in libQtCore (4.8).
This commit is contained in:
Marek Marczykowski 2013-02-15 16:06:54 +01:00
parent 6b03b6dd1b
commit fd330c283d
2 changed files with 17 additions and 0 deletions

View File

@ -232,6 +232,9 @@
<height>22</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<widget class="QMenu" name="menu_system">
<property name="title">
<string>System</string>
@ -324,6 +327,9 @@
<property name="floatable">
<bool>false</bool>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>

View File

@ -785,10 +785,18 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.context_menu.addMenu(self.logs_menu)
self.context_menu.addSeparator()
self.tools_context_menu = QMenu(self)
self.tools_context_menu.addAction(self.action_toolbar)
self.tools_context_menu.addAction(self.action_menubar)
self.table_selection_changed()
self.connect(self.table.horizontalHeader(), SIGNAL("sortIndicatorChanged(int, Qt::SortOrder)"), self.sortIndicatorChanged)
self.connect(self.table, SIGNAL("customContextMenuRequested(const QPoint&)"), self.open_context_menu)
self.connect(self.menubar, SIGNAL("customContextMenuRequested(const QPoint&)"),
lambda pos: self.open_tools_context_menu(self.menubar, pos))
self.connect(self.toolBar, SIGNAL("customContextMenuRequested(const QPoint&)"),
lambda pos: self.open_tools_context_menu(self.toolBar, pos))
self.connect(self.blk_menu, SIGNAL("triggered(QAction *)"), self.attach_dettach_device_triggered)
self.connect(self.logs_menu, SIGNAL("triggered(QAction *)"), self.show_log)
@ -1649,6 +1657,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
menu.addAction(self.action_menubar)
return menu
def open_tools_context_menu(self, widget, point):
self.tools_context_menu.exec_(widget.mapToGlobal(point))
@pyqtSlot('const QPoint&')
def open_context_menu(self, point):