From e57923c7d767f5a532bc35571d74a5470eb76314 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 5 Apr 2018 14:21:24 +0200 Subject: built-in style palette --- src/data/nodestyle.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/data') diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp index 302ab84..b3d72fb 100644 --- a/src/data/nodestyle.cpp +++ b/src/data/nodestyle.cpp @@ -26,6 +26,8 @@ QString NodeStyle::name() const NodeStyle::Shape NodeStyle::shape() const { + if (_data == 0) return NodeStyle::Circle; + QString sh = _data->property("shape"); if (sh.isNull()) return NodeStyle::Circle; else if (sh == "circle") return NodeStyle::Circle; @@ -35,6 +37,8 @@ NodeStyle::Shape NodeStyle::shape() const QColor NodeStyle::fillColor() const { + if (_data == 0) return Qt::white; + QString col = _data->property("fill"); if (col.isNull()) { @@ -52,6 +56,8 @@ QColor NodeStyle::fillColor() const QColor NodeStyle::strokeColor() const { + if (_data == 0) return Qt::black; + QString col = _data->property("draw"); if (col.isNull()) { @@ -103,11 +109,29 @@ QIcon NodeStyle::icon() const px.fill(Qt::transparent); QPainter painter(&px); QPainterPath pth = path(); - painter.setPen(pen()); - painter.setBrush(brush()); - pth.translate(50.0f, 50.0f); - painter.drawPath(pth); + + if (_data == 0) { + QColor c(180,180,200); + painter.setPen(QPen(c)); + painter.setBrush(QBrush(c)); + painter.drawEllipse(QPointF(50.0f,50.0f), 3,3); + + QPen pen(QColor(180,180,220)); + pen.setWidth(3); + QVector p; + p << 2.0 << 2.0; + pen.setDashPattern(p); + painter.setPen(pen); + painter.setBrush(Qt::NoBrush); + painter.drawPath(pth); + } else { + painter.setPen(pen()); + painter.setBrush(brush()); + painter.drawPath(pth); + } + + return QIcon(px); } -- cgit v1.2.3