My Project
ApplicationManagerInterface.h
1/*
2 * Copyright 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 Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Michael Zanetti <michael.zanetti@canonical.com>
18 */
19
20#ifndef LOMIRI_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
21#define LOMIRI_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
22
23#include <lomiri/SymbolExport.h>
24
25#include <QtCore/QObject>
26#include <QtCore/QAbstractListModel>
27
28namespace lomiri
29{
30namespace shell
31{
32namespace application
33{
34
35class ApplicationInfoInterface;
36class MirSurfaceInterface;
37
44class LOMIRI_API ApplicationManagerInterface: public QAbstractListModel
45{
46 Q_OBJECT
47
53 Q_PROPERTY(int count READ count NOTIFY countChanged)
54
55
60 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
61
62protected:
64 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
65 {
66 m_roleNames.insert(RoleAppId, "appId");
67 m_roleNames.insert(RoleName, "name");
68 m_roleNames.insert(RoleComment, "comment");
69 m_roleNames.insert(RoleIcon, "icon");
70 m_roleNames.insert(RoleState, "state");
71 m_roleNames.insert(RoleFocused, "focused");
72 m_roleNames.insert(RoleIsTouchApp, "isTouchApp");
73 m_roleNames.insert(RoleExemptFromLifecycle, "exemptFromLifecycle");
74 m_roleNames.insert(RoleApplication, "application");
75
76 connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
77 connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
78 connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
79 connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged()));
80 }
82
83public:
89 enum Roles {
90 RoleAppId = Qt::UserRole,
91 RoleName,
92 RoleComment,
93 RoleIcon,
94 RoleState,
95 RoleFocused,
96 RoleIsTouchApp,
97 RoleExemptFromLifecycle,
98 RoleApplication,
99 };
100 Q_ENUM(Roles)
101
102
104
105 QHash<int, QByteArray> roleNames() const override
106 {
107 return m_roleNames;
108 }
109
110 int count() const {
111 return rowCount();
112 }
113
114 virtual QString focusedApplicationId() const = 0;
115
117
126 Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *get(int index) const = 0;
127
136 Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
137
138 /*
139 * @brief Returns the AplicationInfo with the given surface
140 */
141 virtual ApplicationInfoInterface *findApplicationWithSurface(MirSurfaceInterface* surface) const = 0;
142
151 Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
152
160 Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
161
168 Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
169
170Q_SIGNALS:
172 void countChanged();
174
181 void focusRequested(const QString &appId);
182
187
188protected:
190 QHash<int, QByteArray> m_roleNames;
192};
193
194} // namespace application
195} // namespace shell
196} // namespace lomiri
197
198#endif // LOMIRI_SHELL_APPLICATIONMANAGER_APPLICATIONINFO_H
A class that holds information about applications.
Definition: ApplicationInfoInterface.h:44
The Application manager.
Definition: ApplicationManagerInterface.h:45
virtual Q_INVOKABLE bool requestFocusApplication(const QString &appId)=0
Request to focus a given application.
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * findApplication(const QString &appId) const =0
Get an ApplicationInfo item (using the appId).
void focusedApplicationIdChanged()
Will be emitted whenever the focused application changes.
virtual Q_INVOKABLE bool stopApplication(const QString &appId)=0
Stops an application.
Roles
The Roles supported by the model.
Definition: ApplicationManagerInterface.h:89
void focusRequested(const QString &appId)
Will be emitted right before the focused application changes.
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * startApplication(const QString &appId, const QStringList &arguments)=0
Start an application.
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * get(int index) const =0
Get an ApplicationInfo item (using stack index).
Holds a Mir surface. Pretty much an opaque class.
Definition: MirSurfaceInterface.h:42
Top-level namespace for all things Lomiri-related.
Definition: Version.h:38