diff --git a/resources/ui/carla_host.ui b/resources/ui/carla_host.ui index 0d7721b87..8eefb5796 100644 --- a/resources/ui/carla_host.ui +++ b/resources/ui/carla_host.ui @@ -67,6 +67,9 @@ + + Qt::CustomContextMenu + Qt::ScrollBarAlwaysOff diff --git a/source/carla_host.py b/source/carla_host.py index 66bb53d2a..c095bad9e 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -390,6 +390,8 @@ class HostWindow(QMainWindow): self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove) self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked) + self.ui.listWidget.customContextMenuRequested.connect(self.showPluginActionsMenu) + self.ui.graphicsView.horizontalScrollBar().valueChanged.connect(self.slot_horizontalScrollBarChanged) self.ui.graphicsView.verticalScrollBar().valueChanged.connect(self.slot_verticalScrollBarChanged) @@ -740,6 +742,58 @@ class HostWindow(QMainWindow): return (btype, ptype, filename, label, uniqueId, extraPtr) + @pyqtSlot() + def showPluginActionsMenu(self): + menu = QMenu(self) + + if config_UseQt5: + menu.addSection("Plugins") + else: + # fake section + act = menu.addAction(" Plugins") + font = act.font() + font.setBold(True) + act.setFont(font) + act.setEnabled(False) + menu.addSeparator() + + menu.addAction(self.ui.act_plugin_add) + menu.addAction(self.ui.act_plugin_remove_all) + + if config_UseQt5: + menu.addSection("All plugins (macros)") + else: + # fake space + act = menu.addAction(" ") + font = act.font() + font.setBold(True) + font.setPointSize(font.pointSize()/2) + act.setEnabled(False) + + # fake section + act = menu.addAction(" All plugins (macros)") + font = act.font() + font.setBold(True) + act.setFont(font) + act.setEnabled(False) + menu.addSeparator() + + menu.addAction(self.ui.act_plugins_enable) + menu.addAction(self.ui.act_plugins_disable) + menu.addSeparator() + menu.addAction(self.ui.act_plugins_volume100) + menu.addAction(self.ui.act_plugins_mute) + menu.addSeparator() + menu.addAction(self.ui.act_plugins_wet100) + menu.addAction(self.ui.act_plugins_bypass) + menu.addSeparator() + menu.addAction(self.ui.act_plugins_center) + menu.addSeparator() + menu.addAction(self.ui.act_plugins_compact) + menu.addAction(self.ui.act_plugins_expand) + + menu.exec_(QCursor.pos()) + @pyqtSlot() def slot_pluginAdd(self): data = self.showAddPluginDialog() @@ -1959,6 +2013,9 @@ def canvasCallback(action, value1, value2, valueStr): if pwidget is not None: pwidget.showCustomUI() + elif action == patchcanvas.ACTION_BG_RIGHT_CLICK: + gCarla.gui.showPluginActionsMenu() + # ------------------------------------------------------------------------------------------------------------ # Engine callback diff --git a/source/patchcanvas.py b/source/patchcanvas.py index 954c4c1b4..a9024ec4e 100644 --- a/source/patchcanvas.py +++ b/source/patchcanvas.py @@ -76,6 +76,7 @@ ACTION_PLUGIN_RENAME = 10 # plugin_id, N, N ACTION_PLUGIN_REPLACE = 11 # plugin_id, N, N ACTION_PLUGIN_REMOVE = 12 # plugin_id, N, N ACTION_PLUGIN_SHOW_UI = 13 # plugin_id, N, N +ACTION_BG_RIGHT_CLICK = 14 # N, N, N # Icon ICON_APPLICATION = 0 @@ -1360,8 +1361,12 @@ class PatchScene(QGraphicsScene): QGraphicsScene.wheelEvent(self, event) - #def contextMenuEvent(self, event): - #print("context menu event") + def contextMenuEvent(self, event): + if len(self.selectedItems()) == 0: + event.accept() + canvas.callback(ACTION_BG_RIGHT_CLICK, 0, 0, "") + else: + QGraphicsScene.contextMenuEvent(self, event) # ------------------------------------------------------------------------------ # canvasfadeanimation.cpp