on e2c239f help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
103 lines 3.5 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// A pretty dumb file. Just a container for properties.
26// Implemented in C++ instead of QML just because of the enumerations
27// See QTBUG-14861
28class ApplicationInfo : public QObject {
29 Q_OBJECT
30 Q_ENUMS(Stage)
31 Q_ENUMS(State)
32 Q_PROPERTY(QString desktopFile READ desktopFile WRITE setDesktopFile NOTIFY desktopFileChanged)
33 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
34 Q_PROPERTY(QString comment READ comment WRITE setComment NOTIFY commentChanged)
35 Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
36 Q_PROPERTY(QString exec READ exec WRITE setExec NOTIFY execChanged)
37 Q_PROPERTY(qint64 handle READ handle WRITE setHandle NOTIFY handleChanged)
38 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
39 Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
40 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
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)
50 public:
51 enum Stage { MainStage, SideStage };
52 enum State { Starting, Running };
54 ApplicationInfo(QObject *parent = NULL);
56 #define IMPLEMENT_PROPERTY(name, Name, type) \
57 public: \
58 type name() const { return m_##name; } \
59 void set##Name(const type& value) \
60 { \
61 if (m_##name != value) { \
62 m_##name = value; \
63 Q_EMIT name##Changed(); \
64 } \
65 } \
66 Q_SIGNALS: \
67 void name##Changed(); \
68 private: \
69 type m_##name;
71 IMPLEMENT_PROPERTY(desktopFile, DesktopFile, QString)
72 IMPLEMENT_PROPERTY(name, Name, QString)
73 IMPLEMENT_PROPERTY(comment, Comment, QString)
74 IMPLEMENT_PROPERTY(icon, Icon, QString)
75 IMPLEMENT_PROPERTY(exec, Exec, QString)
76 IMPLEMENT_PROPERTY(handle, Handle, qint64)
77 IMPLEMENT_PROPERTY(stage, Stage, Stage)
78 IMPLEMENT_PROPERTY(state, State, State)
79 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
80 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
81 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
83 #undef IMPLEMENT_PROPERTY
85 public:
86 void showWindow(QQuickItem *parent);
87 void hideWindow();
89 private Q_SLOTS:
90 void onWindowComponentStatusChanged(QQmlComponent::Status status);
92 private:
93 void createWindowItem();
94 void doCreateWindowItem();
95 void createWindowComponent();
96 QQuickItem *m_windowItem;
97 QQmlComponent *m_windowComponent;
98 QQuickItem *m_parentItem;
99};
101Q_DECLARE_METATYPE(ApplicationInfo*)
103#endif // APPLICATION_H