コード例 #1
0
ファイル: graphcanvas.py プロジェクト: wrapperband/leo-editor
    def __init__(self, glue, hierarchyLink=False, *args, **kargs):
        """:Parameters:
            - `glue`: glue object owning this

        pass glue object and let it key nodeItems to leo nodes
        """
        # pylint: disable=keyword-arg-before-vararg
        # putting *args first is invalid in Python 2.x.
        self.glue = glue
        super().__init__()
        self.line = QtWidgets.QGraphicsLineItem(*args)

        pen = QtGui.QPen()

        self.line.setZValue(0)
        if not hierarchyLink:
            self.setZValue(1)
            pen.setWidth(2)
        else:
            self.setZValue(0)
            pen.setColor(QtGui.QColor(240, 240, 240))
            pen.setWidth(2)  # (0.5)

        self.line.setPen(pen)
        self.addToGroup(self.line)

        self.head = QtWidgets.QGraphicsPolygonItem()

        if hierarchyLink:
            self.head.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180)))
        else:
            self.head.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0)))

        self.head.setPen(QtGui.QPen(QtConst.NoPen))
        self.addToGroup(self.head)
コード例 #2
0
    def __init__(self, glue, hierarchyLink=False, *args, **kargs):
        """:Parameters:
            - `glue`: glue object owning this

        pass glue object and let it key nodeItems to leo nodes
        """
        self.glue = glue
        QtWidgets.QGraphicsItemGroup.__init__(self)
        self.line = QtWidgets.QGraphicsLineItem(*args)

        pen = QtGui.QPen()

        self.line.setZValue(0)
        if not hierarchyLink:
            self.setZValue(1)
            pen.setWidth(2)
        else:
            self.setZValue(0)
            pen.setColor(QtGui.QColor(240, 240, 240))
            pen.setWidth(2)  # (0.5)

        self.line.setPen(pen)
        self.addToGroup(self.line)

        self.head = QtWidgets.QGraphicsPolygonItem()

        if hierarchyLink:
            self.head.setBrush(QtGui.QBrush(QtGui.QColor(180, 180, 180)))
        else:
            self.head.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0)))

        self.head.setPen(QtGui.QPen(QtConst.NoPen))
        self.addToGroup(self.head)
コード例 #3
0
ファイル: graphcanvas.py プロジェクト: Darriall/leo-editor
    def clearFormatting(self):

        node = self.node[self.lastNodeItem]
        item = self.nodeItem[node]
        # FIXME: need node.clear_formatting()
        if hasattr(item, 'bg'):
            item.bg.setBrush(QtGui.QBrush(QtGui.QColor(200, 240, 200)))
        if hasattr(item, 'text'):
            item.text.setDefaultTextColor(QtGui.QColor(0, 0, 0))
        if 'color' in node.u['_bklnk']:
            del node.u['_bklnk']['color']
        if 'tcolor' in node.u['_bklnk']:
            del node.u['_bklnk']['tcolor']
        self.releaseNode(self.nodeItem[node])
コード例 #4
0
    def clearFormatting(self):

        if self.lastNodeItem not in self.node:
            return
        node = self.node[self.lastNodeItem]
        item = self.nodeItem[node]
        # FIXME: need node.clear_formatting()
        if hasattr(item, 'bg') and hasattr(item.bg, 'setBrush'):
            item.bg.setBrush(QtGui.QBrush(QtGui.QColor(200, 240, 200)))
        if hasattr(item, 'text'):
            item.text.setDefaultTextColor(QtGui.QColor(0, 0, 0))
        if 'color' in node.u['_bklnk']:
            del node.u['_bklnk']['color']
        if 'tcolor' in node.u['_bklnk']:
            del node.u['_bklnk']['tcolor']
        self.releaseNode(self.nodeItem[node])
        self.c.redraw()  # update color of node in the tree too
コード例 #5
0
    def __init__(self, *args, **kargs):
        nodeBase.__init__(self, *args, **kargs)

        self.text = self.text_item()
        # .text must be first for nodeComment, see its bg_item()
        self.bg = self.bg_item()
        if g.app.config.getBool("color_theme_is_dark"):
            bgcolor = QtGui.QColor(30, 50, 30)
        else:
            bgcolor = QtGui.QColor(200, 240, 200)
        self.bg.setBrush(QtGui.QBrush(bgcolor))

        self.setZValue(20)
        self.bg.setZValue(10)
        self.text.setZValue(15)
        self.bg.setPen(QtGui.QPen(QtConst.NoPen))

        self.text.setPos(QtCore.QPointF(0, self.iconVPos))
        self.addToGroup(self.text)

        self.bg.setPos(QtCore.QPointF(0, self.iconVPos))
        self.addToGroup(self.bg)
コード例 #6
0
 def set_bg_color(self, color):
     self.bg.setBrush(QtGui.QBrush(QtGui.QColor(color)))
コード例 #7
0
 def focusOutEvent(self, event):
     QtWidgets.QGraphicsItemGroup.focusOutEvent(self, event)
     self.bg.setBrush(QtGui.QBrush(QtGui.QColor(200, 240, 200)))
     g.es("focusOutEvent")