on e246ecd help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
122 lines 3.9 kB history raw
1/*
2 * Copyright (C) 2013-2014 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 APPLICATION_H
18#define APPLICATION_H
20#include <QObject>
21#include <QQmlComponent>
23class QQuickItem;
24class MirSurfaceItem;
26// unity-api
27#include <unity/shell/application/ApplicationInfoInterface.h>
29using namespace unity::shell::application;
31class ApplicationInfo : public ApplicationInfoInterface {
32 Q_OBJECT
34 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
35 Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
36 Q_PROPERTY(QQmlListProperty<MirSurfaceItem> promptSurfaces READ promptSurfaces NOTIFY promptSurfacesChanged DESIGNABLE false)
38 // Only exists in this fake implementation
40 // whether the test code will explicitly control the creation of the application surface
41 Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
43public:
44 ApplicationInfo(QObject *parent = NULL);
45 ApplicationInfo(const QString &appId, QObject *parent = NULL);
46 ~ApplicationInfo();
48 void setIconId(const QString &iconId);
49 void setScreenshotId(const QString &screenshotId);
51 void setAppId(const QString &value) { m_appId = value; }
52 QString appId() const override { return m_appId; }
54 void setName(const QString &value);
55 QString name() const override { return m_name; }
57 QString comment() const override { return QString(); }
59 QUrl icon() const override { return m_icon; }
61 void setStage(Stage value);
62 Stage stage() const override { return m_stage; }
64 Q_INVOKABLE void setState(State value);
65 State state() const override { return m_state; }
67 void setFocused(bool value);
68 bool focused() const override { return m_focused; }
70 QString screenshot() const { return m_screenshotFileName; }
72 void setFullscreen(bool value);
73 bool fullscreen() const { return m_fullscreen; }
75 void setSurface(MirSurfaceItem* surface);
76 MirSurfaceItem* surface() const { return m_surface; }
78 void removeSurface(MirSurfaceItem* surface);
80 void addPromptSurface(MirSurfaceItem* surface);
81 QList<MirSurfaceItem*> promptSurfaceList() const;
82 QQmlListProperty<MirSurfaceItem> promptSurfaces();
84 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
85 void setManualSurfaceCreation(bool value);
87Q_SIGNALS:
88 void surfaceChanged(MirSurfaceItem*);
89 void promptSurfacesChanged();
90 void fullscreenChanged(bool value);
91 void manualSurfaceCreationChanged(bool value);
93public Q_SLOTS:
94 Q_INVOKABLE void createSurface();
96private:
97 static int promptSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop);
98 static MirSurfaceItem* promptSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index);
99 void setIcon(const QUrl &value);
100 void setScreenshot(const QUrl &value);
102 QString m_screenshotFileName;
104 QString m_appId;
105 QString m_name;
106 QUrl m_icon;
107 Stage m_stage;
108 State m_state;
109 bool m_focused;
110 bool m_fullscreen;
111 MirSurfaceItem* m_surface;
113 bool m_manualSurfaceCreation;
115 QQuickItem *m_parentItem;
116 QList<MirSurfaceItem*> m_promptSurfaces;
117};
119Q_DECLARE_METATYPE(ApplicationInfo*)
120Q_DECLARE_METATYPE(QQmlListProperty<MirSurfaceItem>)
122#endif // APPLICATION_H