Badge
Qualified name: mv::util::Badge
-
class Badge : public QObject
Badge class.
Draws a circle with a number with any Qt::Alignment flag and foreground (text) and background color. Currently used by the collapsed widget only.
Note: By default the badge is disabled, use Badge::setEnabled(…) to enable it
- Author
Thomas Kroes
Public Functions
-
Badge(QObject *parent = nullptr, std::uint32_t number = 0, const QColor &backgroundColor = Qt::red, const QColor &foregroundColor = Qt::white, Qt::Alignment alignment = Qt::AlignTop | Qt::AlignRight, float scale = 0.5f)
Construct with pointer to
parentobject, badgenumber,backgroundColor,foregroundColor,alignmentandbadgescale.- Parameters:
parent – Pointer to parent object
number – Number displayed in the badge
backgroundColor – Background color the badge
foregroundColor – Foreground color the badge
alignment – Alignment of the badge
scale – Scale of the badge w.r.t. of its container
-
QPixmap getPixmap() const
Get pixmap.
- Returns:
Pixmap representation of the badge (100 x 100)
-
Parameters getParameters() const
Get parameters.
- Returns:
Badge parameters
-
bool getEnabled() const
Get badge enabled.
- Returns:
Badge enabled
-
void setEnabled(bool enabled)
Set badge enabled to
enabled.- Parameters:
enabled – Badge enabled
-
std::uint32_t getNumber() const
Get badge number.
- Returns:
Badge number
-
void setNumber(std::uint32_t number)
Set badge number to
number.- Parameters:
number – Badge number
-
QColor getBackgroundColor() const
Get background color.
- Returns:
Background color
-
void setBackgroundColor(const QColor &backgroundColor)
Set background color to
backgroundColor.- Parameters:
backgroundColor – Background color
-
QColor getForegroundColor() const
Get foreground color.
- Returns:
Foreground color
-
void setForegroundColor(const QColor &foregroundColor)
Set foreground color to
foregroundColor.- Parameters:
foregroundColor – Foreground color
-
Qt::Alignment getAlignment() const
Get badge alignment.
- Returns:
Badge alignment
-
void setAlignment(Qt::Alignment alignment)
Set badge alignment to
alignment.- Parameters:
alignment – Badge alignment
-
float getScale() const
Get badge scale.
- Returns:
Badge scale
-
void setScale(float scale)
Set badge scale to
scale.- Parameters:
scale – Badge scale
-
QPixmap getCustomPixmap() const
Get custom pixmap.
- Returns:
Custom pixmap
-
void setCustomPixmap(const QPixmap &customPixmap)
Set custom pixmap to
customPixmap.- Parameters:
customPixmap – Custom pixmap
-
void enabledChanged(bool enabled)
Signals that enabled changed to
enabled.- Parameters:
enabled – Enabled
-
void numberChanged(std::uint32_t number)
Signals that the badge number changed to
number.- Parameters:
number – Badge number
-
void backgroundColorChanged(const QColor &backgroundColor)
Signals that the background color changed to
backgroundColor.- Parameters:
backgroundColor – Background color
-
void foregroundColorChanged(const QColor &foregroundColor)
Signals that the foreground color changed to
foregroundColor.- Parameters:
foregroundColor – Foreground color
-
void alignmentChanged(Qt::Alignment alignmen)
Signals that the badge alignment changed to
alignment.- Parameters:
alignment – Badge alignment
-
void scaleChanged(float scale)
Signals that the badge scale changed to
scale.- Parameters:
scale – Badge scale
-
void customPixmapChanged(const QPixmap &customPixmap)
Signals that the custom pixmap changed to
customPixmap.- Parameters:
customPixmap – Custom pixmap
-
void changed()
Signals that the badge configuration changed.
-
struct Parameters
Badge parameters container struct.
Public Functions
-
inline Parameters(std::uint32_t number = 0, const QColor &backgroundColor = Qt::red, const QColor &foregroundColor = Qt::white, Qt::Alignment alignment = Qt::AlignTop | Qt::AlignRight, float scale = 0.5f)
Construct with
number,backgroundColor,foregroundColor,alignmentandscale.- Parameters:
number – Number displayed in the badge
backgroundColor – Background color the badge
foregroundColor – Foreground color the badge
alignment – Alignment of the badge
scale – Scale of the badge w.r.t. of its container
-
inline Parameters(std::uint32_t number = 0, const QColor &backgroundColor = Qt::red, const QColor &foregroundColor = Qt::white, Qt::Alignment alignment = Qt::AlignTop | Qt::AlignRight, float scale = 0.5f)