Skip to content

Commit a29975e

Browse files
enable attribute info expand
1 parent 43a8e78 commit a29975e

File tree

4 files changed

+53
-64
lines changed

4 files changed

+53
-64
lines changed

flowpipe_editor/attributes/__init__.py

Whitespace-only changes.

flowpipe_editor/attributes/attribute_widgets.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

flowpipe_editor/attributes/attributes_widget.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

flowpipe_editor/widgets/properties_bin/attribute_widgets.py

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
11
"""AttributesWidget for displaying flowpipe node attributes in a Qt Widget."""
22

3+
from __future__ import annotations
4+
35
import json
46

7+
from flowpipe.plug import IPlug
8+
59
# pylint: disable=no-name-in-module
6-
from Qt import QtWidgets
10+
from Qt import QtGui, QtWidgets
711

8-
from flowpipe.plug import IPlug
12+
13+
class PopeUpLineEdit(QtWidgets.QLineEdit):
14+
"""A QLineEdit that opens a popup dialog on double-click to show/edit its content."""
15+
16+
def __init__(self, label: str, parent: QtWidgets.QWidget = None):
17+
super().__init__(parent)
18+
self.label = label
19+
20+
def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent):
21+
# Open popup dialog on double-click
22+
dialog = PopupDialog(self.label, self.text(), self)
23+
dialog.exec_()
24+
# Optionally call the parent event if you still want default behavior
25+
super().mouseDoubleClickEvent(event)
26+
27+
28+
class PopupDialog(QtWidgets.QDialog):
29+
"""A popup dialog that displays a larger text area for editing/viewing content."""
30+
31+
def __init__(
32+
self, label: str, value: str, parent: QtWidgets.QWidget = None
33+
):
34+
super().__init__(parent=parent)
35+
self.setWindowTitle(label)
36+
self.resize(400, 400)
37+
38+
layout = QtWidgets.QVBoxLayout()
39+
40+
self.input_field = QtWidgets.QTextEdit()
41+
self.input_field.setText(value)
42+
self.input_field.setReadOnly(True)
43+
layout.addWidget(self.input_field)
44+
45+
buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok)
46+
buttons.accepted.connect(self.accept)
47+
layout.addWidget(buttons)
48+
49+
self.setLayout(layout)
50+
51+
52+
class IPlugWidget(QtWidgets.QWidget):
53+
"""Base class for plug widgets."""
54+
55+
def __init__(self, parent: QtWidgets.QWidget, plug=None):
56+
super().__init__(parent)
57+
self.plug = plug
958

1059

1160
class DefaultPlugWidget(QtWidgets.QWidget):
@@ -21,10 +70,10 @@ def __init__(self, parent: QtWidgets, plug: IPlug):
2170
self.plug = plug
2271
self.setLayout(QtWidgets.QVBoxLayout(self))
2372
self.layout().setContentsMargins(0, 0, 0, 0)
24-
self.lineedit = QtWidgets.QLineEdit(self)
73+
self.lineedit = PopeUpLineEdit(self.plug.name, self)
2574
if isinstance(self.plug.value, dict):
2675
try:
27-
self.lineedit.setText(json.dumps(self.plug.value))
76+
self.lineedit.setText(json.dumps(self.plug.value, indent=1))
2877
except TypeError:
2978
# If the value cannot be serialized, fall back to str
3079
self.lineedit.setText(str(self.plug.value))

0 commit comments

Comments
 (0)