diff options
author | Roopesh Chander <roop@forwardbias.in> | 2009-10-22 20:37:26 +0530 |
---|---|---|
committer | Roopesh Chander <roop@forwardbias.in> | 2009-10-22 20:37:26 +0530 |
commit | 7ec741042396523e6fe91d047d8d76cec242343e (patch) | |
tree | b7465db01a327a18ce8fcb5a91593bac7c56d808 /graphicstoolbar.cpp | |
parent | 0f2eb7a23dcbf1450d2a0e280f7fe48c281b9989 (diff) |
now for a really funky way of showing load progress :)
Diffstat (limited to 'graphicstoolbar.cpp')
-rw-r--r-- | graphicstoolbar.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/graphicstoolbar.cpp b/graphicstoolbar.cpp index e4e0901..4149c83 100644 --- a/graphicstoolbar.cpp +++ b/graphicstoolbar.cpp @@ -6,6 +6,7 @@ GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent, wFlags) , m_scene(scene) + , m_fillLevel(100) { m_scene->addItem(this); m_layout = new QGraphicsLinearLayout(Qt::Horizontal, this); @@ -60,8 +61,13 @@ QBrush GraphicsToolBar::backgroundBrush() const { return m_bgBrush; } +void GraphicsToolBar::setFillLevel(int percent) { + m_fillLevel = qMax(0, qMin(percent, 100)); +} + void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *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->drawRoundedRect(boundingRect(), 10, 10); |