KDEUI
kcapacitybar.cpp
Go to the documentation of this file.
201 outline.quadTo(rect.left() + drawRect.width() + ROUND_MARGIN / 2, drawRect.height() / 2 + rect.top(), rect.left() + drawRect.width() - ROUND_MARGIN / 4 - 1, drawRect.height() + rect.top());
203 outline.quadTo(-ROUND_MARGIN / 2 + rect.left(), drawRect.height() / 2 + rect.top(), rect.left() + ROUND_MARGIN / 4 + 1, rect.top());
204 const QColor fillColor = KColorScheme::shade(palette().window().color(), KColorScheme::DarkShade);
207 QRadialGradient bottomGradient(QPointF(rect.width() / 2, drawRect.bottom() + 1), rect.width() / 2);
208 bottomGradient.setColorAt(0, KColorScheme::shade(palette().window().color(), KColorScheme::LightShade));
210 p->fillRect(QRect(rect.left(), drawRect.bottom() + rect.top(), rect.width(), 1), bottomGradient);
220 path.quadTo(drawRect.width() + ROUND_MARGIN / 2, drawRect.height() / 2, drawRect.width() - ROUND_MARGIN / 4, drawRect.height());
225 linearGradient.setColorAt(0.5, KColorScheme::shade(palette().window().color(), KColorScheme::MidShade));
226 linearGradient.setColorAt(1, KColorScheme::shade(palette().window().color(), KColorScheme::LightShade));
236 p->setClipRect(QRect(start, 0, (drawRect.width() + 2) * (d->value / 100.0), drawRect.height()), Qt::IntersectClip);
256 internalBar.quadTo(right + roundMargin / 2, drawRect.height() / 2, right - roundMargin / 4, drawRect.height());
261 fillInternalBar.setColorAt(0, KColorScheme::shade(palette().highlight().color(), KColorScheme::MidShade));
262 fillInternalBar.setColorAt(0.5, KColorScheme::shade(palette().highlight().color(), KColorScheme::LightShade));
263 fillInternalBar.setColorAt(1, KColorScheme::shade(palette().highlight().color(), KColorScheme::MidShade));
271 int numSlots = (drawRect.width() - ROUND_MARGIN - ((slotWidth + spacing) * 2)) / (slotWidth + spacing);
274 int plusOffset = d->fillFullBlocks ? ((drawRect.width() - ROUND_MARGIN - ((slotWidth + spacing) * 2)) - (numSlots * (slotWidth + spacing))) / 2.0
281 firstSlot.lineTo(left + slotWidth + roundMargin / 4 + plusOffset, drawRect.height() - verticalSpacing);
293 p->fillRect(QRect(rect.left() + start, rect.top() + verticalSpacing, slotWidth, drawRect.height() - verticalSpacing * 2), fillInternalBar);
297 if (!d->fillFullBlocks || (!stopped && (stopSlot != (numSlots + 1)) && (stopSlot != numSlots))) {
302 lastSlot.quadTo(start + roundMargin, drawRect.height() / 2, start + slotWidth + plusOffset, verticalSpacing);
318 const QColor fillTopColor = KColorScheme::shade(palette().window().color(), KColorScheme::LightShade);
319 topGradient.setColorAt(0, QColor(fillTopColor.red(), fillTopColor.green(), fillTopColor.blue(), 127));
328 glassGradient.setColorAt(0, QColor(fillGlassColor.red(), fillGlassColor.green(), fillGlassColor.blue(), 255));
338 p->drawText(rect, Qt::AlignCenter, fontMetrics().elidedText(d->text, Qt::ElideRight, drawRect.width() - 2 * ROUND_MARGIN));
340 p->drawText(rect, Qt::AlignBottom | d->horizontalTextAlignment, fontMetrics().elidedText(d->text, Qt::ElideRight, drawRect.width()));
The light color is lighter than dark() or shadow() and contrasts with the base color.
Definition: kcolorscheme.h:280
bool fillFullBlocks() const
int barHeight() const
static ControlElement customControlElement(const QString &element, const QWidget *widget)
Definition: kstyle.cpp:391
bool continuous() const
int value() const
If any text set, draw it into the capacity bar.
Definition: kcapacitybar.h:61
DrawTextMode drawTextMode() const
The way text is drawn, inside the capacity bar or outside of it.
The dark color is in between mid() and shadow().
Definition: kcolorscheme.h:292
If any text set, draw it out of the capacity bar.
Definition: kcapacitybar.h:62
void setFillFullBlocks(bool fillFullBlocks)
When the capacity bar is non-continuous, sets whether the last block shown should be drawn full or ca...
Definition: kcapacitybar.cpp:106
QString text() const
QColor shade(ShadeRole) const
Retrieve the requested shade color, using KColorScheme::background(KColorScheme::NormalBackground) as...
Definition: kcolorscheme.cpp:469
void setDrawTextMode(DrawTextMode mode)
Set the way text is drawn if any is set.
Definition: kcapacitybar.cpp:159
KCapacityBar(DrawTextMode drawTextMode=DrawTextOutline, QWidget *parent=0)
Capacity bar constructor.
Definition: kcapacitybar.cpp:65
void setHorizontalTextAlignment(Qt::Alignment textAlignment)
If the capacity bar is in outline text mode, draw the text with textAlignment alignment.
Definition: kcapacitybar.cpp:141
void setText(const QString &text)
Sets the text for the capacity bar.
Definition: kcapacitybar.cpp:88
Qt::Alignment horizontalTextAlignment() const
void setContinuous(bool continuous)
Sets whether the fill of the capacity bar should be continuous or in block mode.
Definition: kcapacitybar.cpp:117
void setBarHeight(int barHeight)
Sets the height (in pixels) of the bar.
Definition: kcapacitybar.cpp:128
void drawCapacityBar(QPainter *p, const QRect &rect) const
This method allows you to draw the widget, directly, for example on item delegates.
Definition: kcapacitybar.cpp:170
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.