diff --git a/.travis/script-pylint.sh b/.travis/script-pylint.sh index a85e3edf7..d50c338be 100755 --- a/.travis/script-pylint.sh +++ b/.travis/script-pylint.sh @@ -21,9 +21,12 @@ ${pylint} \ --max-statements=100 \ --disable=\ bad-whitespace,\ +broad-except,\ +fixme,\ invalid-name,\ missing-docstring \ - source/frontend/widgets/canvaspreviewframe.py + source/frontend/widgets/canvaspreviewframe.py \ + source/frontend/widgets/racklistwidget.py # main app code, ignore some errors ${pylint} \ diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 74f0ecdf7..6c4baffbf 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -789,13 +789,14 @@ class HostWindow(QMainWindow): if self.fCustomStopAction == self.CUSTOM_ACTION_APP_CLOSE or not self.fWithCanvas: return - QTimer.singleShot(1000, self.slot_canvasRefresh) + self.loadExternalCanvasGroupPositionsIfNeeded(self.fProjectFilename) - extrafile = self.fProjectFilename.rsplit(".",1)[0]+".json" + def loadExternalCanvasGroupPositionsIfNeeded(self, filename): + extrafile = filename.rsplit(".",1)[0]+".json" if not os.path.exists(extrafile): return - with open(self.fProjectFilename, "r") as fh: + with open(filename, "r") as fh: if "".join(fh.readlines(90)).find("") < 0: return @@ -806,6 +807,7 @@ class HostWindow(QMainWindow): return patchcanvas.restoreGroupPositions(canvasdata) + QTimer.singleShot(1000, self.slot_canvasRefresh) # -------------------------------------------------------------------------------------------------------- # Files (menu actions) @@ -2052,6 +2054,10 @@ class HostWindow(QMainWindow): CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load file"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + return + + if filename.endswith(".carxp"): + self.loadExternalCanvasGroupPositionsIfNeeded(filename) # -------------------------------------------------------------------------------------------------------- # Transport diff --git a/source/frontend/carla_shared.py b/source/frontend/carla_shared.py index 9ca5e4821..262514a43 100644 --- a/source/frontend/carla_shared.py +++ b/source/frontend/carla_shared.py @@ -16,13 +16,6 @@ # # For a full copy of the GNU General Public License see the doc/GPL.txt file. -# ------------------------------------------------------------------------------------------------------------ -# Config - -# These will be modified during install -X_LIBDIR_X = None -X_DATADIR_X = None - # ------------------------------------------------------------------------------------------------------------ # Imports (Global) @@ -62,6 +55,13 @@ from carla_backend import ( ENGINE_TRANSPORT_MODE_JACK ) +# ------------------------------------------------------------------------------------------------------------ +# Config + +# These will be modified during install +X_LIBDIR_X = None +X_DATADIR_X = None + # ------------------------------------------------------------------------------------------------------------ # Platform specific stuff diff --git a/source/frontend/widgets/racklistwidget.py b/source/frontend/widgets/racklistwidget.py index f68f235a2..8bbd51322 100644 --- a/source/frontend/widgets/racklistwidget.py +++ b/source/frontend/widgets/racklistwidget.py @@ -19,14 +19,21 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) +import os + +# ------------------------------------------------------------------------------------------------------------ +# Imports (PyQt5) + from PyQt5.QtCore import Qt, QSize, QRect, QEvent -from PyQt5.QtGui import QPainter, QPixmap -from PyQt5.QtWidgets import QAbstractItemView, QFrame, QListWidget, QListWidgetItem +from PyQt5.QtGui import QColor, QPainter, QPixmap +from PyQt5.QtWidgets import QAbstractItemView, QListWidget, QListWidgetItem, QMessageBox # ------------------------------------------------------------------------------------------------------------ # Imports (Custom Stuff) -from carla_skin import * +from carla_backend import CUSTOM_DATA_TYPE_PROPERTY, MACOS +from carla_shared import gCarla, CustomMessageBox +from carla_skin import createPluginSlot # ------------------------------------------------------------------------------------------------------------ # Rack Widget item @@ -39,13 +46,6 @@ class RackListItem(QListWidgetItem): QListWidgetItem.__init__(self, parent, self.kRackItemType) self.host = parent.host - if False: - # kdevelop likes this :) - parent = RackListWidget() - host = CarlaHostNull() - self.host = host - self.fWidget = AbstractPluginSlot() - # ---------------------------------------------------------------------------------------------------- # Internal stuff @@ -55,13 +55,15 @@ class RackListItem(QListWidgetItem): color = self.host.get_custom_data_value(pluginId, CUSTOM_DATA_TYPE_PROPERTY, "CarlaColor") skin = self.host.get_custom_data_value(pluginId, CUSTOM_DATA_TYPE_PROPERTY, "CarlaSkin") - compact = bool(self.host.get_custom_data_value(pluginId, CUSTOM_DATA_TYPE_PROPERTY, "CarlaSkinIsCompacted") == "true") + compact = bool(self.host.get_custom_data_value(pluginId, + CUSTOM_DATA_TYPE_PROPERTY, + "CarlaSkinIsCompacted") == "true") if color: try: color = tuple(int(i) for i in color.split(";",3)) - except: - print("Color value decode failed for", color) + except Exception as e: + print("Color value decode failed for", color, "error was:", e) color = None else: color = None @@ -209,11 +211,6 @@ class RackListWidget(QListWidget): self.host = None self.fParent = None - if False: - # kdevelop likes this :) - from carla_backend import CarlaHostMeta - self.host = host = CarlaHostNull() - exts = gCarla.utils.get_supported_file_extensions() self.fSupportedExtensions = tuple(("." + i) for i in exts) @@ -233,7 +230,7 @@ class RackListWidget(QListWidget): self.setDropIndicatorShown(True) self.viewport().setAcceptDrops(True) - self.updateStyle() + self._updateStyle() # -------------------------------------------------------------------------------------------------------- @@ -262,7 +259,7 @@ class RackListWidget(QListWidget): #return True if MACOS and lfilename.endswith(".vst"): return True - elif lfilename.endswith(".vst3") and ".vst3" in self.fSupportedExtensions: + if lfilename.endswith(".vst3") and ".vst3" in self.fSupportedExtensions: return True elif os.path.isfile(filename): @@ -300,8 +297,12 @@ class RackListWidget(QListWidget): self.setCurrentRow(-1) def dragLeaveEvent(self, event): + if not self.fWasLastDragValid: + QListWidget.dragLeaveEvent(self, event) + return + + event.acceptProposedAction() self.fWasLastDragValid = False - QListWidget.dragLeaveEvent(self, event) # -------------------------------------------------------------------------------------------------------- @@ -337,8 +338,12 @@ class RackListWidget(QListWidget): if not self.host.load_file(filename): CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), - self.tr("Failed to load file"), - self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + self.tr("Failed to load file"), + self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + continue + + if filename.endswith(".carxp"): + gCarla.gui.loadExternalCanvasGroupPositionsIfNeeded(filename) if tryItem is not None: self.host.replace_plugin(self.host.get_max_plugin_number()) @@ -356,8 +361,8 @@ class RackListWidget(QListWidget): def changeEvent(self, event): if event.type() in (QEvent.StyleChange, QEvent.PaletteChange): - self.updateStyle() - QWidget.changeEvent(self, event) + self._updateStyle() + QListWidget.changeEvent(self, event) def paintEvent(self, event): painter = QPainter(self.viewport()) @@ -367,7 +372,7 @@ class RackListWidget(QListWidget): imgL_rect = QRect(0, 0, self.fPixmapWidth, height) imgR_rect = QRect(width-self.fPixmapWidth, 0, self.fPixmapWidth, height) - painter.setBrush(self.rail_color) + painter.setBrush(self.rail_col) painter.setPen(Qt.NoPen) painter.drawRects(imgL_rect, imgR_rect) painter.setCompositionMode(QPainter.CompositionMode_Multiply) @@ -378,26 +383,12 @@ class RackListWidget(QListWidget): painter.drawTiledPixmap(imgR_rect, self.fPixmapR) painter.setCompositionMode(QPainter.CompositionMode_SourceOver) - painter.setPen(self.edge_color) + painter.setPen(self.edge_col) painter.setBrush(Qt.NoBrush) painter.drawRect(self.fPixmapWidth, 0, width-self.fPixmapWidth*2, height) QListWidget.paintEvent(self, event) - # -------------------------------------------------------------------------------------------------------- - - def updateStyle(self): - palette = self.palette() - - bg_color = palette.window().color() - base_color = palette.base().color() - text_color = palette.text().color() - r0,g0,b0,a = bg_color.getRgb() - r1,g1,b1,a = text_color.getRgb() - - self.rail_color = QColor((r0*3+r1)/4, (g0*3+g1)/4, (b0*3+b1)/4) - self.edge_color = self.rail_color.darker(115) if self.rail_color.blackF() > base_color.blackF() else base_color.darker(115) - def selectionChanged(self, selected, deselected): for index in deselected.indexes(): item = self.itemFromIndex(index) @@ -411,4 +402,18 @@ class RackListWidget(QListWidget): QListWidget.selectionChanged(self, selected, deselected) + # -------------------------------------------------------------------------------------------------------- + + def _updateStyle(self): + palette = self.palette() + + bg_color = palette.window().color() + base_color = palette.base().color() + text_color = palette.text().color() + r0,g0,b0,_ = bg_color.getRgb() + r1,g1,b1,_ = text_color.getRgb() + + self.rail_col = QColor((r0*3+r1)/4, (g0*3+g1)/4, (b0*3+b1)/4) + self.edge_col = (self.rail_col if self.rail_col.blackF() > base_color.blackF() else base_color).darker(115) + # ------------------------------------------------------------------------------------------------------------