From 4bb7fc38bc2fd0fc26e2034a710f3f4b709edda9 Mon Sep 17 00:00:00 2001 From: Flavio Tarsetti Date: Wed, 27 Nov 2019 13:27:01 +0100 Subject: [PATCH] [widgets][toolchaineditor] add default color channel if none found --- beat/editor/widgets/toolchaineditor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/beat/editor/widgets/toolchaineditor.py b/beat/editor/widgets/toolchaineditor.py index b983f12..80041e8 100644 --- a/beat/editor/widgets/toolchaineditor.py +++ b/beat/editor/widgets/toolchaineditor.py @@ -389,7 +389,7 @@ class Connection(QGraphicsPathItem): self.end_pin_name = connection_details["to"].split(".")[1] self.channel = connection_details["channel"] - if self.channel is None or self.channel not in channel_colors: + if self.channel is None: warning = QMessageBox() warning.setIcon(QMessageBox.Warning) warning.setWindowTitle(toolchain.tr("Connection creation")) @@ -400,6 +400,21 @@ class Connection(QGraphicsPathItem): warning.exec_() else: + if self.channel not in channel_colors: + toolchain.web_representation["channel_colors"][self.channel] = "#000000" + channel_colors = toolchain.web_representation["channel_colors"] + + warning = QMessageBox() + warning.setIcon(QMessageBox.Warning) + warning.setWindowTitle(toolchain.tr("Channel color")) + warning.setInformativeText( + toolchain.tr( + "No channel color found. Assigning default black color" + ) + ) + warning.setStandardButtons(QMessageBox.Ok) + warning.exec_() + hexadecimal = channel_colors[self.channel].lstrip("#") hlen = len(hexadecimal) self.connection_color = list( -- 2.21.0