2017-04-27 18:26:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-01-14 17:23:57 +00:00
|
|
|
#ifndef DIVETEXTITEM_H
|
|
|
|
#define DIVETEXTITEM_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-08-11 08:57:42 +00:00
|
|
|
#include <QFont>
|
2014-01-19 18:16:04 +00:00
|
|
|
#include <QGraphicsItemGroup>
|
2015-09-03 17:20:19 +00:00
|
|
|
|
|
|
|
class QBrush;
|
2014-01-14 17:23:57 +00:00
|
|
|
|
|
|
|
/* A Line Item that has animated-properties. */
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveTextItem : public QObject, public QGraphicsItemGroup {
|
2014-01-14 17:23:57 +00:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
|
|
|
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
|
|
|
|
public:
|
2021-08-09 14:48:08 +00:00
|
|
|
DiveTextItem(double dpr, QGraphicsItem *parent = 0);
|
2014-02-28 04:09:57 +00:00
|
|
|
void setText(const QString &text);
|
2014-01-14 17:23:57 +00:00
|
|
|
void setAlignment(int alignFlags);
|
2014-02-15 15:03:41 +00:00
|
|
|
void setScale(double newscale);
|
2014-02-28 04:09:57 +00:00
|
|
|
void setBrush(const QBrush &brush);
|
|
|
|
const QString &text();
|
2015-07-29 17:57:05 +00:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
2021-08-11 08:57:42 +00:00
|
|
|
static QFont getFont(double dpr, double scale);
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2014-01-14 17:23:57 +00:00
|
|
|
private:
|
2014-01-19 18:16:04 +00:00
|
|
|
void updateText();
|
2014-01-14 17:23:57 +00:00
|
|
|
int internalAlignFlags;
|
2014-01-19 18:16:04 +00:00
|
|
|
QGraphicsPathItem *textBackgroundItem;
|
|
|
|
QGraphicsPathItem *textItem;
|
2014-01-21 12:48:26 +00:00
|
|
|
QString internalText;
|
2021-08-09 14:48:08 +00:00
|
|
|
double dpr;
|
2014-02-15 15:03:41 +00:00
|
|
|
double scale;
|
2014-01-14 17:23:57 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVETEXTITEM_H
|