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()));
void setOpacity(qreal opacity)
Type type() const
const QPalette & palette() const
The light color is lighter than dark() or shadow() and contrasts with the base color.
Definition: kcolorscheme.h:280
bool end()
void fillRect(const QRectF &rectangle, const QBrush &brush)
void updateGeometry()
QWidget * window() const
QRect contentsRect() const
void setColorAt(qreal position, const QColor &color)
QStyle * style() const
void setClipping(bool enable)
bool fillFullBlocks() const
int barHeight() const
static ControlElement customControlElement(const QString &element, const QWidget *widget)
Definition: kstyle.cpp:391
void save()
bool continuous() const
void moveTo(const QPointF &point)
int height() const
int value() const
typedef Alignment
If any text set, draw it into the capacity bar.
Definition: kcapacitybar.h:61
void update()
DrawTextMode drawTextMode() const
The way text is drawn, inside the capacity bar or outside of it.
void setAccessibleName(const QString &name)
void initFrom(const QWidget *widget)
int width() const
const QColor & color() const
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
const QRect & rect() const
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
Qt::LayoutDirection layoutDirection() const
int top() const
void fillPath(const QPainterPath &path, const QBrush &brush)
int red() const
void setPen(const QColor &color)
void lineTo(const QPointF &endPoint)
int left() const
void setWidth(int width)
bool isEmpty() const
QColor shade(ShadeRole) const
Retrieve the requested shade color, using KColorScheme::background(KColorScheme::NormalBackground) as...
Definition: kcolorscheme.cpp:469
void setBrush(const QBrush &brush)
void drawText(const QPointF &position, const QString &text)
void setDrawTextMode(DrawTextMode mode)
Set the way text is drawn if any is set.
Definition: kcapacitybar.cpp:159
virtual void changeEvent(QEvent *event)
QRect rect() const
int green() const
int width(const QString &text, int len) const
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
KCapacityBar(DrawTextMode drawTextMode=DrawTextOutline, QWidget *parent=0)
Capacity bar constructor.
Definition: kcapacitybar.cpp:65
void restore()
int blue() const
void setHorizontalTextAlignment(Qt::Alignment textAlignment)
If the capacity bar is in outline text mode, draw the text with textAlignment alignment.
Definition: kcapacitybar.cpp:141
const QBrush & base() const
int width() const
void setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)
QFontMetrics fontMetrics() const
void setText(const QString &text)
Sets the text for the capacity bar.
Definition: kcapacitybar.cpp:88
void setHeight(int height)
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const =0
int height() const
int bottom() const
void translate(const QPointF &offset)
Qt::Alignment horizontalTextAlignment() const
void quadTo(const QPointF &c, const QPointF &endPoint)
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
int height() const
qreal opacity() const
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-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.