KWidgetsAddons
kcapacitybar.cpp
55 d->ce_capacityBar = KStyleExtensions::customControlElement(QStringLiteral("CE_CapacityBar"), this);
191 outline.quadTo(-ROUND_MARGIN / 2 + rect.left(), drawRect.height() / 2 + rect.top(), rect.left() + ROUND_MARGIN / 4 + 1, rect.top());
195 QRadialGradient bottomGradient(QPointF(rect.width() / 2, drawRect.bottom() + 1), rect.width() / 2);
198 p->fillRect(QRect(rect.left(), drawRect.bottom() + rect.top(), rect.width(), 1), bottomGradient);
208 path.quadTo(drawRect.width() + ROUND_MARGIN / 2, drawRect.height() / 2, drawRect.width() - ROUND_MARGIN / 4, drawRect.height());
221 int start = (layoutDirection() == Qt::LeftToRight) ? -1 : (drawRect.width() + 2) - (drawRect.width() + 2) * (d->value / 100.0);
223 p->setClipRect(QRect(start, 0, (drawRect.width() + 2) * (d->value / 100.0), drawRect.height()), Qt::IntersectClip);
240 internalBar.quadTo(right + roundMargin / 2, drawRect.height() / 2, right - roundMargin / 4, drawRect.height());
255 int numSlots = (drawRect.width() - ROUND_MARGIN - ((slotWidth + spacing) * 2)) / (slotWidth + spacing);
258 int plusOffset = d->fillFullBlocks ? ((drawRect.width() - ROUND_MARGIN - ((slotWidth + spacing) * 2)) - (numSlots * (slotWidth + spacing))) / 2.0 : 0;
264 firstSlot.lineTo(left + slotWidth + roundMargin / 4 + plusOffset, drawRect.height() - verticalSpacing);
276 p->fillRect(QRect(rect.left() + start, rect.top() + verticalSpacing, slotWidth, drawRect.height() - verticalSpacing * 2), fillInternalBar);
280 if (!d->fillFullBlocks || (!stopped && (stopSlot != (numSlots + 1)) && (stopSlot != numSlots))) {
285 lastSlot.quadTo(start + roundMargin, drawRect.height() / 2, start + slotWidth + plusOffset, verticalSpacing);
302 topGradient.setColorAt(0, QColor(fillTopColor.red(), fillTopColor.green(), fillTopColor.blue(), 127));
311 glassGradient.setColorAt(0, QColor(fillGlassColor.red(), fillGlassColor.green(), fillGlassColor.blue(), 255));
321 p->drawText(rect, Qt::AlignCenter, fontMetrics().elidedText(d->text, Qt::ElideRight, drawRect.width() - 2 * ROUND_MARGIN));
323 p->drawText(rect, Qt::AlignBottom | d->horizontalTextAlignment, fontMetrics().elidedText(d->text, Qt::ElideRight, drawRect.width()));
329 int width = fontMetrics().boundingRect(d->text).width() + ((d->drawTextMode == KCapacityBar::DrawTextInline) ? ROUND_MARGIN * 2 : 0);
331 int height = (d->drawTextMode == KCapacityBar::DrawTextInline) ? qMax(fontMetrics().height(), d->barHeight)
353 d->ce_capacityBar = KStyleExtensions::customControlElement(QStringLiteral("CE_CapacityBar"), this);
This widget shows a bar which is filled to show the level of usage of a certain device.
Definition kcapacitybar.h:35
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:91
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:155
void setContinuous(bool continuous)
Sets whether the fill of the capacity bar should be continuous or in block mode.
Definition kcapacitybar.cpp:102
void setHorizontalTextAlignment(Qt::Alignment textAlignment)
If the capacity bar is in outline text mode, draw the text with textAlignment alignment.
Definition kcapacitybar.cpp:126
void setBarHeight(int barHeight)
Sets the height (in pixels) of the bar.
Definition kcapacitybar.cpp:113
KCapacityBar(QWidget *parent=nullptr)
Constructs a capacity bar with DrawTextOutline as draw text mode.
Definition kcapacitybar.cpp:46
void setDrawTextMode(DrawTextMode mode)
Set the way text is drawn if any is set.
Definition kcapacitybar.cpp:144
Q_SCRIPTABLE Q_NOREPLY void start()
QStyle::ControlElement customControlElement(const QString &element, const QWidget *widget)
Resolve a dynamic QStyle::ControlElement for eg.
Definition kstyleextensions.cpp:80
int blue() const const
QColor darker(int factor) const const
int green() const const
int red() const const
StyleChange
QRect boundingRect(QChar ch) const const
void setColorAt(qreal position, const QColor &color)
Antialiasing
void drawText(const QPoint &position, const QString &text)
void fillPath(const QPainterPath &path, const QBrush &brush)
void fillRect(const QRect &rectangle, QGradient::Preset preset)
qreal opacity() const const
void restore()
void save()
void setBrush(Qt::BrushStyle style)
void setClipRect(const QRect &rectangle, Qt::ClipOperation operation)
void setClipping(bool enable)
void setOpacity(qreal opacity)
void setPen(Qt::PenStyle style)
void setRenderHints(RenderHints hints, bool on)
void translate(const QPoint &offset)
void lineTo(const QPointF &endPoint)
void moveTo(const QPointF &point)
void quadTo(const QPointF &c, const QPointF &endPoint)
int bottom() const const
int height() const const
void setHeight(int height)
void setWidth(int width)
int top() const const
int width() const const
bool isEmpty() const const
ControlElement
State_Horizontal
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
typedef Alignment
NoBrush
IntersectClip
transparent
LeftToRight
NoPen
ElideRight
void setAccessibleName(const QString &name)
virtual void changeEvent(QEvent *event)
QRect contentsRect() const const
virtual bool event(QEvent *event) override
QFontMetrics fontMetrics() const const
height
layoutDirection
palette
rect
QStyle * style() const const
void update()
void updateGeometry()
width
QWidget * window() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.