Debian Codegraph @

tests/mocks/QtMir/Application/ApplicationInfo.h

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 */
16
17 #ifndef APPLICATION_H
18 #define APPLICATION_H
19
20 #include <QObject>
21
22 class MirSurface;
23
24 // lomiri-api
25 #include <lomiri/shell/application/ApplicationInfoInterface.h>
26 #include <lomiri/shell/application/Mir.h>
27
28 #include "MirSurfaceListModel.h"
29
30 #include <QList>
31 #include <QTimer>
32 #include <QUrl>
33
34 using namespace lomiri::shell::application;
35
36 class ApplicationInfo : public ApplicationInfoInterface {
37 Q_OBJECT
38
39 // whether the test code will explicitly control the creation of the application surface
40 // Only exists in this mock
41 Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
42
43 // Only exists in this mock
44 Q_PROPERTY(QString screenshot READ screenshot CONSTANT)
45
46 public:
47 ApplicationInfo(QObject *parent = nullptr);
48 ApplicationInfo(const QString &appId, QObject *parent = nullptr);
49 ~ApplicationInfo();
50
51 Q_INVOKABLE void createPromptSurface();
52
53 RequestedState requestedState() const override;
54 void setRequestedState(RequestedState) override;
55
56 void setIconId(const QString &iconId);
57 void setScreenshotId(const QString &screenshotId);
58 void setQmlFilename(const QString &);
59
60 void setAppId(const QString &value) { m_appId = value; }
61 QString appId() const override { return m_appId; }
62
63 void setName(const QString &value);
64 QString name() const override { return m_name; }
65
66 QString comment() const override { return QString(); }
67
68 QUrl icon() const override { return m_icon; }
69
70 Q_INVOKABLE void setState(State value);
71 State state() const override { return m_state; }
72
73 bool focused() const override;
74 bool showSplash() const override { return true; }
75 QString splashTitle() const override { return QString(); }
76 QUrl splashImage() const override { return QUrl(); }
77 bool splashShowHeader() const override { return false; }
78 bool serverSideDecoration() const override { return false; }
79 QColor splashColor() const override { return QColor(0,0,0,0); }
80 QColor splashColorHeader() const override { return QColor(0,0,0,0); }
81 QColor splashColorFooter() const override { return QColor(0,0,0,0); }
82
83 QString screenshot() const { return m_screenshotFileName; }
84
85 void setFullscreen(bool value);
86 bool fullscreen() const;
87
88 Qt::ScreenOrientations supportedOrientations() const override;
89 void setSupportedOrientations(Qt::ScreenOrientations orientations);
90
91 bool rotatesWindowContents() const override;
92 void setRotatesWindowContents(bool value);
93
94 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
95 void setManualSurfaceCreation(bool value);
96
97 bool isTouchApp() const override;
98 void setIsTouchApp(bool isTouchApp); // only in mock
99
100 bool exemptFromLifecycle() const override;
101 void setExemptFromLifecycle(bool) override;
102
103 QSize initialSurfaceSize() const override;
104 void setInitialSurfaceSize(const QSize &size) override;
105
106 Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
107
108 MirSurfaceListInterface* surfaceList() const override { return m_surfaceList; }
109 MirSurfaceListInterface* promptSurfaceList() const override { return m_promptSurfaceList; }
110 int surfaceCount() const override { return m_surfaceList->count(); }
111
112 //////
113 // internal mock stuff
114 void close() override;
115 void requestFocus();
116
117 Q_SIGNALS:
118 void fullscreenChanged(bool value);
119 void manualSurfaceCreationChanged(bool value);
120 void closed();
121
122 public Q_SLOTS:
123 Q_INVOKABLE void createSurface();
124
125 private Q_SLOTS:
126 void onSurfaceCountChanged();
127
128 private:
129 void setIcon(const QUrl &value);
130
131 QString m_screenshotFileName;
132
133 QString m_appId;
134 QString m_name;
135 QUrl m_icon;
136 State m_state{Stopped};
137 bool m_fullscreen{false};
138 Qt::ScreenOrientations m_supportedOrientations{Qt::PortraitOrientation |
139 Qt::LandscapeOrientation |
140 Qt::InvertedPortraitOrientation |
141 Qt::InvertedLandscapeOrientation};
142 bool m_rotatesWindowContents{false};
143 RequestedState m_requestedState{RequestedRunning};
144 bool m_isTouchApp{true};
145 bool m_exemptFromLifecycle{false};
146 QSize m_initialSurfaceSize;
147 MirSurfaceListModel *m_surfaceList;
148 MirSurfaceListModel *m_promptSurfaceList;
149 int m_liveSurfaceCount{0};
150 QTimer m_surfaceCreationTimer;
151 QList<MirSurface*> m_closingSurfaces;
152 bool m_manualSurfaceCreation{false};
153 Mir::ShellChrome m_shellChrome{Mir::NormalChrome};
154 QUrl m_qmlFilePath;
155 };
156
157 Q_DECLARE_METATYPE(ApplicationInfo*)
158
159 #endif // APPLICATION_H