on 4551efc help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
101 lines 3.2 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>
22#include <QDebug>
24class QQuickItem;
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)
41 // Only exists in this fake implementation
43 // QML component used to represent its image/screenhot
44 Q_PROPERTY(QString imageQml READ imageQml WRITE setImageQml NOTIFY imageQmlChanged)
46 // QML component used to represent the application window
47 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)
49 public:
50 ApplicationInfo(QObject *parent = NULL);
51 ApplicationInfo(const QString &appId, QObject *parent = NULL);
53 #define IMPLEMENT_PROPERTY(name, Name, type) \
54 public: \
55 type name() const { return m_##name; } \
56 void set##Name(const type& value) \
57 { \
58 if (m_##name != value) { \
59 m_##name = value; \
60 qDebug() << "emitting changed" << this << Q_FUNC_INFO; \
61 Q_EMIT name##Changed(); \
62 } \
63 } \
64 Q_SIGNALS: \
65 void name##Changed(); \
66 private: \
67 type m_##name;
69 IMPLEMENT_PROPERTY(appId, AppId, QString)
70 IMPLEMENT_PROPERTY(name, Name, QString)
71 IMPLEMENT_PROPERTY(comment, Comment, QString)
72 IMPLEMENT_PROPERTY(icon, Icon, QUrl)
73 IMPLEMENT_PROPERTY(stage, Stage, Stage)
74 IMPLEMENT_PROPERTY(state, State, State)
75 IMPLEMENT_PROPERTY(focused, Focused, bool)
76 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
77 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
78 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
79 IMPLEMENT_PROPERTY(screenshot, Screenshot, QUrl)
81 #undef IMPLEMENT_PROPERTY
83 public:
84 void showWindow(QQuickItem *parent);
85 void hideWindow();
87 private Q_SLOTS:
88 void onWindowComponentStatusChanged(QQmlComponent::Status status);
90 private:
91 void createWindowItem();
92 void doCreateWindowItem();
93 void createWindowComponent();
94 QQuickItem *m_windowItem;
95 QQmlComponent *m_windowComponent;
96 QQuickItem *m_parentItem;
97};
99Q_DECLARE_METATYPE(ApplicationInfo*)
101#endif // APPLICATION_H