Debian Codegraph @

tests/mocks/QtMir/Application/MirSurfaceItem.h

raw
1 /*
2 * Copyright (C) 2014-2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #ifndef MIRSURFACEITEM_H
18 #define MIRSURFACEITEM_H
19
20 #include "MirSurface.h"
21
22 #include <QQuickItem>
23 #include <QUrl>
24
25 // lomiri-api
26 #include <lomiri/shell/application/MirSurfaceItemInterface.h>
27
28 class MirSurfaceItem : public lomiri::shell::application::MirSurfaceItemInterface
29 {
30 Q_OBJECT
31
32 ////
33 // for use in qml tests
34 Q_PROPERTY(int touchPressCount READ touchPressCount WRITE setTouchPressCount
35 NOTIFY touchPressCountChanged DESIGNABLE false)
36 Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
37 NOTIFY touchReleaseCountChanged DESIGNABLE false)
38
39 Q_PROPERTY(int mousePressCount READ mousePressCount WRITE setMousePressCount
40 NOTIFY mousePressCountChanged)
41 Q_PROPERTY(int mouseReleaseCount READ mouseReleaseCount WRITE setMouseReleaseCount
42 NOTIFY mouseReleaseCountChanged)
43 public:
44 explicit MirSurfaceItem(QQuickItem *parent = 0);
45 ~MirSurfaceItem();
46
47 Mir::Type type() const override;
48 QString name() const override;
49 bool live() const override;
50 Mir::ShellChrome shellChrome() const override;
51
52 Mir::State surfaceState() const override;
53
54 Mir::OrientationAngle orientationAngle() const override;
55 void setOrientationAngle(Mir::OrientationAngle angle) override;
56
57 lomiri::shell::application::MirSurfaceInterface* surface() const override { return m_qmlSurface; }
58 void setSurface(lomiri::shell::application::MirSurfaceInterface*) override;
59
60 bool consumesInput() const override { return m_consumesInput; }
61 void setConsumesInput(bool value) override;
62
63 int surfaceWidth() const override;
64 void setSurfaceWidth(int value) override;
65
66 int surfaceHeight() const override;
67 void setSurfaceHeight(int value) override;
68
69 FillMode fillMode() const override { return m_fillMode; }
70 void setFillMode(FillMode value) override;
71
72 /////
73 // For use in qml tests
74
75 void setLive(bool live);
76
77 int touchPressCount() const { return m_touchPressCount; }
78 void setTouchPressCount(int count) { m_touchPressCount = count; Q_EMIT touchPressCountChanged(count); }
79
80 int touchReleaseCount() const { return m_touchReleaseCount; }
81 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
82
83 int mousePressCount() const { return m_mousePressCount; }
84 void setMousePressCount(int count) { m_mousePressCount = count; Q_EMIT mousePressCountChanged(count); }
85
86 int mouseReleaseCount() const { return m_mouseReleaseCount; }
87 void setMouseReleaseCount(int count) { m_mouseReleaseCount = count; Q_EMIT mouseReleaseCountChanged(count); }
88
89 Q_SIGNALS:
90 void touchPressCountChanged(int count);
91 void touchReleaseCountChanged(int count);
92 void mousePressCountChanged(int count);
93 void mouseReleaseCountChanged(int count);
94
95 protected:
96 void touchEvent(QTouchEvent * event) override;
97 void mousePressEvent(QMouseEvent * event) override;
98 void mouseMoveEvent(QMouseEvent * event) override;
99 void mouseReleaseEvent(QMouseEvent * event) override;
100
101 private Q_SLOTS:
102 void onComponentStatusChanged(QQmlComponent::Status status);
103 void updateScreenshot(QUrl screenshot);
104 void updateMirSurfaceExposure();
105 void updateMirSurfaceActiveFocus(bool focused);
106
107 private:
108 void createQmlContentItem();
109 void printComponentErrors();
110 void updateSurfaceSize();
111
112 MirSurface* m_qmlSurface;
113
114 QQmlComponent *m_qmlContentComponent;
115 QQuickItem *m_qmlItem;
116
117 bool m_consumesInput;
118
119 Mir::OrientationAngle *m_orientationAngle;
120
121 int m_surfaceWidth;
122 int m_surfaceHeight;
123
124 int m_touchPressCount;
125 int m_touchReleaseCount;
126 int m_mousePressCount;
127 int m_mouseReleaseCount;
128 QVariantMap m_touchTrail;
129
130 FillMode m_fillMode{Stretch};
131
132 friend class SurfaceManager;
133 };
134
135 Q_DECLARE_METATYPE(MirSurfaceItem*)
136 Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
137
138 #endif // MIRSURFACEITEM_H