diff --git a/.gitignore b/.gitignore index 081e56706..3fdce1d80 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,7 @@ source/paramspinbox.py source/pixmapbutton.py source/pixmapdial.py source/pixmapkeyboard.py -source/qgraphicsembedscene.py +source/racklistwidget.py # Binaries carla-bridge-qtcreator diff --git a/Makefile b/Makefile index d518f2bc8..a71f9cc0d 100644 --- a/Makefile +++ b/Makefile @@ -279,6 +279,7 @@ RES = \ bin/resources/pixmapbutton.py \ bin/resources/pixmapdial.py \ bin/resources/pixmapkeyboard.py \ + bin/resources/racklistwidget.py \ bin/resources/resources_rc.py \ bin/resources/ui_carla_about.py \ bin/resources/ui_carla_about_juce.py \ @@ -352,7 +353,8 @@ WIDGETS = \ source/paramspinbox.py \ source/pixmapbutton.py \ source/pixmapdial.py \ - source/pixmapkeyboard.py + source/pixmapkeyboard.py \ + source/racklistwidget.py WIDGETS: $(WIDGETS) @@ -538,6 +540,7 @@ endif $(LINK) $(PREFIX)/share/carla/pixmapbutton.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/pixmapdial.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/pixmapkeyboard.py $(DESTDIR)$(PREFIX)/share/carla/resources/ + $(LINK) $(PREFIX)/share/carla/racklistwidget.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/resources_rc.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_about.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_about_juce.py $(DESTDIR)$(PREFIX)/share/carla/resources/ diff --git a/resources/ui/carla_host.ui b/resources/ui/carla_host.ui index 016381052..1f0ae3a8e 100644 --- a/resources/ui/carla_host.ui +++ b/resources/ui/carla_host.ui @@ -57,20 +57,7 @@ - - - QFrame::NoFrame - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - + @@ -814,6 +801,11 @@
digitalpeakmeter.h
1 + + RackListWidget + QListWidget +
racklistwidget.h
+
diff --git a/source/carla_host.py b/source/carla_host.py index e0aed2185..acf527803 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -642,7 +642,7 @@ class HostWindow(QMainWindow, PluginEditParentMeta): self.ui.act_plugin_remove_all.setEnabled(False) patchcanvas.handleAllPluginsRemoved() - while self.ui.rack.takeItem(0): + while self.ui.listWidget.takeItem(0): pass self.clearSideStuff() diff --git a/source/carla_rack.py b/source/carla_rack.py index 122b867ad..da05685cb 100644 --- a/source/carla_rack.py +++ b/source/carla_rack.py @@ -38,65 +38,6 @@ else: from carla_host import * from carla_skin import * -# ------------------------------------------------------------------------------------------------------------ -# Rack widget item - -class CarlaRackItem(QListWidgetItem): - kRackItemType = QListWidgetItem.UserType + 1 - - def __init__(self, parent, pluginId, useSkins): - QListWidgetItem.__init__(self, parent, self.kRackItemType) - - # ---------------------------------------------------------------------------------------------------- - # Internal stuff - - self.fParent = parent - self.fPluginId = pluginId - self.fUseSkins = useSkins - self.fWidget = None - - self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) - #self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled|Qt.ItemIsDropEnabled) - - # ---------------------------------------------------------------------------------------------------- - # Set-up GUI - - self.recreateWidget() - - if False: - self.fWidget = AbstractPluginSlot(parent, parent.host, pluginId) - - # -------------------------------------------------------------------------------------------------------- - - def setPluginId(self, pluginId): - self.fPluginId = pluginId - self.fWidget.setPluginId(pluginId) - - # -------------------------------------------------------------------------------------------------------- - - def getEditDialog(self): - return self.fWidget.fEditDialog - - def closeEditDialog(self): - self.fWidget.fEditDialog.close() - - # -------------------------------------------------------------------------------------------------------- - - def getWidget(self): - return self.fWidget - - def recreateWidget(self): - if self.fWidget is not None: - #self.fWidget.fEditDialog.close() - del self.fWidget - - self.fWidget = createPluginSlot(self.fParent, self.fParent.host, self.fPluginId, self.fUseSkins) - self.fWidget.setFixedHeight(self.fWidget.getFixedHeight()) - - self.setSizeHint(QSize(640, self.fWidget.getFixedHeight())) - - self.fParent.setItemWidget(self, self.fWidget) - # ------------------------------------------------------------------------------------------------------------ # Rack widget list diff --git a/source/widgets/racklistwidget.py b/source/widgets/racklistwidget.py new file mode 100644 index 000000000..1be9ec9b1 --- /dev/null +++ b/source/widgets/racklistwidget.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Rack List Widget, a custom Qt4 widget +# Copyright (C) 2011-2014 Filipe Coelho +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# For a full copy of the GNU General Public License see the doc/GPL.txt file. + +# ------------------------------------------------------------------------------------------------------------ +# Imports (Config) + +from carla_config import * + +# ------------------------------------------------------------------------------------------------------------ +# Imports (Global) + +if config_UseQt5: + from PyQt5.QtCore import Qt, QSize + from PyQt5.QtGui import QPainter, QPixmap + from PyQt5.QtWidgets import QAbstractItemView, QFrame, QListWidget, QListWidgetItem +else: + from PyQt4.QtCore import Qt, QSize + from PyQt4.QtGui import QAbstractItemView, QFrame, QListWidget, QListWidgetItem, QPainter, QPixmap + +# ------------------------------------------------------------------------------------------------------------ +# Imports (Custom Stuff) + +from carla_skin import createPluginSlot + +# ------------------------------------------------------------------------------------------------------------ +# Rack Widget item + +class CarlaRackItem(QListWidgetItem): + kRackItemType = QListWidgetItem.UserType + 1 + + def __init__(self, parent, pluginId, useSkins): + QListWidgetItem.__init__(self, parent, self.kRackItemType) + self.host = parent.host + + if False: + # kdevelop likes this :) + from carla_backend import CarlaHostMeta + host = CarlaHostMeta() + self.host = host + + # ---------------------------------------------------------------------------------------------------- + # Internal stuff + + self.fParent = parent + self.fPluginId = pluginId + self.fUseSkins = useSkins + self.fWidget = None + + self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) + #self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled|Qt.ItemIsDropEnabled) + + # ---------------------------------------------------------------------------------------------------- + # Set-up GUI + + self.recreateWidget() + + # -------------------------------------------------------------------------------------------------------- + + def closeEditDialog(self): + self.fWidget.fEditDialog.close() + + def getEditDialog(self): + return self.fWidget.fEditDialog + + def getWidget(self): + return self.fWidget + + # -------------------------------------------------------------------------------------------------------- + + def setPluginId(self, pluginId): + self.fPluginId = pluginId + self.fWidget.setPluginId(pluginId) + + # -------------------------------------------------------------------------------------------------------- + + def recreateWidget(self): + if self.fWidget is not None: + #self.fWidget.fEditDialog.close() + del self.fWidget + + self.fWidget = createPluginSlot(self.fParent, self.fParent.host, self.fPluginId, self.fUseSkins) + self.fWidget.setFixedHeight(self.fWidget.getFixedHeight()) + + self.setSizeHint(QSize(640, self.fWidget.getFixedHeight())) + + self.fParent.setItemWidget(self, self.fWidget) + +# ------------------------------------------------------------------------------------------------------------ +# Rack Widget + +class RackListWidget(QListWidget): + def __init__(self, parent): + QListWidget.__init__(self, parent) + + self.fSupportedExtensions = [] + self.fWasLastDragValid = False + + self.setMinimumWidth(700) + self.setSelectionMode(QAbstractItemView.SingleSelection) + self.setSortingEnabled(False) + + self.setDragEnabled(True) + self.setDragDropMode(QAbstractItemView.DropOnly) + self.setDropIndicatorShown(True) + self.viewport().setAcceptDrops(True) + + self.setFrameShape(QFrame.NoFrame) + self.setFrameShadow(QFrame.Plain) + + self.fPixmapL = QPixmap(":/bitmaps/rack_interior_left.png") + self.fPixmapR = QPixmap(":/bitmaps/rack_interior_right.png") + + self.fPixmapWidth = self.fPixmapL.width() + + # -------------------------------------------------------------------------------------------------------- + + def paintEvent(self, event): + painter = QPainter(self.viewport()) + painter.drawTiledPixmap(0, 0, self.fPixmapWidth, self.height(), self.fPixmapL) + painter.drawTiledPixmap(self.width()-self.fPixmapWidth-2, 0, self.fPixmapWidth, self.height(), self.fPixmapR) + QListWidget.paintEvent(self, event) + +# ------------------------------------------------------------------------------------------------------------