Spectral/src/imageitem.h

51 lines
1.2 KiB
C
Raw Normal View History

2018-09-06 08:22:00 +00:00
#ifndef IMAGEITEM_H
#define IMAGEITEM_H
#include <QImage>
#include <QObject>
#include <QPainter>
#include <QQuickItem>
#include <QQuickPaintedItem>
class ImageItem : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
Q_PROPERTY(QString hint READ hint WRITE setHint NOTIFY hintChanged)
Q_PROPERTY(QString defaultColor READ defaultColor WRITE setDefaultColor NOTIFY
defaultColorChanged)
2018-09-10 01:51:02 +00:00
Q_PROPERTY(bool round READ round WRITE setRound NOTIFY roundChanged)
2018-09-06 08:22:00 +00:00
public:
ImageItem(QQuickItem *parent = nullptr);
void paint(QPainter *painter);
QImage image() const { return m_image; }
void setImage(const QImage &image);
QString hint() { return m_hint; }
void setHint(QString hint);
QString defaultColor() { return m_color; }
void setDefaultColor(QString color);
2018-09-10 01:51:02 +00:00
bool round() { return m_round; }
void setRound(bool value);
2018-09-06 08:22:00 +00:00
signals:
void imageChanged();
void hintChanged();
void defaultColorChanged();
2018-09-10 01:51:02 +00:00
void roundChanged();
2018-09-06 08:22:00 +00:00
private:
QImage m_image;
QString m_hint = "H";
2018-09-16 08:09:36 +00:00
QString m_color;
2018-09-10 01:51:02 +00:00
bool m_round = true;
2018-09-16 08:09:36 +00:00
QString stringtoColor(QString string);
2018-09-06 08:22:00 +00:00
};
#endif // IMAGEITEM_H