File: ApplicationInfoInterface.h

package info (click to toggle)
lomiri-api 0.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,248 kB
  • sloc: cpp: 6,415; python: 264; ansic: 96; makefile: 29; sh: 17
file content (362 lines) | stat: -rw-r--r-- 12,241 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
 * Copyright 2013,2015,2016 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LOMIRI_SHELL_APPLICATION_APPLICATIONINFOINTERFACE_H
#define LOMIRI_SHELL_APPLICATION_APPLICATIONINFOINTERFACE_H

#include <lomiri/SymbolExport.h>

#include <QtCore/QObject>
#include <QtCore/QUrl>
#include <QColor>
#include <QSize>

namespace lomiri
{
namespace shell
{
namespace application
{

class MirSurfaceListInterface;

/**
 * @brief A class that holds information about applications
 *
 * The items hold all the information required for the visual representation
 * in the launcher.
 */

class LOMIRI_API ApplicationInfoInterface: public QObject
{
    Q_OBJECT

    /**
     * @brief The appId of the application.
     *
     * Holds the appId for the application. For example (com.ubuntu.camera-app).
     * The appId is derived from the filename of the .desktop file.
     */
    Q_PROPERTY(QString appId READ appId CONSTANT)

    /**
     * @brief The name of the application.
     *
     * Holds the name of the application. Localized to current language.
     */
    Q_PROPERTY(QString name READ name NOTIFY nameChanged)

    /**
     * @brief The comment for the application.
     *
     * Holds the comment of the application as obtained from the .desktop file. Localized
     * to current language.
     */
    Q_PROPERTY(QString comment READ comment NOTIFY commentChanged)

    /**
     * @brief The application's icon.
     *
     * Holds a path to the icon for the application. Can be a file or a gicon url.
     */
    Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged)

    /**
     * @brief The application's state.
     *
     * Holds the current application state.
     */
    Q_PROPERTY(State state READ state NOTIFY stateChanged)

    /**
     * @brief The application's requested running state
     */
    Q_PROPERTY(RequestedState requestedState READ requestedState WRITE setRequestedState NOTIFY requestedStateChanged)

    /**
     * @brief The application's focus state.
     *
     * Holds the current application focus state. True if focused, false otherwise.
     */
    Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)

    /**
     * @brief Show Splash screen
     *
     * A splash screen is shown while the application is loading,
     * before it has drawn its first frame. This sets if it should be shown or not
     */
    Q_PROPERTY(bool showSplash READ showSplash CONSTANT)

    /**
     * @brief Splash screen title
     *
     * @see splashShowHeader
     * Title of the splash screen, to be displayed on its header.
     *
     * A splash screen is shown while the application is loading,
     * before it has drawn its first frame.
     */
    Q_PROPERTY(QString splashTitle READ splashTitle CONSTANT)

    /**
     * @brief Splash image
     *
     * Url of the splash image to be shown while the application is loading,
     * before it has drawn its first frame.
     *
     * The splash image is centered on the splash screen and displayed in
     * its actual size (ie, it's not stretched or shrinked and aspect ratio
     * is kept).
     */
    Q_PROPERTY(QUrl splashImage READ splashImage CONSTANT)

    /**
     * @brief Whether an application header should be shown on the splash screen
     *
     * We offer 2 kinds of splash screens for applications:
     * 1. A splash with a gradient background and image
     * 2. A splash faking a MainView with header text set. So it is possible to
     *    arrange things so that once the app starts up, this splash and the app's
     *    first frame are identical.
     *
     * This property is the switch to select between these.
     *
     * The header will display the splashTitle, if defined, or the application
     * name otherwise.
     *
     * @see name, splashTitle
     */
    Q_PROPERTY(bool splashShowHeader READ splashShowHeader CONSTANT)

    /**
     * @brief Background color of the splash screen
     *
     * Any color that is not fully opaque (having an alpha value of less than
     * 1.0) is ignored and the default background color will be used instead.
     *
     * A splash screen is shown while the application is loading,
     * before it has drawn its first frame.
     */
    Q_PROPERTY(QColor splashColor READ splashColor CONSTANT)

    /**
     * @brief Color of the splash screen header
     *
     * Any color that is not fully opaque (having an alpha value of less than
     * 1.0) is ignored and the splashColor will be used instead.
     *
     * A splash screen is shown while the application is loading,
     * before it has drawn its first frame.
     *
     * @see splashColor
     */
    Q_PROPERTY(QColor splashColorHeader READ splashColorHeader CONSTANT)

    /**
     * @brief Color of the splash screen footer
     *
     * Any color that is not fully opaque (having an alpha value of less than
     * 1.0) is ignored and the splashColor will be used instead.
     *
     * A splash screen is shown while the application is loading,
     * before it has drawn its first frame.
     *
     * @see splashColor
     */
    Q_PROPERTY(QColor splashColorFooter READ splashColorFooter CONSTANT)

    /**
     * @brief The orientations supported by the application UI
     * @see rotatesContents
     */
    Q_PROPERTY(Qt::ScreenOrientations supportedOrientations READ supportedOrientations CONSTANT)

    /**
     * @brief Whether the application UI will rotate itself to match the screen orientation
     *
     * Returns true if the application will rotate the UI in its windows to match the screen
     * orientation.
     *
     * If false, it means that the application never rotates its UI, so it will
     * rely on the window manager to appropriately rotate his windows to match the screen
     * orientation instead.
     *
     * @see supportedOrientations
     */
    Q_PROPERTY(bool rotatesWindowContents READ rotatesWindowContents CONSTANT)

