diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-05-07 23:00:05 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-08 14:18:27 -0700 |
commit | 76e1436f684117766c5132c4ab69bf7ae50cd2ed (patch) | |
tree | 4fe152f164e5af1a9e605d13d4ace70526470117 | |
parent | b5d5b05140eac7a8031cdb15e7c31f659a6f2da6 (diff) | |
download | subsurface-76e1436f684117766c5132c4ab69bf7ae50cd2ed.tar.gz |
Better design for the ToolTip Handler.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/profilegraphics.cpp | 28 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 2 |
2 files changed, 18 insertions, 12 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index a9a7c93f8..e2fed39c5 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -665,25 +665,30 @@ void ToolTipItem::setRect(const QRectF& r) { // qDeleteAll(childItems()); - if (background) { - childItems().removeAt(childItems().indexOf(background)); - delete background; - } + delete background; rectangle = r; setBrush(QBrush(Qt::white)); setPen(QPen(Qt::black, 0.5)); + // Creates a 2pixels border QPainterPath border; - border.addRoundedRect(-2, -2, rectangle.width() + 4, rectangle.height()+ 4, 3, 3); - border.addRoundedRect( 0, 0, rectangle.width(), rectangle.height(), 3, 3); + border.addRoundedRect(-4, -4, rectangle.width() + 8, rectangle.height() + 10, 3, 3); + border.addRoundedRect(-1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3); setPath(border); - QGraphicsRectItem *b = new QGraphicsRectItem(-1, -1, rectangle.width()+1, rectangle.height()+1, this); - b->setFlag(ItemStacksBehindParent); + QPainterPath bg; + bg.addRoundedRect( -1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3); + QColor c = QColor(Qt::black); c.setAlpha(155); + + QGraphicsPathItem *b = new QGraphicsPathItem(bg, this); + b->setFlag(ItemStacksBehindParent); + b->setFlags(ItemIgnoresTransformations); b->setBrush(c); + b->setPen(QPen(QBrush(Qt::transparent), 0)); + b->setZValue(-10); background = b; updateTitlePosition(); @@ -753,7 +758,7 @@ void ToolTipItem::updateTitlePosition() setRect(newRect); } - title->setPos(boundingRect().width()/2 -title->boundingRect().width()/2, 0); + title->setPos(boundingRect().width()/2 - title->boundingRect().width()/2 -1, 0); title->setFlag(ItemIgnoresTransformations); title->setPen(QPen(Qt::white, 1)); title->setBrush(Qt::white); @@ -761,14 +766,15 @@ void ToolTipItem::updateTitlePosition() if (toolTips.size() > 0){ double x1 = 0; double y1 = title->pos().y() + SPACING/2 + title->boundingRect().height(); - double x2 = boundingRect().width() - 4; + double x2 = boundingRect().width() - 10; double y2 = y1; separator->setLine(x1, y1, x2, y2); separator->setFlag(ItemIgnoresTransformations); separator->setPen(QPen(Qt::white)); + separator->show(); }else{ - separator->setLine(QLineF()); + separator->hide(); } } diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index c1668692d..1c9238bee 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -59,7 +59,7 @@ public Q_SLOTS: private: typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip; QMap<QString, ToolTip > toolTips; - QGraphicsRectItem *background; + QGraphicsPathItem *background; QGraphicsLineItem *separator; QGraphicsSimpleTextItem *title; |