on 01c8faa help sign in
unity8/tests/mocks/Unity/Application/ApplicationInfo.h
163 lines 5.3 kB history raw
1/*
2 * Copyright (C) 2013-2016 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>
22class MirSurface;
24// unity-api
25#include <unity/shell/application/ApplicationInfoInterface.h>
26#include <unity/shell/application/Mir.h>
28#include "MirSurfaceListModel.h"
30#include <QList>
31#include <QTimer>
33using namespace unity::shell::application;
35class ApplicationInfo : public ApplicationInfoInterface {
36 Q_OBJECT
38 ////
39 // FIXME: Remove those
40 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
42 // Only exists in this fake implementation
44 // whether the test code will explicitly control the creation of the application surface
45 Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
47 Q_PROPERTY(QString screenshot READ screenshot CONSTANT)
49public:
50 ApplicationInfo(QObject *parent = nullptr);
51 ApplicationInfo(const QString &appId, QObject *parent = nullptr);
52 ~ApplicationInfo();
54 RequestedState requestedState() const override;
55 void setRequestedState(RequestedState) override;
57 void setIconId(const QString &iconId);
58 void setScreenshotId(const QString &screenshotId);
60 void setAppId(const QString &value) { m_appId = value; }
61 QString appId() const override { return m_appId; }
63 void setName(const QString &value);
64 QString name() const override { return m_name; }
66 QString comment() const override { return QString(); }
68 QUrl icon() const override { return m_icon; }
70 Q_INVOKABLE void setStage(Stage value) override; // invokable only for mock
71 Stage stage() const override { return m_stage; }
73 Q_INVOKABLE void setState(State value);
74 State state() const override { return m_state; }
76 bool focused() const override;
78 QString splashTitle() const override { return QString(); }
79 QUrl splashImage() const override { return QUrl(); }
80 bool splashShowHeader() const override { return false; }
81 QColor splashColor() const override { return QColor(0,0,0,0); }
82 QColor splashColorHeader() const override { return QColor(0,0,0,0); }
83 QColor splashColorFooter() const override { return QColor(0,0,0,0); }
85 QString screenshot() const { return m_screenshotFileName; }
87 void setFullscreen(bool value);
88 bool fullscreen() const;
90 Qt::ScreenOrientations supportedOrientations() const override;
91 void setSupportedOrientations(Qt::ScreenOrientations orientations);
93 bool rotatesWindowContents() const override;
94 void setRotatesWindowContents(bool value);
96 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
97 void setManualSurfaceCreation(bool value);
99 bool isTouchApp() const override;
100 void setIsTouchApp(bool isTouchApp); // only in mock
102 bool exemptFromLifecycle() const override;
103 void setExemptFromLifecycle(bool) override;
105 QSize initialSurfaceSize() const override;
106 void setInitialSurfaceSize(const QSize &size) override;
108 Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
110 MirSurfaceListInterface* surfaceList() const override { return m_surfaceList; }
111 MirSurfaceListInterface* promptSurfaceList() const override { return m_promptSurfaceList; }
112 int surfaceCount() const override { return m_surfaceList->count(); }
114 void setFocused(bool value);
116 //////
117 // internal mock stuff
118 void close();
119 void requestFocus();
121Q_SIGNALS:
122 void fullscreenChanged(bool value);
123 void manualSurfaceCreationChanged(bool value);
124 void closed();
126public Q_SLOTS:
127 Q_INVOKABLE void createSurface();
129private Q_SLOTS:
130 void onSurfaceCountChanged();
132private:
133 void setIcon(const QUrl &value);
135 QString m_screenshotFileName;
137 QString m_appId;
138 QString m_name;
139 QUrl m_icon;
140 Stage m_stage{MainStage};
141 State m_state{Stopped};
142 bool m_fullscreen{false};
143 Qt::ScreenOrientations m_supportedOrientations{Qt::PortraitOrientation |
144 Qt::LandscapeOrientation |
145 Qt::InvertedPortraitOrientation |
146 Qt::InvertedLandscapeOrientation};
147 bool m_rotatesWindowContents{false};
148 RequestedState m_requestedState{RequestedRunning};
149 bool m_isTouchApp{true};
150 bool m_exemptFromLifecycle{false};
151 QSize m_initialSurfaceSize;
152 MirSurfaceListModel *m_surfaceList;
153 MirSurfaceListModel *m_promptSurfaceList;
154 int m_liveSurfaceCount{0};
155 QTimer m_surfaceCreationTimer;
156 QList<MirSurface*> m_closingSurfaces;
157 bool m_manualSurfaceCreation{false};
158 Mir::ShellChrome m_shellChrome{Mir::NormalChrome};
159};
161Q_DECLARE_METATYPE(ApplicationInfo*)
163#endif // APPLICATION_H