Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
3d44bde1
Commit
3d44bde1
authored
Nov 22, 2019
by
Flavio TARSETTI
Browse files
[widgets][toolchaineditor] datasets color picker and channel color update
parent
707241b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/toolchaineditor.py
View file @
3d44bde1
...
...
@@ -60,6 +60,7 @@ from PyQt5.QtWidgets import QPushButton
from
PyQt5.QtWidgets
import
QMenu
from
PyQt5.QtWidgets
import
QLineEdit
from
PyQt5.QtWidgets
import
QMessageBox
from
PyQt5.QtWidgets
import
QColorDialog
from
..backend.asset
import
Asset
from
..backend.asset
import
AssetType
...
...
@@ -395,6 +396,7 @@ class BlockEditionDialog(QDialog):
toolchain
=
block
.
toolchain
self
.
setWindowTitle
(
self
.
tr
(
"Block Edition"
))
self
.
name_lineedit
=
QLineEdit
(
block
.
name
)
self
.
color
=
"#000000"
self
.
channel_combobox
=
QComboBox
()
no_channel_label
=
QLabel
(
self
.
tr
(
"No input connections yet!"
))
no_dataset_channel_label
=
QLabel
(
self
.
tr
(
"No synchronization for datasets"
))
...
...
@@ -403,8 +405,13 @@ class BlockEditionDialog(QDialog):
layout
.
addRow
(
self
.
tr
(
"Name:"
),
self
.
name_lineedit
)
channels
=
[]
if
block
.
type
==
BlockType
.
DATASETS
.
name
:
channel_color_button
=
QPushButton
(
"Channel color"
,
self
)
channel_color_button
.
setToolTip
(
"Opens color dialog"
)
channel_color_button
.
clicked
.
connect
(
self
.
on_color_click
)
layout
.
addRow
(
self
.
tr
(
"Channel:"
),
no_dataset_channel_label
)
layout
.
addRow
(
self
.
tr
(
"Channel color:"
),
channel_color_button
)
elif
block
.
synchronized_channel
is
None
:
layout
.
addRow
(
self
.
tr
(
"Channel:"
),
no_channel_label
)
else
:
...
...
@@ -432,12 +439,23 @@ class BlockEditionDialog(QDialog):
self
.
buttons
.
accepted
.
connect
(
self
.
accept
)
self
.
buttons
.
rejected
.
connect
(
self
.
reject
)
@
pyqtSlot
()
def
on_color_click
(
self
):
self
.
colorDialog
()
def
colorDialog
(
self
):
color
=
QColorDialog
.
getColor
()
if
color
.
isValid
():
self
.
color
=
color
.
name
().
capitalize
()
def
value
(
self
):
"""Returns the value selected"""
return
{
"name"
:
self
.
name_lineedit
.
text
(),
"channel"
:
self
.
channel_combobox
.
currentText
(),
"color"
:
self
.
color
,
}
@
staticmethod
...
...
@@ -715,6 +733,11 @@ class Block(QGraphicsObject):
):
self
.
synchronized_channel
=
value
[
"channel"
]
block_updated
=
True
if
self
.
type
==
BlockType
.
DATASETS
.
name
:
self
.
toolchain
.
web_representation
[
"channel_colors"
][
self
.
name
]
=
value
[
"color"
]
block_updated
=
True
if
block_updated
:
# Update blocks
...
...
@@ -751,6 +774,27 @@ class Block(QGraphicsObject):
if
connection
.
channel
==
old_name
:
connection
.
channel
=
self
.
name
# color update
self
.
toolchain
.
scene
.
removeItem
(
connection
)
# Find the corresponding channel
connection_settings
=
{}
connection_settings
[
"channel"
]
=
connection
.
channel
# Create the connection
connection_settings
[
"from"
]
=
(
connection
.
start_block_name
+
"."
+
connection
.
start_pin_name
)
connection_settings
[
"to"
]
=
(
connection
.
end_block_name
+
"."
+
connection
.
end_pin_name
)
channel_colors
=
self
.
toolchain
.
json_object
.
get
(
"representation"
,
{}
).
get
(
"channel_colors"
)
connection
.
load
(
self
.
toolchain
,
connection_settings
,
channel_colors
)
self
.
toolchain
.
scene
.
addItem
(
connection
)
# Complete toolchain channel update from current block
if
old_channel
!=
self
.
synchronized_channel
:
self
.
toolchain
.
update_channel_path
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment