on 6ca9421 help sign in
unity8/tests/mocks/Unity/Application/MirSurfaceItem.h
115 lines 3.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)
39public:
40 explicit MirSurfaceItem(QQuickItem *parent = 0);
41 ~MirSurfaceItem();
43 Mir::Type type() const override;
44 QString name() const override;
45 bool live() const override;
47 Mir::State surfaceState() const override;
48 void setSurfaceState(Mir::State) override {}
50 Mir::OrientationAngle orientationAngle() const override;
51 void setOrientationAngle(Mir::OrientationAngle angle) override;
53 unity::shell::application::MirSurfaceInterface* surface() const override { return m_qmlSurface; }
54 void setSurface(unity::shell::application::MirSurfaceInterface*) override;
56 bool consumesInput() const override { return m_consumesInput; }
57 void setConsumesInput(bool value) override;
59 int surfaceWidth() const override;
60 void setSurfaceWidth(int value) override;
62 int surfaceHeight() const override;
63 void setSurfaceHeight(int value) override;
65 /////
66 // For use in qml tests
68 void setLive(bool live);
70 int touchPressCount() const { return m_touchPressCount; }
71 void setTouchPressCount(int count) { m_touchPressCount = count; Q_EMIT touchPressCountChanged(count); }
73 int touchReleaseCount() const { return m_touchReleaseCount; }
74 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
76Q_SIGNALS:
77 void touchPressCountChanged(int count);
78 void touchReleaseCountChanged(int count);
80protected:
81 void touchEvent(QTouchEvent * event) override;
82 void mousePressEvent(QMouseEvent * event) override;
83 void mouseMoveEvent(QMouseEvent * event) override;
84 void mouseReleaseEvent(QMouseEvent * event) override;
85 void itemChange(ItemChange change, const ItemChangeData & value) override;
87private Q_SLOTS:
88 void onComponentStatusChanged(QQmlComponent::Status status);
89 void updateScreenshot(QUrl screenshot);
91private:
92 void createQmlContentItem();
93 void printComponentErrors();
94 void updateSurfaceSize();
96 MirSurface* m_qmlSurface;
98 QQmlComponent *m_qmlContentComponent;
99 QQuickItem *m_qmlItem;
101 bool m_consumesInput;
103 int m_surfaceWidth;
104 int m_surfaceHeight;
106 int m_touchPressCount;
107 int m_touchReleaseCount;
109 friend class SurfaceManager;
110};
112Q_DECLARE_METATYPE(MirSurfaceItem*)
113Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
115#endif // MIRSURFACEITEM_H