mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
64aace63f0
We really shouldn't need to connect to the MainWindow in order to get the right scale for the fonts when printing. While printing likely will remain a desktop only function, this is just bad design. And making calls like this from the paint() function is a bad plan, anyway. So instead we make sure that every DiveTextItem knows what the printScale was when it was created (or actually, when the text was first set as they frequently get created before we have a scene which we use to get to the profile), and gets updated whenever that scale changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
38 lines
967 B
C++
38 lines
967 B
C++
#ifndef DIVETEXTITEM_H
|
|
#define DIVETEXTITEM_H
|
|
|
|
#include <QObject>
|
|
#include <QGraphicsItemGroup>
|
|
#include "graphicsview-common.h"
|
|
#include <QBrush>
|
|
|
|
/* A Line Item that has animated-properties. */
|
|
class DiveTextItem : public QObject, public QGraphicsItemGroup {
|
|
Q_OBJECT
|
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
|
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
|
|
public:
|
|
DiveTextItem(QGraphicsItem *parent = 0);
|
|
void setText(const QString &text);
|
|
void setAlignment(int alignFlags);
|
|
void setScale(double newscale);
|
|
void setBrush(const QBrush &brush);
|
|
const QString &text();
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
|
|
private
|
|
slots:
|
|
void fontPrintScaleUpdate(double scale);
|
|
|
|
private:
|
|
void updateText();
|
|
int internalAlignFlags;
|
|
QGraphicsPathItem *textBackgroundItem;
|
|
QGraphicsPathItem *textItem;
|
|
QString internalText;
|
|
double printScale;
|
|
double scale;
|
|
bool connected;
|
|
};
|
|
|
|
#endif // DIVETEXTITEM_H
|