From c986c868602c7c3fa7e90ae2747074aa8341608d Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 15 May 2020 15:06:50 +0100 Subject: [PATCH] Add "Find plugin in patchbay" right-click option Signed-off-by: falkTX --- source/frontend/carla_host.py | 14 +++++++++++ source/frontend/carla_skin.py | 19 +++++++++++++- source/frontend/patchcanvas/patchcanvas.py | 29 ++++++++++++++++++++++ source/frontend/patchcanvas/scene.py | 3 +++ source/frontend/widgets/racklistwidget.py | 3 +-- 5 files changed, 65 insertions(+), 3 deletions(-) diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 124725cef..2c3c17e02 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -639,6 +639,20 @@ class HostWindow(QMainWindow): else: pitem.recreateWidget(newSkin = skin) + def findPluginInPatchbay(self, pluginId): + if pluginId > self.fPluginCount: + return + + if self.fExternalPatchbay: + self.slot_canvasShowInternal() + + if not patchcanvas.focusGroupUsingPluginId(pluginId): + name = self.host.get_plugin_info(pluginId)['name'] + if not patchcanvas.focusGroupUsingGroupName(name): + return + + self.ui.tabWidget.setCurrentIndex(1) + def switchPlugins(self, pluginIdA, pluginIdB): if pluginIdA == pluginIdB: return diff --git a/source/frontend/carla_skin.py b/source/frontend/carla_skin.py index 273c8cfab..3df24b775 100644 --- a/source/frontend/carla_skin.py +++ b/source/frontend/carla_skin.py @@ -1038,13 +1038,24 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): menu = QMenu(self) # ------------------------------------------------------------- - # Expand/Minimize + # Expand/Minimize and Tweaks actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize")) actColor = menu.addAction(self.tr("Change Color...")) actSkin = menu.addAction(self.tr("Change Skin...")) menu.addSeparator() + # ------------------------------------------------------------- + # Find in patchbay, if possible + + if self.host.processMode in (ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, + ENGINE_PROCESS_MODE_PATCHBAY): + actFindInPatchbay = menu.addAction(self.tr("Find plugin in patchbay")) + menu.addSeparator() + + else: + actFindInPatchbay = None + # ------------------------------------------------------------- # Move up and down @@ -1169,6 +1180,12 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): return gCarla.gui.changePluginSkin(self.fPluginId, skin[0]) + # ------------------------------------------------------------- + # Find in patchbay + + elif actSel == actFindInPatchbay: + gCarla.gui.findPluginInPatchbay(self.fPluginId) + # ------------------------------------------------------------- # Move up and down diff --git a/source/frontend/patchcanvas/patchcanvas.py b/source/frontend/patchcanvas/patchcanvas.py index 5a4837125..04cab3b6f 100644 --- a/source/frontend/patchcanvas/patchcanvas.py +++ b/source/frontend/patchcanvas/patchcanvas.py @@ -698,6 +698,35 @@ def setGroupAsPlugin(group_id, plugin_id, hasUI, hasInlineDisplay): # ------------------------------------------------------------------------------------------------------------ +def focusGroupUsingPluginId(plugin_id): + if canvas.debug: + print("PatchCanvas::focusGroupUsingPluginId(%i)" % (plugin_id,)) + + if plugin_id < 0 or plugin_id >= MAX_PLUGIN_ID_ALLOWED: + return False + + for group in canvas.group_list: + if group.plugin_id == plugin_id: + item = group.widgets[0] + canvas.scene.clearSelection() + canvas.scene.getView().centerOn(item) + item.setSelected(True) + return True + +def focusGroupUsingGroupName(group_name): + if canvas.debug: + print("PatchCanvas::focusGroupUsingGroupName(%s)" % (group_name,)) + + for group in canvas.group_list: + if group.group_name == group_name: + item = group.widgets[0] + canvas.scene.clearSelection() + canvas.scene.getView().centerOn(item) + item.setSelected(True) + return True + +# ------------------------------------------------------------------------------------------------------------ + def addPort(group_id, port_id, port_name, port_mode, port_type, is_alternate=False): if canvas.debug: print("PatchCanvas::addPort(%i, %i, %s, %s, %s, %s)" % ( diff --git a/source/frontend/patchcanvas/scene.py b/source/frontend/patchcanvas/scene.py index 365a0321f..19f716743 100644 --- a/source/frontend/patchcanvas/scene.py +++ b/source/frontend/patchcanvas/scene.py @@ -95,6 +95,9 @@ class PatchScene(QGraphicsScene): def getScaleFactor(self): return self.m_view.transform().m11() + def getView(self): + return self.m_view + def fixScaleFactor(self, transform=None): fix, set_view = False, False if not transform: diff --git a/source/frontend/widgets/racklistwidget.py b/source/frontend/widgets/racklistwidget.py index 82978801a..f68f235a2 100644 --- a/source/frontend/widgets/racklistwidget.py +++ b/source/frontend/widgets/racklistwidget.py @@ -262,8 +262,7 @@ class RackListWidget(QListWidget): #return True if MACOS and lfilename.endswith(".vst"): return True - # TODO check vst3 supported feature - elif lfilename.endswith(".vst3"): + elif lfilename.endswith(".vst3") and ".vst3" in self.fSupportedExtensions: return True elif os.path.isfile(filename):