Browse Source

Show a custom menu when right-clicking empty rack & patchbay areas

Closes #231
tags/1.9.7
falkTX 9 years ago
parent
commit
e11b07a633
3 changed files with 67 additions and 2 deletions
  1. +3
    -0
      resources/ui/carla_host.ui
  2. +57
    -0
      source/carla_host.py
  3. +7
    -2
      source/patchcanvas.py

+ 3
- 0
resources/ui/carla_host.ui View File

@@ -67,6 +67,9 @@
</item>
<item>
<widget class="RackListWidget" name="listWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>


+ 57
- 0
source/carla_host.py View File

@@ -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



+ 7
- 2
source/patchcanvas.py View File

@@ -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


Loading…
Cancel
Save