summaryrefslogtreecommitdiffstats
path: root/graphicstoolbar.cpp
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-10-23 13:51:29 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-10-23 13:51:29 +0530
commitea9d7a4a3b4eb65f1a26486acf1087b006b542ce (patch)
treed4fb73577b13e6c1080e7ffa46bef06a8c4f1ba5 /graphicstoolbar.cpp
parent6561ebe90cf7b5747a4a98775dd774ce2f13be66 (diff)
fill level fills inside the rect, rather than being the rect
Diffstat (limited to 'graphicstoolbar.cpp')
-rw-r--r--graphicstoolbar.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/graphicstoolbar.cpp b/graphicstoolbar.cpp
index 1e74601..25bb17c 100644
--- a/graphicstoolbar.cpp
+++ b/graphicstoolbar.cpp
@@ -19,6 +19,7 @@ GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent,
setFlag(QGraphicsItem::ItemIsMovable);
setAcceptHoverEvents(true);
+ m_fillLevelBrush = QBrush(Qt::transparent);
QLinearGradient bgGradient;
bgGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
bgGradient.setStart(0, 0);
@@ -73,6 +74,14 @@ QBrush GraphicsToolBar::backgroundBrush() const {
return m_bgBrush;
}
+void GraphicsToolBar::setFillLevelBrush(QBrush brush) {
+ m_fillLevelBrush = brush;
+}
+
+QBrush GraphicsToolBar::fillLevelBrush() const {
+ return m_fillLevelBrush;
+}
+
void GraphicsToolBar::setFillLevel(int percent) {
m_fillLevel = qMax(0, qMin(percent, 100));
}
@@ -81,9 +90,11 @@ void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
Q_UNUSED(option);
Q_UNUSED(widget);
painter->save();
- painter->setClipRect(boundingRect().adjusted(0, boundingRect().height() * ((100 - m_fillLevel) / 100.0), 0, 0));
- painter->setBrush(m_bgBrush);
painter->setPen(Qt::NoPen);
+ painter->setBrush(m_bgBrush);
+ painter->drawRoundedRect(boundingRect(), 10, 10);
+ painter->setClipRect(boundingRect().adjusted(0, boundingRect().height() * ((100 - m_fillLevel) / 100.0), 0, 0));
+ painter->setBrush(m_fillLevelBrush);
painter->drawRoundedRect(boundingRect(), 10, 10);
painter->restore();
}