on aafc6d8 help sign in
unity8/tests/mocks/Unity/Application/ApplicationManager.h
134 lines 4.5 kB history raw
1/*
2 * Copyright (C) 2013-2014 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_MANAGER_H
18#define APPLICATION_MANAGER_H
20#include <QObject>
21#include <QList>
22#include <QStringList>
23#include "ApplicationInfo.h"
25// unity-api
26#include <unity/shell/application/ApplicationManagerInterface.h>
28class QQuickItem;
29using namespace unity::shell::application;
31class ApplicationManager : public ApplicationManagerInterface {
32 Q_OBJECT
33 Q_ENUMS(Role)
34 Q_ENUMS(StageHint)
35 Q_ENUMS(FormFactorHint)
36 Q_ENUMS(FavoriteApplication)
37 Q_FLAGS(ExecFlags)
39 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
41 Q_PROPERTY(int sideStageWidth READ sideStageWidth)
42 Q_PROPERTY(StageHint stageHint READ stageHint)
43 Q_PROPERTY(FormFactorHint formFactorHint READ formFactorHint)
45 Q_PROPERTY(bool fake READ fake CONSTANT)
47 public:
48 ApplicationManager(QObject *parent = NULL);
49 virtual ~ApplicationManager();
51 static ApplicationManager *singleton();
53 enum MoreRoles {
54 RoleSurface = RoleScreenshot+1,
55 RoleFullscreen,
56 };
57 enum Role {
58 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,
59 ShutdownDialog
60 };
61 enum StageHint {
62 MainStage, IntegrationStage, ShareStage, ContentPickingStage,
63 SideStage, ConfigurationStage
64 };
65 enum FormFactorHint {
66 DesktopFormFactor, PhoneFormFactor, TabletFormFactor
67 };
68 enum FavoriteApplication {
69 CameraApplication, GalleryApplication, BrowserApplication, ShareApplication,
70 PhoneApplication, DialerApplication, MessagingApplication, AddressbookApplication
71 };
72 enum Flag {
73 NoFlag = 0x0,
74 ForceMainStage = 0x1,
75 };
76 Q_DECLARE_FLAGS(ExecFlags, Flag)
78 int sideStageWidth() const;
79 StageHint stageHint() const;
80 FormFactorHint formFactorHint() const;
82 bool fake() { return true; }
84 // QAbstractItemModel methods.
85 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
86 QVariant data(const QModelIndex& index, int role) const override;
87 Q_INVOKABLE ApplicationInfo *get(int index) const override;
88 Q_INVOKABLE ApplicationInfo *findApplication(const QString &appId) const override;
90 Q_INVOKABLE void move(int from, int to);
92 // Application control methods
93 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;
94 Q_INVOKABLE bool focusApplication(const QString &appId) override;
95 Q_INVOKABLE void unfocusCurrentApplication() override;
96 Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, const QStringList &arguments = QStringList()) override;
97 Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, ExecFlags flags, const QStringList &arguments = QStringList());
98 Q_INVOKABLE bool stopApplication(const QString &appId) override;
99 Q_INVOKABLE bool updateScreenshot(const QString &appId) override;
101 QString focusedApplicationId() const override;
102 bool suspended() const;
103 void setSuspended(bool suspended);
105 // Only for testing
106 Q_INVOKABLE QStringList availableApplications();
108 QModelIndex findIndex(ApplicationInfo* application);
110 bool isEmpty() const;
112 Q_SIGNALS:
113 void focusRequested(FavoriteApplication favoriteApplication);
114 void focusRequested(const QString &appId);
115 void emptyChanged(bool empty);
117 private:
118 void add(ApplicationInfo *application);
119 void remove(ApplicationInfo* application);
120 void showApplicationWindow(ApplicationInfo *application);
121 void buildListOfAvailableApplications();
122 void generateQmlStrings(ApplicationInfo *application);
123 bool m_suspended;
124 QList<ApplicationInfo*> m_runningApplications;
125 QList<ApplicationInfo*> m_availableApplications;
127 static ApplicationManager *the_application_manager;
128};
130Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
132Q_DECLARE_METATYPE(ApplicationManager*)
134#endif // APPLICATION_MANAGER_H