Debian Codegraph @

utils/fgqcanvas/canvaspainteddisplay.h

raw symbols SCIP
1 //
2 // Copyright (C) 2018 James Turner <[email protected]>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 #ifndef CANVAS_PAINTED_DISPLAY_H
19 #define CANVAS_PAINTED_DISPLAY_H
20
21 #include <memory>
22
23 #include <QQuickPaintedItem>
24 #include <QPointer>
25
26 class CanvasConnection;
27 class FGCanvasGroup;
28 class QQuickItem;
29
30 class CanvasPaintedDisplay : public QQuickPaintedItem
31 {
32 Q_OBJECT
33
34 Q_PROPERTY(CanvasConnection* canvas READ canvas WRITE setCanvas NOTIFY canvasChanged)
35
36 public:
37 CanvasPaintedDisplay(QQuickItem* parent = nullptr);
38 ~CanvasPaintedDisplay();
39
40 CanvasConnection* canvas() const
41 {
42 return m_connection;
43 }
44
45 void paint(QPainter *painter) override;
46 signals:
47
48 void canvasChanged(CanvasConnection* canvas);
49
50 public slots:
51
52 void setCanvas(CanvasConnection* canvas);
53
54 protected:
55
56 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
57
58 private slots:
59 void onConnectionStatusChanged();
60
61 void onConnectionUpdated();
62
63 void onCanvasSizeChanged();
64 void onConnectionDestroyed();
65
66 private:
67 void recomputeScaling();
68 void buildElements();
69
70 CanvasConnection* m_connection = nullptr;
71 QPointer<FGCanvasGroup> m_rootElement;
72 // QQuickItem* m_rootItem = nullptr;
73 QSizeF m_sourceSize;
74 };
75
76 #endif // CANVAS_PAINTED_DISPLAY_H