on 551c708 help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
98 lines 3.0 kB history raw
1/*
2 * Copyright (C) 2013 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;
25// unity-api
26#include <unity/shell/application/ApplicationInfoInterface.h>
28// A pretty dumb file. Just a container for properties.
29// Implemented in C++ instead of QML just because of the enumerations
30// See QTBUG-14861
32using namespace unity::shell::application;
34class ApplicationInfo : public ApplicationInfoInterface {
35 Q_OBJECT
37 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
38 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
40 // Only exists in this fake implementation
42 // QML component used to represent its image/screenhot
43 Q_PROPERTY(QString imageQml READ imageQml WRITE setImageQml NOTIFY imageQmlChanged)
45 // QML component used to represent the application window
46 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)
48 public:
49 ApplicationInfo(QObject *parent = NULL);
50 ApplicationInfo(const QString &appId, QObject *parent = NULL);
52 #define IMPLEMENT_PROPERTY(name, Name, type) \
53 public: \
54 type name() const { return m_##name; } \
55 void set##Name(const type& value) \
56 { \
57 if (m_##name != value) { \
58 m_##name = value; \
59 Q_EMIT name##Changed(); \
60 } \
61 } \
62 Q_SIGNALS: \
63 void name##Changed(); \
64 private: \
65 type m_##name;
67 IMPLEMENT_PROPERTY(appId, AppId, QString)
68 IMPLEMENT_PROPERTY(name, Name, QString)
69 IMPLEMENT_PROPERTY(comment, Comment, QString)
70 IMPLEMENT_PROPERTY(icon, Icon, QUrl)
71 IMPLEMENT_PROPERTY(stage, Stage, Stage)
72 IMPLEMENT_PROPERTY(state, State, State)
73 IMPLEMENT_PROPERTY(focused, Focused, bool)
74 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
75 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
76 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
78 #undef IMPLEMENT_PROPERTY
80 public:
81 void showWindow(QQuickItem *parent);
82 void hideWindow();
84 private Q_SLOTS:
85 void onWindowComponentStatusChanged(QQmlComponent::Status status);
87 private:
88 void createWindowItem();
89 void doCreateWindowItem();
90 void createWindowComponent();
91 QQuickItem *m_windowItem;
92 QQmlComponent *m_windowComponent;
93 QQuickItem *m_parentItem;
94};
96Q_DECLARE_METATYPE(ApplicationInfo*)
98#endif // APPLICATION_H