matrixion/src/ui/Badge.h

63 lines
1.6 KiB
C
Raw Normal View History

#pragma once
2017-04-06 02:06:42 +03:00
#include <QColor>
#include <QIcon>
#include <QWidget>
#include <QtGlobal>
#include "OverlayWidget.h"
class Badge : public OverlayWidget
{
2017-09-10 12:59:21 +03:00
Q_OBJECT
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
Q_PROPERTY(QPointF relativePosition WRITE setRelativePosition READ relativePosition)
2017-04-06 02:06:42 +03:00
public:
2017-09-10 12:59:21 +03:00
explicit Badge(QWidget *parent = 0);
explicit Badge(const QIcon &icon, QWidget *parent = 0);
explicit Badge(const QString &text, QWidget *parent = 0);
void setBackgroundColor(const QColor &color);
void setTextColor(const QColor &color);
void setIcon(const QIcon &icon);
void setRelativePosition(const QPointF &pos);
void setRelativePosition(qreal x, qreal y);
void setRelativeXPosition(qreal x);
void setRelativeYPosition(qreal y);
void setText(const QString &text);
void setDiameter(int diameter);
QIcon icon() const;
QString text() const;
QColor backgroundColor() const;
QColor textColor() const;
QPointF relativePosition() const;
QSize sizeHint() const override;
qreal relativeXPosition() const;
qreal relativeYPosition() const;
int diameter() const;
2017-04-06 02:06:42 +03:00
protected:
2017-09-10 12:59:21 +03:00
void paintEvent(QPaintEvent *event) override;
2017-04-06 02:06:42 +03:00
private:
2017-09-10 12:59:21 +03:00
void init();
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
QColor background_color_;
QColor text_color_;
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
QIcon icon_;
QSize size_;
QString text_;
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
int padding_;
int diameter_;
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
qreal x_;
qreal y_;
2017-04-06 02:06:42 +03:00
};