on 44c8a85 help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
113 lines 3.5 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>
29// A pretty dumb file. Just a container for properties.
30// Implemented in C++ instead of QML just because of the enumerations
31// See QTBUG-14861
33using namespace unity::shell::application;
35class ApplicationInfo : public ApplicationInfoInterface {
36 Q_OBJECT
38 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
39 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
40 Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
42 // Only exists in this fake implementation
44 // QML component used to represent its image/screenhot
45 Q_PROPERTY(QString imageQml READ imageQml WRITE setImageQml NOTIFY imageQmlChanged)
47 // QML component used to represent the application window
48 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)
50public:
51 ApplicationInfo(QObject *parent = NULL);
52 ApplicationInfo(const QString &appId, QObject *parent = NULL);
53 ~ApplicationInfo();
55 #define IMPLEMENT_PROPERTY(name, Name, type) \
56 public: \
57 type name() const { return m_##name; } \
58 void set##Name(const type& value) \
59 { \
60 if (m_##name != value) { \
61 m_##name = value; \
62 Q_EMIT name##Changed(value); \
63 } \
64 } \
65 Q_SIGNALS: \
66 void name##Changed(const type&); \
67 private: \
68 type m_##name;
70 IMPLEMENT_PROPERTY(appId, AppId, QString)
71 IMPLEMENT_PROPERTY(name, Name, QString)
72 IMPLEMENT_PROPERTY(comment, Comment, QString)
73 IMPLEMENT_PROPERTY(icon, Icon, QUrl)
74 IMPLEMENT_PROPERTY(stage, Stage, Stage)
75 IMPLEMENT_PROPERTY(state, State, State)
76 IMPLEMENT_PROPERTY(focused, Focused, bool)
77 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
78 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
79 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
80 IMPLEMENT_PROPERTY(screenshot, Screenshot, QUrl)
82 #undef IMPLEMENT_PROPERTY
84public:
85 MirSurfaceItem* surface() const { return m_surface; }
87Q_SIGNALS:
88 void surfaceChanged(MirSurfaceItem*);
90public:
91 void showWindow(QQuickItem *parent);
92 void hideWindow();
94private Q_SLOTS:
95 void onWindowComponentStatusChanged(QQmlComponent::Status status);
96 void onStateChanged(State state);
98 void createSurface();
99 void destroySurface();
101private:
102 void createWindowItem();
103 void doCreateWindowItem();
104 void createWindowComponent();
105 QQuickItem *m_windowItem;
106 QQmlComponent *m_windowComponent;
107 QQuickItem *m_parentItem;
108 MirSurfaceItem* m_surface;
109};
111Q_DECLARE_METATYPE(ApplicationInfo*)
113#endif // APPLICATION_H