Browse Source

Use ui_base properties.

main
Ben Niemann 11 months ago
parent
commit
d31f7f8068
  1. 22
      noisicaa/ui/qml/GraphConnection.py
  2. 2
      noisicaa/ui/ui_base.py

22
noisicaa/ui/qml/GraphConnection.py

@ -35,37 +35,27 @@ from .GraphNode import GraphNodeWrapper
logger = logging.getLogger(__name__)
class GraphConnectionWrapper(ui_base.ProjectMixin, QtCore.QObject):
class GraphConnectionWrapper(ui_base.ProjectMixin, ui_base.PropertyContainer, QtCore.QObject):
highlighted, highlightedChanged = ui_base.Property('highlighted', bool)
def __init__(self, *, connection, nodeMap, **kwargs):
super().__init__(**kwargs)
self.__connection = connection
self.__highlighted = False
self.__srcNode = nodeMap[self.__connection.srcNodeId]
self.__destNode = nodeMap[self.__connection.destNodeId]
def __str__(self):
return '<{} {}>'.format(type(self).__name__, self.__connection)
@ui_base.ConstProperty(model.Connection)
def connection(self):
return self.__connection
connection = QtCore.Property(model.Connection, fget=connection, constant=True)
@ui_base.ConstProperty(GraphNodeWrapper)
def srcNode(self):
return self.__srcNode
srcNode = QtCore.Property(GraphNodeWrapper, fget=srcNode, constant=True)
@ui_base.ConstProperty(GraphNodeWrapper)
def destNode(self):
return self.__destNode
destNode = QtCore.Property(GraphNodeWrapper, fget=destNode, constant=True)
def getHighlighted(self):
return self.__highlighted
def setHighlighted(self, p):
if p == self.__highlighted:
return
self.__highlighted = p
self.highlightedChanged.emit(p)
highlightedChanged = QtCore.Signal(float)
highlighted = QtCore.Property(float, fget=getHighlighted, fset=setHighlighted, notify=highlightedChanged)

2
noisicaa/ui/ui_base.py

@ -91,7 +91,7 @@ def Property(name, pytype, qtype=None, *, default=None, validate=None):
return prop, sig
class PropertyContainer(QtCore.QObject):
class PropertyContainer(object):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

Loading…
Cancel
Save