on bbbdccd help sign in
unity8/tests/mocks/Unity/Application/MirSurfaceItem.h
135 lines 4.6 kB history 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 */
17#ifndef MIRSURFACEITEM_H
18#define MIRSURFACEITEM_H
20#include "MirSurface.h"
22#include <QQuickItem>
23#include <QUrl>
25// unity-api
26#include <unity/shell/application/MirSurfaceItemInterface.h>
28class MirSurfaceItem : public unity::shell::application::MirSurfaceItemInterface
30 Q_OBJECT
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)
39 Q_PROPERTY(int mousePressCount READ mousePressCount WRITE setMousePressCount
40 NOTIFY mousePressCountChanged)
41 Q_PROPERTY(int mouseReleaseCount READ mouseReleaseCount WRITE setMouseReleaseCount
42 NOTIFY mouseReleaseCountChanged)
43public:
44 explicit MirSurfaceItem(QQuickItem *parent = 0);
45 ~MirSurfaceItem();
47 Mir::Type type() const override;
48 QString name() const override;
49 bool live() const override;
51 Mir::State surfaceState() const override;
52 void setSurfaceState(Mir::State) override {}
54 Mir::OrientationAngle orientationAngle() const override;
55 void setOrientationAngle(Mir::OrientationAngle angle) override;
57 unity::shell::application::MirSurfaceInterface* surface() const override { return m_qmlSurface; }
58 void setSurface(unity::shell::application::MirSurfaceInterface*) override;
60 bool consumesInput() const override { return m_consumesInput; }
61 void setConsumesInput(bool value) override;
63 int surfaceWidth() const override;
64 void setSurfaceWidth(int value) override;
66 int surfaceHeight() const override;
67 void setSurfaceHeight(int value) override;
69 FillMode fillMode() const override { return m_fillMode; }
70 void setFillMode(FillMode value) override;
72 /////
73 // For use in qml tests
75 void setLive(bool live);
77 int touchPressCount() const { return m_touchPressCount; }
78 void setTouchPressCount(int count) { m_touchPressCount = count; Q_EMIT touchPressCountChanged(count); }
80 int touchReleaseCount() const { return m_touchReleaseCount; }
81 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
83 int mousePressCount() const { return m_mousePressCount; }
84 void setMousePressCount(int count) { m_mousePressCount = count; Q_EMIT mousePressCountChanged(count); }
86 int mouseReleaseCount() const { return m_mouseReleaseCount; }
87 void setMouseReleaseCount(int count) { m_mouseReleaseCount = count; Q_EMIT mouseReleaseCountChanged(count); }
89Q_SIGNALS:
90 void touchPressCountChanged(int count);
91 void touchReleaseCountChanged(int count);
92 void mousePressCountChanged(int count);
93 void mouseReleaseCountChanged(int count);
95protected:
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 void itemChange(ItemChange change, const ItemChangeData & value) override;
102private Q_SLOTS:
103 void onComponentStatusChanged(QQmlComponent::Status status);
104 void updateScreenshot(QUrl screenshot);
105 void updateMirSurfaceVisibility();
107private:
108 void createQmlContentItem();
109 void printComponentErrors();
110 void updateSurfaceSize();
112 MirSurface* m_qmlSurface;
114 QQmlComponent *m_qmlContentComponent;
115 QQuickItem *m_qmlItem;
117 bool m_consumesInput;
119 int m_surfaceWidth;
120 int m_surfaceHeight;
122 int m_touchPressCount;
123 int m_touchReleaseCount;
124 int m_mousePressCount;
125 int m_mouseReleaseCount;
127 FillMode m_fillMode{Stretch};
129 friend class SurfaceManager;
130};
132Q_DECLARE_METATYPE(MirSurfaceItem*)
133Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
135#endif // MIRSURFACEITEM_H