Merge lp:~gerboland/unity-api/adjust-application-api into lp:unity-api

Proposed by Gerry Boland
Status: Merged
Approved by: Michael Zanetti
Approved revision: 99
Merged at revision: 95
Proposed branch: lp:~gerboland/unity-api/adjust-application-api
Merge into: lp:unity-api
Diff against target: 201 lines (+62/-31)
4 files modified
include/unity/shell/application/ApplicationManagerInterface.h (+23/-10)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+28/-13)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+9/-7)
test/qmltest/unity/shell/application/tst_Application.qml (+2/-1)
To merge this branch: bzr merge lp:~gerboland/unity-api/adjust-application-api
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+183641@code.launchpad.net

Commit message

ApplicationManagerInterface: adjust API to use appId for app start/stop/focus. Return ApplicationInfoInterface only in get(index) and the new findApplication(appId) methods.

Description of the change

ApplicationManagerInterface: adjust API to use appId for app start/stop/focus. Return ApplicationInfoInterface only in get(index) and the new findApplication(appId) methods.

To post a comment you must log in.
96. By Gerry Boland

Missing full stop

Revision history for this message
Michael Zanetti (mzanetti) wrote :

9 + Q_PROPERTY(QString focusedApplication READ focusedApplication NOTIFY focusedApplicationChanged)

As we still support ApplicationInfo objects I'd probably rename this to focusedApplicationId

30 - Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
33 + Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(const int index) const = 0;

I don't really see the point of this. It only restricts the usage of the variable in the actual implementation without any benefit (as we're creating a copy of that integer anyways). But not a real problem either.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

> 9 + Q_PROPERTY(QString focusedApplication READ focusedApplication NOTIFY
> focusedApplicationChanged)
>
> As we still support ApplicationInfo objects I'd probably rename this to
> focusedApplicationId

+1

> 30 - Q_INVOKABLE virtual
> unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
> 33 + Q_INVOKABLE virtual
> unity::shell::application::ApplicationInfoInterface *get(const int index)
> const = 0;
>
> I don't really see the point of this. It only restricts the usage of the
> variable in the actual implementation without any benefit (as we're creating a
> copy of that integer anyways). But not a real problem either.

Well I did it as I can't imagine an implementation that will actually modify that value :) It's a possible micro-optimization, but not worth fighting over either. I'll remove to reduce the diff

97. By Gerry Boland

Remove const from get(index)

98. By Gerry Boland

Fix doc errors

99. By Gerry Boland