    /**
     * @brief Whether the application is an app targeting the Ubuntu Touch platform.
     */
    Q_PROPERTY(bool isTouchApp READ isTouchApp CONSTANT)

    /**
     * @brief Whether this app is exempt from lifecycle management
     *
     * If true, this app will never entirely suspend its process.
     */
    Q_PROPERTY(bool exemptFromLifecycle READ exemptFromLifecycle WRITE setExemptFromLifecycle NOTIFY exemptFromLifecycleChanged)

    /**
     * @brief The size to be given for new surfaces created by this application
     */
    Q_PROPERTY(QSize initialSurfaceSize READ initialSurfaceSize WRITE setInitialSurfaceSize NOTIFY initialSurfaceSizeChanged)

    /**
     * @brief List of the top-level surfaces created by this application
     */
    Q_PROPERTY(lomiri::shell::application::MirSurfaceListInterface* surfaceList READ surfaceList CONSTANT)

    /**
     * @brief The list of top-level prompt surfaces for this application
     */
    Q_PROPERTY(lomiri::shell::application::MirSurfaceListInterface* promptSurfaceList READ promptSurfaceList CONSTANT)

    /**
     * @brief Count of application's surfaces
     *
     * This is a convenience property and will always be the same as surfaceList->count().
     * It allows to connect to an application and listen for surface creations/removals for
     * that particular application without having to keep track of the
     * application <-> surfaceList relationship.
     */
     Q_PROPERTY(int surfaceCount READ surfaceCount NOTIFY surfaceCountChanged)

    /**
     * @brief Whether the application wants server side decoration
     *
     * By default this will be true, but may be false if the application specifically requested it
     * to be off
     */
    Q_PROPERTY(bool serverSideDecoration READ serverSideDecoration NOTIFY serverSideDecorationChanged)

protected:
    /// @cond
    ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }
    /// @endcond

public:
    /**
     * @brief A enum that defines a stage.
     *
     * MainStage: The main stage, which is the normal place for applications in
     * traditional desktop environments.
     * SideStage: The side stage, a panel on the right to place phone form factor
     * applications.
     */
    enum Stage {
        MainStage,
        SideStage
    };
    Q_ENUM(Stage)

    /**
     * @brief An application's state.
     *
     * Starting: The application was launched and is currently starting up.
     * Running: The application is running and ready to be used.
     * Suspended: The application is in the background and has been suspended by
     * the system in order to save resources.
     * Stopped: The application is in the background and has been stopped by
     * the system in order to save resources. From a programmers point of view,
     * the application is closed, but it's state has been stored to disk and
     * can be restored upon next launch.
     */
    enum State {
        Starting,
        Running,
        Suspended,
        Stopped
    };
    Q_ENUM(State)

    /**
     * @brief The desired state of an application
     *
     * RequestedRunning: If state is Suspended or Stopped, the application will be resumed
     *                   or restarted, respectively.
     * RequestedSuspended: If state is Running, the application will be suspended.
     */
    enum RequestedState {
        RequestedRunning = Running,
        RequestedSuspended = Suspended
    };
    Q_ENUM(RequestedState)

    /**
     * @brief Closes the application
     */
    virtual void close() = 0;

    /// @cond
    virtual ~ApplicationInfoInterface() {}

    virtual QString appId() const = 0;
    virtual QString name() const = 0;
    virtual QString comment() const = 0;
    virtual QUrl icon() const = 0;
    virtual State state() const = 0;
    virtual RequestedState requestedState() const = 0;
    virtual void setRequestedState(RequestedState) = 0;
    virtual bool focused() const = 0;
    virtual bool showSplash() const = 0;
    virtual QString splashTitle() const = 0;
    virtual QUrl splashImage() const = 0;
    virtual bool splashShowHeader() const = 0;
    virtual QColor splashColor() const = 0;
    virtual QColor splashColorHeader() const = 0;
    virtual QColor splashColorFooter() const = 0;
    virtual Qt::ScreenOrientations supportedOrientations() const = 0;
    virtual bool rotatesWindowContents() const = 0;
    virtual bool isTouchApp() const = 0;
    virtual bool exemptFromLifecycle() const = 0;
    virtual void setExemptFromLifecycle(bool) = 0;
    virtual QSize initialSurfaceSize() const = 0;
    virtual void setInitialSurfaceSize(const QSize &size) = 0;
    virtual MirSurfaceListInterface* surfaceList() const = 0;
    virtual MirSurfaceListInterface* promptSurfaceList() const = 0;
    virtual int surfaceCount() const = 0;
    virtual bool serverSideDecoration() const = 0;
    /// @endcond

Q_SIGNALS:
    /// @cond
    void nameChanged(const QString &name);
    void commentChanged(const QString &comment);
    void iconChanged(const QUrl &icon);
    void stateChanged(State state);
    void requestedStateChanged(RequestedState value);
    void focusedChanged(bool focused);
    void exemptFromLifecycleChanged(bool exemptFromLifecycle);
    void initialSurfaceSizeChanged(const QSize &size);
    void surfaceCountChanged(int surfaceCount);
    void serverSideDecorationChanged(bool ssd);
    /// @endcond

    /**
     * @brief The application is requesting focus
     */
    void focusRequested();
};

} // namespace application
} // namespace shell
} // namespace lomiri

Q_DECLARE_METATYPE(lomiri::shell::application::ApplicationInfoInterface*)

#endif // LOMIRI_SHELL_APPLICATIONMANAGER_APPLICATIONINFOINTERFACE_H