Loading...
Searching...
No Matches
ApplicationManagerInterface.h
/*
* Copyright 2013,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/>.
*
* Authors:
* Michael Zanetti <michael.zanetti@canonical.com>
*/
#ifndef LOMIRI_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
#define LOMIRI_SHELL_APPLICATION_APPLICATIONMANAGERINTERFACE_H
#include <lomiri/SymbolExport.h>
#include <QtCore/QObject>
#include <QtCore/QAbstractListModel>
namespace lomiri
{
namespace shell
{
namespace application
{
class ApplicationInfoInterface;
class MirSurfaceInterface;
class LOMIRI_API ApplicationManagerInterface: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
protected:
ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
{
m_roleNames.insert(RoleAppId, "appId");
m_roleNames.insert(RoleName, "name");
m_roleNames.insert(RoleComment, "comment");
m_roleNames.insert(RoleIcon, "icon");
m_roleNames.insert(RoleState, "state");
m_roleNames.insert(RoleFocused, "focused");
m_roleNames.insert(RoleIsTouchApp, "isTouchApp");
m_roleNames.insert(RoleExemptFromLifecycle, "exemptFromLifecycle");
m_roleNames.insert(RoleApplication, "application");
connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged()));
}
public:
enum Roles {
RoleAppId = Qt::UserRole,
RoleName,
RoleComment,
RoleIcon,
RoleState,
RoleFocused,
RoleIsTouchApp,
RoleExemptFromLifecycle,
RoleApplication,
};
Q_ENUM(Roles)
virtual ~ApplicationManagerInterface() {}
QHash<int, QByteArray> roleNames() const override
{
return m_roleNames;
}
int count() const {
return rowCount();
}
virtual QString focusedApplicationId() const = 0;
Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *get(int index) const = 0;
Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
/*
* @brief Returns the AplicationInfo with the given surface
*/
virtual ApplicationInfoInterface *findApplicationWithSurface(MirSurfaceInterface* surface) const = 0;
Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
Q_INVOKABLE virtual lomiri::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
Q_SIGNALS:
void countChanged();
void focusRequested(const QString &appId);
void focusedApplicationIdChanged();
protected:
QHash<int, QByteArray> m_roleNames;
};
} // namespace application
} // namespace shell
} // namespace lomiri
#endif // LOMIRI_SHELL_APPLICATIONMANAGER_APPLICATIONINFO_H
lomiri::shell::application::ApplicationInfoInterface
A class that holds information about applications.
Definition ApplicationInfoInterface.h:44
lomiri::shell::application::ApplicationManagerInterface
The Application manager.
Definition ApplicationManagerInterface.h:45
lomiri::shell::application::ApplicationManagerInterface::requestFocusApplication
virtual Q_INVOKABLE bool requestFocusApplication(const QString &appId)=0
Request to focus a given application.
lomiri::shell::application::ApplicationManagerInterface::findApplication
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * findApplication(const QString &appId) const =0
Get an ApplicationInfo item (using the appId).
lomiri::shell::application::ApplicationManagerInterface::focusedApplicationIdChanged
void focusedApplicationIdChanged()
Will be emitted whenever the focused application changes.
lomiri::shell::application::ApplicationManagerInterface::stopApplication
virtual Q_INVOKABLE bool stopApplication(const QString &appId)=0
Stops an application.
lomiri::shell::application::ApplicationManagerInterface::Roles
Roles
The Roles supported by the model.
Definition ApplicationManagerInterface.h:89
lomiri::shell::application::ApplicationManagerInterface::focusRequested
void focusRequested(const QString &appId)
Will be emitted right before the focused application changes.
lomiri::shell::application::ApplicationManagerInterface::startApplication
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * startApplication(const QString &appId, const QStringList &arguments)=0
Start an application.
lomiri::shell::application::ApplicationManagerInterface::get
virtual Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * get(int index) const =0
Get an ApplicationInfo item (using stack index).
lomiri::shell::application::MirSurfaceInterface
Holds a Mir surface. Pretty much an opaque class.
Definition MirSurfaceInterface.h:42
lomiri
Top-level namespace for all things Lomiri-related.
Definition Version.h:38