on e2c239f help sign in
unity8/tests/mocks/Unity/Application/ApplicationManager.h
127 lines 4.6 kB history raw
1/*
2 * Copyright (C) 2013 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 "ApplicationListModel.h"
24#include "ApplicationInfo.h"
26class QQuickItem;
28class ApplicationManager : public QObject {
29 Q_OBJECT
30 Q_ENUMS(Role)
31 Q_ENUMS(StageHint)
32 Q_ENUMS(FormFactorHint)
33 Q_ENUMS(FavoriteApplication)
34 Q_FLAGS(ExecFlags)
36 Q_PROPERTY(int keyboardHeight READ keyboardHeight NOTIFY keyboardHeightChanged)
37 Q_PROPERTY(bool keyboardVisible READ keyboardVisible NOTIFY keyboardVisibleChanged)
39 Q_PROPERTY(int sideStageWidth READ sideStageWidth)
40 Q_PROPERTY(StageHint stageHint READ stageHint)
41 Q_PROPERTY(FormFactorHint formFactorHint READ formFactorHint)
42 Q_PROPERTY(ApplicationListModel* mainStageApplications READ mainStageApplications)
43 Q_PROPERTY(ApplicationListModel* sideStageApplications READ sideStageApplications)
44 Q_PROPERTY(ApplicationInfo* mainStageFocusedApplication READ mainStageFocusedApplication
45 NOTIFY mainStageFocusedApplicationChanged)
46 Q_PROPERTY(ApplicationInfo* sideStageFocusedApplication READ sideStageFocusedApplication
47 NOTIFY sideStageFocusedApplicationChanged)
49 Q_PROPERTY(bool fake READ fake CONSTANT)
51 public:
52 ApplicationManager(QObject *parent = NULL);
53 virtual ~ApplicationManager();
55 enum Role {
56 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,
57 ShutdownDialog
58 };
59 enum StageHint {
60 MainStage, IntegrationStage, ShareStage, ContentPickingStage,
61 SideStage, ConfigurationStage
62 };
63 enum FormFactorHint {
64 DesktopFormFactor, PhoneFormFactor, TabletFormFactor
65 };
66 enum FavoriteApplication {
67 CameraApplication, GalleryApplication, BrowserApplication, ShareApplication
68 };
69 enum Flag {
70 NoFlag = 0x0,
71 ForceMainStage = 0x1,
72 };
73 Q_DECLARE_FLAGS(ExecFlags, Flag)
75 int keyboardHeight() const;
76 bool keyboardVisible() const;
77 int sideStageWidth() const;
78 StageHint stageHint() const;
79 FormFactorHint formFactorHint() const;
80 ApplicationListModel* mainStageApplications() const;
81 ApplicationListModel* sideStageApplications() const;
82 ApplicationInfo* mainStageFocusedApplication() const;
83 ApplicationInfo* sideStageFocusedApplication() const;
85 bool fake() { return true; }
87 Q_INVOKABLE void focusApplication(int handle);
88 Q_INVOKABLE void unfocusCurrentApplication(StageHint stageHint);
89 Q_INVOKABLE ApplicationInfo* startProcess(QString desktopFile,
90 ExecFlags flags,
91 QStringList arguments = QStringList());
92 Q_INVOKABLE void stopProcess(ApplicationInfo* application);
93 Q_INVOKABLE void startWatcher() {}
95 Q_SIGNALS:
96 void keyboardHeightChanged();
97 void keyboardVisibleChanged();
98 void mainStageFocusedApplicationChanged();
99 void sideStageFocusedApplicationChanged();
100 void focusRequested(FavoriteApplication favoriteApplication);
102 private:
103 void showApplicationWindow(ApplicationInfo *application);
104 void buildListOfAvailableApplications();
105 void generateQmlStrings(ApplicationInfo *application);
106 void createMainStageComponent();
107 void createMainStage();
108 void createSideStageComponent();
109 void createSideStage();
110 int m_keyboardHeight;
111 bool m_keyboardVisible;
112 ApplicationListModel* m_mainStageApplications;
113 ApplicationListModel* m_sideStageApplications;
114 ApplicationInfo* m_mainStageFocusedApplication;
115 ApplicationInfo* m_sideStageFocusedApplication;
116 QList<ApplicationInfo*> m_availableApplications;
117 QQmlComponent *m_mainStageComponent;
118 QQuickItem *m_mainStage;
119 QQmlComponent *m_sideStageComponent;
120 QQuickItem *m_sideStage;
121};
123Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
125Q_DECLARE_METATYPE(ApplicationManager*)
127#endif // APPLICATION_MANAGER_H