Rename property focusedApplication to focusedApplicationId

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
2--- include/unity/shell/application/ApplicationManagerInterface.h 2013-08-29 12:46:31 +0000
3+++ include/unity/shell/application/ApplicationManagerInterface.h 2013-09-03 13:52:17 +0000
4@@ -56,7 +56,7 @@
5 *
6 * Use focusApplication() and unfocusCurrentApplication() to modify this.
7 */
8- Q_PROPERTY(unity::shell::application::ApplicationInfoInterface* focusedApplication READ focusedApplication NOTIFY focusedApplicationChanged)
9+ Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
10
11 protected:
12 /// @cond
13@@ -105,25 +105,36 @@
14 return rowCount();
15 }
16
17- virtual unity::shell::application::ApplicationInfoInterface *focusedApplication() const = 0;
18+ virtual QString focusedApplicationId() const = 0;
19 /// @endcond
20
21 /**
22- * @brief Get an ApplicationInfo item.
23+ * @brief Get an ApplicationInfo item (using stack index).
24 *
25 * Note: QML requires the full namespace in the return value.
26 *
27 * @param index the index of the item to get
28- * @returns The item.
29+ * @returns The item, or null if not found.
30 */
31 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *get(int index) const = 0;
32
33 /**
34+ * @brief Get an ApplicationInfo item (using the appId).
35+ *
36+ * Note: QML requires the full namespace in the return value.
37+ *
38+ * @param appId the appId of the item to get
39+ * @returns The item, or null if not found.
40+ */
41+ Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
42+
43+ /**
44 * @brief Focus the given application.
45 *
46- * @param application The application to be focused.
47+ * @param appId The application to be focused.
48+ * @returns True if appId found and application focused, else false.
49 */
50- Q_INVOKABLE virtual void focusApplication(ApplicationInfoInterface *application) = 0;
51+ Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
52
53 /**
54 * @brief Unfocus the currently focused application.
55@@ -135,15 +146,17 @@
56 *
57 * @param appId The appId for the application to be spawned.
58 * @param arguments Any arguments to be passed to the process.
59+ * @returns True if application start successful, else false.
60 */
61- Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface* startApplication(const QString &appId, const QStringList &arguments) = 0;
62+ Q_INVOKABLE virtual bool startApplication(const QString &appId, const QStringList &arguments) = 0;
63
64 /**
65 * @brief Stops an application.
66 *
67- * @param application The application to be stopped.
68+ * @param appId The application to be stopped.
69+ * @returns True if application stop successful, else false (i.e. false if application was not running).
70 */
71- Q_INVOKABLE virtual void stopApplication(ApplicationInfoInterface* application) = 0;
72+ Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
73
74 Q_SIGNALS:
75 /// @cond
76@@ -153,7 +166,7 @@
77 /**
78 * @brief Will be emitted whenever the focused application changes.
79 */
80- void focusedApplicationChanged();
81+ void focusedApplicationIdChanged();
82
83 protected:
84 /// @cond
85
86=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
87--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2013-08-29 12:54:56 +0000
88+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2013-09-03 13:52:17 +0000
89@@ -75,33 +75,48 @@
90 {
91 if (index < 0 || index >= m_list.count())
92 {
93- return 0;
94+ return nullptr;
95 }
96 return m_list.at(index);
97 }
98
99-unity::shell::application::ApplicationInfoInterface *MockApplicationManager::focusedApplication() const
100-{
101- return m_list.first();
102-}
103-
104-void MockApplicationManager::focusApplication(ApplicationInfoInterface *application)
105-{
106- Q_UNUSED(application)
107+unity::shell::application::ApplicationInfoInterface *MockApplicationManager::findApplication(const QString &appId) const
108+{
109+ for (auto app : m_list)
110+ {
111+ if (app->appId() == appId)
112+ {
113+ return app;
114+ }
115+ }
116+ return nullptr;
117+}
118+
119+QString MockApplicationManager::focusedApplicationId() const
120+{
121+ auto first = m_list.first();
122+ return (first) ? first->appId() : QString();
123+}
124+
125+bool MockApplicationManager::focusApplication(const QString &appId)
126+{
127+ Q_UNUSED(appId)
128+ return true;
129 }
130
131 void MockApplicationManager::unfocusCurrentApplication()
132 {
133 }
134
135-unity::shell::application::ApplicationInfoInterface *MockApplicationManager::startApplication(const QString &appId, const QStringList &arguments)
136+bool MockApplicationManager::startApplication(const QString &appId, const QStringList &arguments)
137 {
138 Q_UNUSED(appId)
139 Q_UNUSED(arguments)
140- return 0;
141+ return true;
142 }
143
144-void MockApplicationManager::stopApplication(unity::shell::application::ApplicationInfoInterface *application)
145+bool MockApplicationManager::stopApplication(const QString &appId)
146 {
147- Q_UNUSED(application)
148+ Q_UNUSED(appId)
149+ return true;
150 }
151
152=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
153--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2013-08-29 12:54:56 +0000
154+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2013-09-03 13:52:17 +0000
155@@ -38,17 +38,19 @@
156
157 QVariant data(const QModelIndex& index, int role) const;
158
159- unity::shell::application::ApplicationInfoInterface *focusedApplication() const;
160-
161- Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(int index) const;
162-
163- Q_INVOKABLE void focusApplication(unity::shell::application::ApplicationInfoInterface *application);
164+ QString focusedApplicationId() const;
165+
166+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;
167+
168+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;
169+
170+ Q_INVOKABLE bool focusApplication(const QString &appId);
171
172 Q_INVOKABLE void unfocusCurrentApplication();
173
174- Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments);
175+ Q_INVOKABLE bool startApplication(const QString &appId, const QStringList &arguments);
176
177- Q_INVOKABLE void stopApplication(unity::shell::application::ApplicationInfoInterface *application);
178+ Q_INVOKABLE bool stopApplication(const QString &appId);
179
180 private:
181 QList<MockApplicationInfo*> m_list;
182
183=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
184--- test/qmltest/unity/shell/application/tst_Application.qml 2013-08-29 12:38:58 +0000
185+++ test/qmltest/unity/shell/application/tst_Application.qml 2013-09-03 13:52:17 +0000
186@@ -86,6 +86,7 @@
187 function test_model_methods_data() {
188 return [
189 { tag: "ApplicationManager.methods[get]", method: "get" },
190+ { tag: "ApplicationManager.methods[findApplication]", method: "findApplication" },
191 { tag: "ApplicationManager.methods[focusApplication]", method: "focusApplication" },
192 { tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" },
193 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },
194@@ -102,7 +103,7 @@
195 function test_model_properties_data() {
196 return [
197 { tag: "ApplicationManager.count", property: "count", type: "number" },
198- { tag: "ApplicationManager.focusedApplication", property: "focusedApplication", type: "unity::shell::application::ApplicationInfoInterface" },
199+ { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },
200 ];
201 }
202

Subscribers

People subscribed via source and target branches

to all changes: