From 52a8b281d565ed3a4255671b1efcf7d552b4e70f Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 31 Aug 2011 20:04:04 +0000 Subject: [PATCH] fixed up color codes for qt 4.7 in NetworkGraph (bug in qt::lighter()) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4581 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkView.cpp | 2 +- retroshare-gui/src/gui/elastic/node.cpp | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index cb964397b..e4c29c9bb 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -158,7 +158,7 @@ void NetworkView::updateDisplay() if(!rsPeers->getPeerDetails(info.gpg_id, detail)) continue ; - switch(detail.validLvl) + switch(detail.trustLvl) { case GPGME_VALIDITY_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break; case GPGME_VALIDITY_FULL: diff --git a/retroshare-gui/src/gui/elastic/node.cpp b/retroshare-gui/src/gui/elastic/node.cpp index 69b9c112f..4aa8f6b4a 100644 --- a/retroshare-gui/src/gui/elastic/node.cpp +++ b/retroshare-gui/src/gui/elastic/node.cpp @@ -79,6 +79,9 @@ Node::Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget _speedx=_speedy=0; _steps=0; + + if(_type == GraphWidget::ELASTIC_NODE_TYPE_OWN) + _auth = GraphWidget::ELASTIC_NODE_AUTH_FULL ; } void Node::addEdge(Edge *edge) @@ -239,6 +242,19 @@ QPainterPath Node::shape() const return path; } +#if QT_VERSION >= 0x040700 +static QColor lightdark(const QColor& col,int l,int d) +{ + int h,s,v ; + + col.getHsv(&h,&s,&v) ; + + v = (int)floor(v * l/(float)d ) ; + + return QColor::fromHsv(h,s,v) ; +} +#endif + void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { static QColor type_color[4] = { QColor(Qt::yellow), QColor(Qt::green), QColor(Qt::cyan), QColor(Qt::black) } ; @@ -254,13 +270,23 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid { gradient.setCenter(3, 3); gradient.setFocalPoint(3, 3); +#if QT_VERSION >= 0x040700 + gradient.setColorAt(1, lightdark(col0,120, 100+_auth*50)); + gradient.setColorAt(0, lightdark(col0, 70, 100+_auth*50)); +#else gradient.setColorAt(1, col0.light(120).dark(100+_auth*100)); gradient.setColorAt(0, col0.light(70).dark(100+_auth*100)); +#endif } else { +#if QT_VERSION >= 0x040700 + gradient.setColorAt(1, lightdark(col0, 50,100+_auth*50)); + gradient.setColorAt(0, lightdark(col0,100,100+_auth*50)); +#else gradient.setColorAt(1, col0.light(50).dark(100+_auth*100)); gradient.setColorAt(0, col0.dark(100+_auth*100)); +#endif } painter->setBrush(gradient); painter->setPen(QPen(Qt::black, 0));