From 64aace63f0a8478be6538e87fecd574f8cc29e86 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 29 Jul 2015 12:21:27 -0700 Subject: Don't connect to the MainWindow 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 --- qt-ui/profile/divetextitem.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qt-ui/profile/divetextitem.h') diff --git a/qt-ui/profile/divetextitem.h b/qt-ui/profile/divetextitem.h index 26e45d746..3991fe7f3 100644 --- a/qt-ui/profile/divetextitem.h +++ b/qt-ui/profile/divetextitem.h @@ -20,13 +20,19 @@ public: 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 -- cgit v1.2.3-70-g09d2