on xenial help sign in
Remove Hud

It's not seeded into the image anymore Let's save some compiling cycles, we can bring it later if needed

commitba2f35994017f026d086b0ef3abe0f8cca0ab35d authorAlbert Astals <albert.astals@canonical.com> dateTue 28 Oct 2014, 12:06 (12 years ago) parent1ff2631
55 files changed−3679
debian/control−2 plugins/CMakeLists.txt−1 plugins/HudClient/CMakeLists.txt−38 plugins/HudClient/HudClient.qmltypes−91 plugins/HudClient/hudclient.cpp−294 plugins/HudClient/hudclient.h−71 plugins/HudClient/hudtoolbarmodel.cpp−98 plugins/HudClient/hudtoolbarmodel.h−44 plugins/HudClient/plugin.cpp−36 plugins/HudClient/plugin.h−31 plugins/HudClient/qmldir−3 plugins/HudClient/volumepeakdetector.cpp−223 plugins/HudClient/volumepeakdetector.h−78 qml/CMakeLists.txt−1 qml/Hud/Hud.qml−497 qml/Hud/HudParametrizedActionsPage.qml−180 qml/Hud/Result.qml−84 qml/Hud/ResultList.qml−106 qml/Hud/SearchBar.qml−100 qml/Hud/ShowingAnimation.qml−54 qml/Hud/SliderLabel.qml−76 qml/Hud/SoundAmplitudeDelegate.qml−52 qml/Hud/SoundAmplitudeVisual.qml−146 qml/Hud/ToolBar.qml−33 qml/Hud/ToolBarIcon.qml−32 qml/Hud/graphics/divider@20.png qml/Hud/graphics/divider@20.sci−5 qml/Hud/graphics/help@20.png qml/Hud/graphics/hud_bg@20.png qml/Hud/graphics/hud_handlearrow@20.png qml/Hud/graphics/hud_handlebar@20.png qml/Hud/graphics/icon_arrow@20.png qml/Hud/graphics/icon_clear@20.png qml/Hud/graphics/icon_search@20.png qml/Hud/graphics/microphone@20.png qml/Hud/graphics/popup_triangle@20.png qml/Hud/graphics/settings@20.png qml/Hud/graphics/undo@20.png qml/Hud/graphics/view-fullscreen@20.png tests/autopilot/unity8/shell/emulators/hud.py−94 tests/autopilot/unity8/shell/emulators/main_window.py−13 tests/autopilot/unity8/shell/tests/__init__.py−3 tests/autopilot/unity8/shell/tests/disabled_test_hud.py−225 tests/mocks/CMakeLists.txt−1 tests/mocks/HudClient/CMakeLists.txt−38 tests/mocks/HudClient/HudClient.qmltypes−113 tests/mocks/HudClient/fake_hud_plugin.cpp−39 tests/mocks/HudClient/fake_hud_plugin.h−31 tests/mocks/HudClient/fake_libhud_client.cpp−247 tests/mocks/HudClient/libhud_client_stub.cpp−93 tests/mocks/HudClient/libhud_client_stub.h−64 tests/mocks/HudClient/qmldir−3 tests/qmltests/CMakeLists.txt−2 tests/qmltests/Hud/tst_Hud.qml−239 tests/qmltests/Hud/tst_Result.qml−98
debian/control−2
@@ -12,14 +12,12 @@ Build-Depends: cmake,
1212# in libstdc++ causing us issues, we explicitly select a G++
1313# version.
1414 g++-4.9,
15− libdee-qt5-dev (>= 3.2),
1615 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
1716 libgl1-mesa-dri,
1817 libgles2-mesa-dev[armhf],
1918 libglib2.0-dev,
2019 libgsettings-qt-dev,
2120 libhardware-dev,
22− libhud-client2-dev,
2321 libpam0g-dev,
2422 libpay2-dev,
2523 libpulse-dev,
plugins/CMakeLists.txt−1
@@ -12,7 +12,6 @@ macro(add_unity8_plugin PLUGIN VERSION PATH)
1212endmacro()
1313
1414add_subdirectory(AccountsService)
15−add_subdirectory(HudClient)
1615add_subdirectory(LightDM)
1716add_subdirectory(Lights)
1817add_subdirectory(Dash)
plugins/HudClient/CMakeLists.txtdeleted−38
@@ -1,38 +0,0 @@
1−find_package(Qt5Core REQUIRED)
2−find_package(Qt5Quick REQUIRED)
3−pkg_search_module(DEE dee-1.0 REQUIRED)
4−pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
5−pkg_search_module(HUDCLIENT hud-client-2 REQUIRED)
6−pkg_search_module(DEEQT libdee-qt5 REQUIRED)
7−pkg_search_module(PULSE libpulse REQUIRED)
8−
9−include_directories(
10− ${CMAKE_CURRENT_BINARY_DIR}
11− ${Qt5Core_INCLUDE_DIRS}
12− ${Qt5Quick_INCLUDE_DIRS}
13− ${DEE_INCLUDE_DIRS}
14− ${DEEQT_INCLUDE_DIRS}
15− ${HUDCLIENT_INCLUDE_DIRS}
16− ${PULSE_INCLUDE_DIRS}
17−)
18−
19−set(HudQML_SOURCES
20− hudclient.cpp
21− hudtoolbarmodel.cpp
22− volumepeakdetector.cpp
23− plugin.cpp
24−)
25−
26−add_library(HudClientQml MODULE ${HudQML_SOURCES})
27−target_link_libraries(HudClientQml
28− ${Qt5Core_LIBRARIES}
29− ${Qt5Quick_LIBRARIES}
30− ${DEEQT_LDFLAGS}
31− ${HUDCLIENT_LDFLAGS}
32− ${GOBJECT_LDFLAGS}
33− ${PULSE_LDFLAGS}
34−)
35−
36−qt5_use_modules(HudClientQml Qml)
37−
38−add_unity8_plugin(HudClient 0.1 HudClient TARGETS HudClientQml)
plugins/HudClient/HudClient.qmltypesdeleted−91
@@ -1,91 +0,0 @@
1−import QtQuick.tooling 1.1
2−
3−// This file describes the plugin-supplied types contained in the library.
4−// It is used for QML tooling purposes only.
5−//
6−// This file was auto-generated by:
7−// 'qmlplugindump -notrelocatable HudClient 0.1 plugins'
8−
9−Module {
10− Component {
11− name: "DeeListModel"
12− prototype: "QAbstractListModel"
13− Property { name: "name"; type: "string" }
14− Property { name: "synchronized"; type: "bool"; isReadonly: true }
15− Property { name: "count"; type: "int"; isReadonly: true }
16− Signal {
17− name: "nameChanged"
18− Parameter { type: "string" }
19− }
20− Signal {
21− name: "synchronizedChanged"
22− Parameter { type: "bool" }
23− }
24− Signal {
25− name: "roleNamesChanged"
26− Parameter { type: "QHash<int,QByteArray>" }
27− }
28− Method {
29− name: "get"
30− type: "QVariantMap"
31− Parameter { name: "row"; type: "int" }
32− }
33− Method { name: "count"; type: "int" }
34− }
35− Component {
36− name: "HudClient"
37− prototype: "QObject"
38− exports: ["HudClient/HudClient 0.1"]
39− exportMetaObjectRevisions: [0]
40− Property { name: "results"; type: "DeeListModel"; isReadonly: true; isPointer: true }
41− Property { name: "toolBarModel"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true }
42− Signal { name: "voiceQueryLoading" }
43− Signal { name: "voiceQueryListening" }
44− Signal { name: "voiceQueryHeardSomething" }
45− Signal { name: "voiceQueryFailed" }
46− Signal {
47− name: "voiceQueryFinished"
48− Parameter { name: "query"; type: "string" }
49− }
50− Signal { name: "commandExecuted" }
51− Signal {
52− name: "showParametrizedAction"
53− Parameter { name: "action"; type: "string" }
54− Parameter { name: "items"; type: "QVariant" }
55− }
56− Method {
57− name: "executeCommand"
58− Parameter { name: "index"; type: "int" }
59− }
60− Method {
61− name: "setQuery"
62− Parameter { name: "new_query"; type: "string" }
63− }
64− Method { name: "startVoiceQuery" }
65− Method {
66− name: "executeParametrizedAction"
67− Parameter { name: "values"; type: "QVariant" }
68− }
69− Method {
70− name: "updateParametrizedAction"
71− Parameter { name: "values"; type: "QVariant" }
72− }
73− Method { name: "cancelParametrizedAction" }
74− Method {
75− name: "executeToolBarAction"
76− Parameter { name: "action"; type: "HudClientQueryToolbarItems" }
77− }
78− }
79− Component {
80− name: "VolumePeakDetector"
81− prototype: "QObject"
82− exports: ["HudClient/VolumePeakDetector 0.1"]
83− exportMetaObjectRevisions: [0]
84− Property { name: "enabled"; type: "bool" }
85− Property { name: "desiredInterval"; type: "int" }
86− Signal {
87− name: "newPeak"
88− Parameter { name: "volume"; type: "float" }
89− }
90− }
91−}
plugins/HudClient/hudclient.cppdeleted−294
@@ -1,294 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include "hudclient.h"
18−
19−#include "hudtoolbarmodel.h"
20−
21−#include <deelistmodel.h>
22−
23−#include <QDebug>
24−
25−namespace
26−{
27−
28−extern "C"
29−{
30−
31−void loadingCB(GObject* /*src*/, gpointer dst)
32−{
33− static_cast<HudClient*>(dst)->voiceQueryLoading();
34−}
35−
36−void listeningCB(GObject* /*src*/, gpointer dst)
37−{
38− static_cast<HudClient*>(dst)->voiceQueryListening();
39−}
40−
41−void heardSomethingCB(GObject* /*src*/, gpointer dst)
42−{
43− static_cast<HudClient*>(dst)->voiceQueryHeardSomething();
44−}
45−
46−void failedCB(GObject* /*src*/, const gchar * /*reason*/, gpointer dst)
47−{
48− static_cast<HudClient*>(dst)->voiceQueryFailed();
49−}
50−
51−void finishedCB(GObject* /*src*/, const gchar* query, gpointer dst)
52−{
53− static_cast<HudClient*>(dst)->voiceQueryFinished(QString::fromUtf8(query));
54−}
55−
56−void modelReadyCB(GObject* /*src*/, gpointer dst)
57−{
58− static_cast<HudClient*>(dst)->modelReady(true);
59−}
60−
61−void modelReallyReadyCB(GObject* /*src*/, gint /*position*/, gint /*removed*/, gint /*added*/, gpointer dst)
62−{
63− static_cast<HudClient*>(dst)->modelReallyReady(true);
64−}
65−
66−static void modelsChangedCB(GObject* /*src*/, gpointer dst)
67−{
68− static_cast<HudClient*>(dst)->queryModelsChanged();
69−}
70−
71−static void toolBarUpdatedCB(GObject* /*src*/, gpointer dst)
72−{
73− static_cast<HudToolBarModel*>(dst)->updatedByBackend();
74−}
75−
76−} // extern "C"
77−
78−} // namespace
79−
80−HudClient::HudClient()
81−{
82− m_results = new DeeListModel();
83− m_clientQuery = hud_client_query_new("");
84− m_toolBarModel = new HudToolBarModel(m_clientQuery);
85− m_currentActionParam = nullptr;
86− m_results->setModel(hud_client_query_get_results_model(m_clientQuery));
87−
88− g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-loading", G_CALLBACK(loadingCB), this);
89− g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-listening", G_CALLBACK(listeningCB), this);
90− g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-heard-something", G_CALLBACK(heardSomethingCB), this);
91− g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-finished", G_CALLBACK(finishedCB), this);
92− g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-failed", G_CALLBACK(failedCB), this);
93− g_signal_connect(G_OBJECT(m_clientQuery), HUD_CLIENT_QUERY_SIGNAL_MODELS_CHANGED, G_CALLBACK(modelsChangedCB), this);
94− g_signal_connect(G_OBJECT(m_clientQuery), HUD_CLIENT_QUERY_SIGNAL_TOOLBAR_UPDATED, G_CALLBACK(toolBarUpdatedCB), m_toolBarModel);
95−}
96−
97−// Terrible hack to get around GLib. GLib stores function pointers as gpointer, which violates the C and C++ spec
98−// because data and function pointers may have different sizes. gcc rightfully emits a warning. There is no #pragma
99−// in gcc to selectively turn off the warning, however. This hack gets around the problem, by using a union (ick) to
100−// convert between the two types.
101−
102−class ToGPointer
103−{
104−public:
105− ToGPointer(void (*cb)())
106− {
107− u_.cb = cb;
108− }
109−
110− operator gpointer()
111− {
112− return u_.p;
113− }
114−
115−private:
116− union
117− {
118− void (*cb)();
119− gpointer p;
120− } u_;
121−};
122−
123−#define TO_GPOINTER(cb) (ToGPointer(reinterpret_cast<void(*)()>((cb))))
124−
125−HudClient::~HudClient()
126−{
127− g_signal_handlers_disconnect_by_func(G_OBJECT(m_clientQuery), TO_GPOINTER(loadingCB), this);
128− g_signal_handlers_disconnect_by_func(G_OBJECT(m_clientQuery), TO_GPOINTER(listeningCB), this);
129− g_signal_handlers_disconnect_by_func(G_OBJECT(m_clientQuery), TO_GPOINTER(heardSomethingCB), this);
130− g_signal_handlers_disconnect_by_func(G_OBJECT(m_clientQuery), TO_GPOINTER(finishedCB), this);
131− g_signal_handlers_disconnect_by_func(G_OBJECT(m_clientQuery), TO_GPOINTER(toolBarUpdatedCB), m_toolBarModel);
132−
133− delete m_results;
134− delete m_toolBarModel;
135−
136− g_object_unref(m_clientQuery);
137−}
138−
139−void HudClient::setQuery(const QString &new_query)
140−{
141− hud_client_query_set_query(m_clientQuery, new_query.toUtf8().constData());
142−}
143−
144−void HudClient::startVoiceQuery()
145−{
146− hud_client_query_voice_query(m_clientQuery);
147−}
148−
149−void HudClient::executeParametrizedAction(const QVariant &values)
150−{
151− updateParametrizedAction(values);
152− hud_client_param_send_commit(m_currentActionParam);
153− g_object_unref(m_currentActionParam);
154− m_currentActionParam = nullptr;
155− Q_EMIT commandExecuted();
156−}
157−
158−void HudClient::updateParametrizedAction(const QVariant &values)
159−{
160− if (m_currentActionParam != nullptr) {
161− const QVariantMap map = values.value<QVariantMap>();
162− GActionGroup *ag = hud_client_param_get_actions(m_currentActionParam);
163−
164− auto it = map.begin();
165− for ( ; it != map.end(); ++it) {
166− const QString action = it.key();
167− const QVariant value = it.value();
168− const GVariantType *actionType = g_action_group_get_action_parameter_type(ag, action.toUtf8().constData());
169− if (g_variant_type_equal(actionType, G_VARIANT_TYPE_DOUBLE) && value.canConvert(QVariant::Double)) {
170− g_action_group_activate_action(ag, action.toUtf8().constData(), g_variant_new_double(value.toDouble()));
171− } else {
172− qWarning() << "Unsuported action type in HudClient::executeParametrizedAction";
173− }
174− }
175− } else {
176− qWarning() << "Got to HudClient::updateParametrizedAction with no m_currentActionParam";
177− }
178−}
179−
180−void HudClient::cancelParametrizedAction()
181−{
182− if (m_currentActionParam != nullptr) {
183− hud_client_param_send_cancel(m_currentActionParam);
184− g_object_unref(m_currentActionParam);
185− m_currentActionParam = nullptr;
186− }
187−}
188−
189−void HudClient::executeToolBarAction(HudClientQueryToolbarItems action)
190−{
191− hud_client_query_execute_toolbar_item(m_clientQuery, action, /* timestamp */ 0);
192− Q_EMIT commandExecuted();
193−}
194−
195−DeeListModel *HudClient::results() const
196−{
197− return m_results;
198−}
199−
200−QAbstractItemModel *HudClient::toolBarModel() const
201−{
202− return m_toolBarModel;
203−}
204−
205−void HudClient::executeCommand(int index)
206−{
207− m_currentActionIndex = index;
208− DeeModel *model = hud_client_query_get_results_model(m_clientQuery);
209− DeeModelIter *iter = dee_model_get_iter_at_row(model, index);
210−
211− GVariant *command_key = dee_model_get_value(model, iter, 0);
212− GVariant *is_parametrized = dee_model_get_value(model, iter, 7);
213− if (g_variant_get_boolean(is_parametrized)) {
214− m_currentActionParam = hud_client_query_execute_param_command(m_clientQuery, command_key, /* timestamp */ 0);
215− if (m_currentActionParam != nullptr) {
216− GMenuModel *menuModel = hud_client_param_get_model (m_currentActionParam);
217− if (menuModel == nullptr) {
218− g_signal_connect(m_currentActionParam, HUD_CLIENT_PARAM_SIGNAL_MODEL_READY, G_CALLBACK(modelReadyCB), this);
219− } else {
220− modelReady(false);
221− }
222− } else {
223− qWarning() << "HudClient::executeCommand::Could not get the HudClientParam for parametrized action with index" << index;
224− }
225− } else {
226− hud_client_query_execute_command(m_clientQuery, command_key, /* timestamp */ 0);
227− Q_EMIT commandExecuted();
228− }
229− g_variant_unref(command_key);
230− g_variant_unref(is_parametrized);
231−}
232−
233−void HudClient::modelReady(bool needDisconnect)
234−{
235− if (needDisconnect) {
236− g_signal_handlers_disconnect_by_func(m_currentActionParam, TO_GPOINTER(modelReadyCB), this);
237− }
238− GMenuModel *menuModel = hud_client_param_get_model (m_currentActionParam);
239− if (g_menu_model_get_n_items(menuModel) == 0) {
240− g_signal_connect(menuModel, "items-changed", G_CALLBACK(modelReallyReadyCB), this);
241− } else {
242− modelReallyReady(false);
243− }
244−}
245−
246−static void addAttribute(QVariantMap &properties, GMenuModel *menuModel, int item, const char *attribute) {
247− GVariant *v = g_menu_model_get_item_attribute_value(menuModel, item, attribute, nullptr);
248−
249− if (v == nullptr)
250− return;
251−
252− properties.insert(attribute, DeeListModel::VariantForData(v));
253− g_variant_unref(v);
254−}
255−
256−void HudClient::modelReallyReady(bool needDisconnect)
257−{
258− GMenuModel *menuModel = hud_client_param_get_model (m_currentActionParam);
259− if (needDisconnect) {
260− g_signal_handlers_disconnect_by_func(menuModel, TO_GPOINTER(modelReallyReadyCB), this);
261− }
262−
263− QVariantList items;
264− for (int i = 0; i < g_menu_model_get_n_items(menuModel); i++) {
265− GVariant *v = g_menu_model_get_item_attribute_value(menuModel, i, "parameter-type", G_VARIANT_TYPE_STRING);
266−
267− if (v == nullptr)
268− continue;
269−
270− const QString type = QString::fromUtf8(g_variant_get_string(v, nullptr));
271− if (type == "slider") {
272− const char *sliderAttributes[] = { "label", "min", "max", "step", "value", "live", "action" };
273− QVariantMap properties;
274− properties.insert("parameter-type", "slider");
275− for (uint j = 0; j < sizeof(sliderAttributes)/sizeof(sliderAttributes[0]); ++j) {
276− addAttribute(properties, menuModel, i, sliderAttributes[j]);
277− }
278− items << properties;
279− }
280− g_variant_unref(v);
281− }
282−
283− DeeModel *model = hud_client_query_get_results_model(m_clientQuery);
284− DeeModelIter *iter = dee_model_get_iter_at_row(model, m_currentActionIndex);
285− GVariant *actionTextVariant = dee_model_get_value(model, iter, 1);
286− const QString actionText = QString::fromUtf8(g_variant_get_string(actionTextVariant, nullptr));
287− g_variant_unref(actionTextVariant);
288− Q_EMIT showParametrizedAction(actionText, QVariant::fromValue(items));
289−}
290−
291−void HudClient::queryModelsChanged()
292−{
293− m_results->setModel(hud_client_query_get_results_model(m_clientQuery));
294−}
plugins/HudClient/hudclient.hdeleted−71
@@ -1,71 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#ifndef HUDCLIENT_H
18−#define HUDCLIENT_H
19−
20−#include <QObject>
21−
22−#include <hud-client.h>
23−
24−class DeeListModel;
25−class QAbstractItemModel;
26−
27−class HudClient : public QObject
28−{
29− Q_OBJECT
30− Q_PROPERTY(DeeListModel* results READ results)
31− Q_PROPERTY(QAbstractItemModel* toolBarModel READ toolBarModel)
32−
33−public:
34− HudClient();
35− ~HudClient();
36−
37− DeeListModel *results() const;
38−
39− QAbstractItemModel *toolBarModel() const;
40−
41− Q_INVOKABLE void executeCommand(int index);
42− Q_INVOKABLE void setQuery(const QString &new_query);
43− Q_INVOKABLE void startVoiceQuery();
44− Q_INVOKABLE void executeParametrizedAction(const QVariant &values);
45− Q_INVOKABLE void updateParametrizedAction(const QVariant &values);
46− Q_INVOKABLE void cancelParametrizedAction();
47− Q_INVOKABLE void executeToolBarAction(HudClientQueryToolbarItems action);
48−
49− void modelReady(bool needDisconnect);
50− void modelReallyReady(bool needDisconnect);
51− void queryModelsChanged();
52−
53−Q_SIGNALS:
54− void voiceQueryLoading();
55− void voiceQueryListening();
56− void voiceQueryHeardSomething();
57− void voiceQueryFailed();
58− void voiceQueryFinished(const QString &query);
59− void commandExecuted();
60− void showParametrizedAction(const QString &action, const QVariant &items);
61−
62−private:
63− HudClientQuery *m_clientQuery;
64− DeeListModel *m_results;
65− QAbstractItemModel *m_toolBarModel;
66− int m_currentActionIndex;
67− HudClientParam *m_currentActionParam;
68−};
69−Q_DECLARE_METATYPE(HudClientQueryToolbarItems)
70−
71−#endif
plugins/HudClient/hudtoolbarmodel.cppdeleted−98
@@ -1,98 +0,0 @@
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− */
16−
17−#include "hudtoolbarmodel.h"
18−
19−#include "hudclient.h"
20−
21−static const int ActionRole = Qt::UserRole;
22−static const int EnabledRole = Qt::UserRole + 1;
23−
24−static QString iconForAction(int action)
25−{
26− switch (action) {
27− case HUD_CLIENT_QUERY_TOOLBAR_UNDO:
28− return "graphics/undo.png";
29− case HUD_CLIENT_QUERY_TOOLBAR_HELP:
30− return "graphics/help.png";
31− case HUD_CLIENT_QUERY_TOOLBAR_FULLSCREEN:
32− return "graphics/view-fullscreen.png";
33− case HUD_CLIENT_QUERY_TOOLBAR_PREFERENCES:
34− return "graphics/settings.png";
35− }
36− return QString();
37−}
38−
39−HudToolBarModel::HudToolBarModel(HudClientQuery *query)
40− : m_query(query)
41−{
42− m_actions << HUD_CLIENT_QUERY_TOOLBAR_UNDO
43− << HUD_CLIENT_QUERY_TOOLBAR_HELP
44− << HUD_CLIENT_QUERY_TOOLBAR_FULLSCREEN
45− << HUD_CLIENT_QUERY_TOOLBAR_PREFERENCES;
46−}
47−
48−HudToolBarModel::~HudToolBarModel()
49−{
50−}
51−
52−int HudToolBarModel::rowCount(const QModelIndex &parent) const
53−{
54− if (parent.isValid())
55− return 0;
56−
57− return m_actions.count();
58−}
59−
60−QVariant HudToolBarModel::data(const QModelIndex &index, int role) const
61−{
62− const int row = index.row();
63− if (row >= m_actions.count())
64− return QVariant();
65−
66− const HudClientQueryToolbarItems action = m_actions[row];
67−
68− switch (role) {
69− case Qt::DecorationRole:
70− return iconForAction(action);
71− break;
72−
73− case ActionRole:
74− return action;
75− break;
76−
77− case EnabledRole:
78− return hud_client_query_toolbar_item_active(m_query, action);
79− break;
80− }
81− return QVariant();
82−}
83−
84−QHash<int,QByteArray> HudToolBarModel::roleNames() const
85−{
86− static QHash<int,QByteArray> roles;
87− if (roles.isEmpty()) {
88− roles[Qt::DecorationRole] = "iconPath";
89− roles[ActionRole] = "action";
90− roles[EnabledRole] = "enabled";
91− }
92− return roles;
93−}
94−
95−void HudToolBarModel::updatedByBackend()
96−{
97− Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << EnabledRole);
98−}
plugins/HudClient/hudtoolbarmodel.hdeleted−44
@@ -1,44 +0,0 @@
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− */
16−
17−#ifndef HUDTOOLBARMODEL_H
18−#define HUDTOOLBARMODEL_H
19−
20−#include <QAbstractListModel>
21−
22−#include <hud-client.h>
23−
24−class HudToolBarModel : public QAbstractListModel
25−{
26− Q_OBJECT
27−
28−public:
29− HudToolBarModel(HudClientQuery *query);
30− ~HudToolBarModel();
31−
32− int rowCount(const QModelIndex &parent = QModelIndex()) const;
33− QVariant data(const QModelIndex &parent, int role) const;
34− QHash<int,QByteArray> roleNames() const;
35−
36− void updatedByBackend();
37−
38−private:
39− QList<HudClientQueryToolbarItems> m_actions;
40−
41− HudClientQuery *m_query;
42−};
43−
44−#endif
plugins/HudClient/plugin.cppdeleted−36
@@ -1,36 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include "plugin.h"
18−
19−#include "hudclient.h"
20−#include "volumepeakdetector.h"
21−
22−#include <deelistmodel.h>
23−
24−#include <qqml.h>
25−
26−void HudQmlPlugin::registerTypes(const char *uri)
27−{
28−#ifndef GLIB_VERSION_2_36
29− g_type_init();
30−#endif
31−
32− qmlRegisterType<DeeListModel>();
33−
34− qmlRegisterType<HudClient>(uri, 0, 1, "HudClient");
35− qmlRegisterType<VolumePeakDetector>(uri, 0, 1, "VolumePeakDetector");
36−}
plugins/HudClient/plugin.hdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#ifndef PLUGIN_H
18−#define PLUGIN_H
19−
20−#include <QQmlExtensionPlugin>
21−
22−class HudQmlPlugin : public QQmlExtensionPlugin
23−{
24− Q_OBJECT
25− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26−public:
27− void registerTypes(const char *uri);
28−};
29−
30−
31−#endif // PLUGIN_H
plugins/HudClient/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module HudClient
2−plugin HudClientQml
3−typeinfo HudClient.qmltypes
plugins/HudClient/volumepeakdetector.cppdeleted−223
@@ -1,223 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include "volumepeakdetector.h"
18−
19−static void stream_read_callback(pa_stream * /*s*/, size_t /*length*/, void *userdata) {
20− PulseAudioVolumePeakDetector *peakDetector = static_cast<PulseAudioVolumePeakDetector *>(userdata);
21− peakDetector->processData();
22−}
23−
24−static void context_state_callback(pa_context *c, void *userdata) {
25− PulseAudioVolumePeakDetector *peakDetector = static_cast<PulseAudioVolumePeakDetector *>(userdata);
26−
27− switch (pa_context_get_state(c)) {
28− case PA_CONTEXT_CONNECTING:
29− case PA_CONTEXT_AUTHORIZING:
30− case PA_CONTEXT_SETTING_NAME:
31− break;
32−
33− case PA_CONTEXT_READY:
34− peakDetector->startStream();
35− break;
36−
37− case PA_CONTEXT_TERMINATED:
38− case PA_CONTEXT_FAILED:
39− default:
40− peakDetector->quit();
41− }
42−}
43−
44−PulseAudioVolumePeakDetector::PulseAudioVolumePeakDetector()
45− : m_accumulatedValue(0)
46− , m_nAccumulatedValues(0)
47− , m_accumulatedValuesLimit(1)
48− , m_context(nullptr)
49− , m_mainloop_api(nullptr)
50− , m_stream(nullptr)
51−{
52−}
53−
54−void PulseAudioVolumePeakDetector::start()
55−{
56− pa_mainloop *mainloop = nullptr;
57−
58− /* Set up a new main loop */
59− mainloop = pa_mainloop_new();
60− if (!mainloop)
61− return;
62−
63− m_mainloop_api = pa_mainloop_get_api(mainloop);
64−
65− /* Create a new connection context */
66− m_context = pa_context_new(m_mainloop_api, nullptr);
67− if (!m_context) {
68− goto quit;
69− }
70−
71− pa_context_set_state_callback(m_context, context_state_callback, this);
72−
73− /* Connect the context */
74− if (pa_context_connect(m_context, nullptr, PA_CONTEXT_NOFLAGS, nullptr) < 0) {
75− goto quit;
76− }
77−
78− /* Run the main loop */
79− if (pa_mainloop_run(mainloop, nullptr) < 0) {
80− goto quit;
81− }
82−
83−quit:
84− if (m_stream)
85− pa_stream_unref(m_stream);
86−
87− if (m_context)
88− pa_context_unref(m_context);
89−
90− if (mainloop) {
91− pa_signal_done();
92− pa_mainloop_free(mainloop);
93− }
94−
95− QThread::currentThread()->quit();
96−}
97−
98−int PulseAudioVolumePeakDetector::nAccumulatedValuesLimit() const
99−{
100− return m_accumulatedValuesLimit;
101−}
102−
103−void PulseAudioVolumePeakDetector::setNAccumulatedValuesLimit(int limit)
104−{
105− m_accumulatedValuesLimit = limit;
106−}
107−
108−// FIXME 16000 is hardcoded because julius needs it
109−// and the hardware/driver/pulse something gets confused
110−// if we use different rates
111−// We would be happier with a much smaller value like 100
112−static uint voice_needed_rate = 16000;
113−
114−void PulseAudioVolumePeakDetector::startStream()
115−{
116− pa_buffer_attr buffer_attr;
117− pa_proplist *proplist = pa_proplist_new();
118−
119− // FIXME 16000 is hardcoded because julius needs it
120− // and the hardware/driver/pulse something gets confused
121− // if we use different rates
122− // We would be happier with a much smaller value like 100
123− pa_sample_spec sample_spec;
124− sample_spec.format = PA_SAMPLE_FLOAT32;
125− sample_spec.rate = 16000;
126− sample_spec.channels = 1;
127−
128− pa_channel_map channel_map;
129−
130− pa_channel_map_init_extend(&channel_map, sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
131− pa_proplist_sets(proplist, PA_PROP_MEDIA_NAME, "HUD Peak Detector");
132−
133− m_stream = pa_stream_new_with_proplist(m_context, nullptr, &sample_spec, &channel_map, proplist);
134− if (!m_stream) {
135− pa_proplist_free(proplist);
136− quit();
137− return;
138− }
139− pa_proplist_free(proplist);
140−
141− pa_stream_set_read_callback(m_stream, stream_read_callback, this);
142−
143− memset(&buffer_attr, 0, sizeof(buffer_attr));
144− buffer_attr.maxlength = (uint32_t) -1;
145− buffer_attr.fragsize = sizeof(float);
146−
147− if (pa_stream_connect_record(m_stream, nullptr, &buffer_attr, (pa_stream_flags_t)(PA_STREAM_PEAK_DETECT | PA_STREAM_ADJUST_LATENCY)) < 0) {
148− quit();
149− }
150−}
151−
152−void PulseAudioVolumePeakDetector::processData()
153−{
154− while (pa_stream_readable_size(m_stream) > 0) {
155− const void *data;
156− size_t length;
157−
158− if (pa_stream_peek(m_stream, &data, &length) < 0) {
159− quit();
160− return;
161− }
162−
163− const float *values = (float*)data;
164− for (size_t i = 0; i < length / sizeof(float); ++i) {
165− float value = values[i];
166− if (value < 0) value = 0;
167− if (value > 1) value = 1;
168− m_nAccumulatedValues++;
169− m_accumulatedValue += value;
170− if (m_nAccumulatedValues == m_accumulatedValuesLimit) {
171− Q_EMIT newPeak(m_accumulatedValue / m_nAccumulatedValues);
172− m_nAccumulatedValues = 0;
173− m_accumulatedValue = 0;
174− }
175− }
176−
177− pa_stream_drop(m_stream);
178− }
179−}
180−
181−void PulseAudioVolumePeakDetector::quit()
182−{
183− m_mainloop_api->quit(m_mainloop_api, 0);
184−}
185−
186−
187−/* VolumePeakDetector */
188−
189−VolumePeakDetector::VolumePeakDetector()
190−{
191− QObject::connect(&m_thread, SIGNAL(started()), &m_volumeDetector, SLOT(start()));
192− QObject::connect(&m_volumeDetector, SIGNAL(newPeak(float)), this, SIGNAL(newPeak(float)));
193−
194− m_volumeDetector.moveToThread(&m_thread);
195−}
196−
197−bool VolumePeakDetector::enabled() const
198−{
199− return m_thread.isRunning();
200−}
201−
202−int VolumePeakDetector::desiredInterval() const
203−{
204− return m_volumeDetector.nAccumulatedValuesLimit() * 1000 / voice_needed_rate;
205−}
206−
207−void VolumePeakDetector::setDesiredInterval(int interval)
208−{
209− m_volumeDetector.setNAccumulatedValuesLimit(voice_needed_rate * interval / 1000);
210−}
211−
212−void VolumePeakDetector::setEnabled(int enabled)
213−{
214− if (enabled) {
215− if (!m_thread.isRunning()) {
216− m_thread.start();
217− }
218− } else {
219− if (m_thread.isRunning()) {
220− m_volumeDetector.quit();
221− }
222− }
223−}
plugins/HudClient/volumepeakdetector.hdeleted−78
@@ -1,78 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#ifndef VOLUMEPEAKDETECTOR_H
18−#define VOLUMEPEAKDETECTOR_H
19−
20−#include <QObject>
21−
22−#include <QThread>
23−
24−#include <pulse/pulseaudio.h>
25−
26−class PulseAudioVolumePeakDetector : public QObject
27−{
28− Q_OBJECT
29−
30−public:
31− PulseAudioVolumePeakDetector();
32−
33− int nAccumulatedValuesLimit() const;
34− void setNAccumulatedValuesLimit(int limit);
35−
36− void startStream();
37− void processData();
38− void quit();
39−
40−public Q_SLOTS:
41− void start();
42−
43−Q_SIGNALS:
44− void newPeak(float value);
45−
46−private:
47− float m_accumulatedValue;
48− int m_nAccumulatedValues;
49− int m_accumulatedValuesLimit;
50− pa_context *m_context;
51− pa_mainloop_api *m_mainloop_api;
52− pa_stream *m_stream;
53−};
54−
55−class VolumePeakDetector : public QObject
56−{
57− Q_OBJECT
58− Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
59− Q_PROPERTY(int desiredInterval READ desiredInterval WRITE setDesiredInterval)
60−
61−public:
62− VolumePeakDetector();
63−
64− bool enabled() const;
65− void setEnabled(int enabled);
66−
67− int desiredInterval() const;
68− void setDesiredInterval(int interval);
69−
70−Q_SIGNALS:
71− void newPeak(float volume);
72−
73−private:
74− QThread m_thread;
75− PulseAudioVolumePeakDetector m_volumeDetector;
76−};
77−
78−#endif
qml/CMakeLists.txt−1
@@ -9,7 +9,6 @@ set(QML_DIRS
99 Dash
1010 graphics
1111 Greeter
12− Hud
1312 Panel
1413 Launcher
1514 Stages
qml/Hud/Hud.qmldeleted−497
@@ -1,497 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import HudClient 0.1
20−
21−import "../Components"
22−import "../Components/Flickables" as Flickables
23−
24−Item {
25− id: hud
26−
27− readonly property real elementsPadding: units.gu(1)
28− readonly property real elementsYSliding: units.gu(2)
29−
30− property alias revealerTarget: hudShowable
31− property alias showAnimation: hudShowable.showAnimation
32− property alias hideAnimation: hudShowable.hideAnimation
33− property alias available: hudShowable.available
34− property alias shown: hudShowable.shown
35− property alias handleHeight: handle.height
36−
37− readonly property variant outEasing: Easing.OutQuad
38− readonly property variant inEasing: Easing.InQuad
39− readonly property int animationDuration: 200
40− readonly property int showableAnimationDuration: 100
41− property bool showingOpenIndicator: false
42−
43− // FIXME At the moment since we have no appstack
44− // it's not possible to get results of the sidestage app
45− // design has to come up with a solution
46− function show() {
47− hudShowable.show()
48− }
49− function hide() {
50− hudShowable.hide()
51− }
52− function resetToInitialState() {
53− hud.state = "initial"
54− searchBar.unfocus()
55− searchBar.text = ""
56− parametrizedActionsPage.shown = false
57− }
58−
59− states: [
60− State {
61− name: "initial"
62− PropertyChanges { target: searchBar; placeholderText: i18n.tr("Type or say a command") }
63− PropertyChanges { target: searchBar; searchEnabled: true }
64− PropertyChanges { target: toolBarAnimator; visible: true}
65− AnchorChanges { target: searchBarAnimator; anchors.top: undefined; anchors.bottom: parent.bottom; }
66− AnchorChanges { target: resultsCardAnimator; anchors.top: undefined; anchors.bottom: toolBarAnimator.top; }
67− },
68− State {
69− name: "input" //only inherited by other states.
70− AnchorChanges { target: searchBarAnimator; anchors.top: parent.top; anchors.bottom: undefined; }
71− AnchorChanges { target: resultsCardAnimator; anchors.top: searchBarAnimator.bottom; anchors.bottom: undefined; }
72− PropertyChanges { target: toolBarAnimator; visible: false }
73− },
74− State {
75− name: "voice_input" //only inherited by other states.
76− extend: "input"
77− PropertyChanges { target: soundAmplitudeVisualAnimator; visible: true }
78− PropertyChanges { target: resultsCardAnimator; visible: false }
79− PropertyChanges { target: soundAmplitudeVisualAnimator; progress: 1 }
80− PropertyChanges { target: searchBar; searchEnabled: false }
81− },
82− State {
83− name: "voice_recognition_loading"
84− extend: "voice_input"
85− PropertyChanges { target: searchBar; placeholderText: i18n.tr("Loading. Please Wait...") }
86− },
87− State {
88− name: "voice_recognition_listening"
89− extend: "voice_input"
90− PropertyChanges { target: searchBar; placeholderText: i18n.tr("Speak Now...") }
91− },
92− State {
93− name: "voice_recognition_processing"
94− extend: "voice_input"
95− PropertyChanges { target: searchBar; placeholderText: i18n.tr("Speaking...") }
96− },
97− State {
98− name: "showing_results"
99− extend: "input"
100− PropertyChanges { target: searchBar; placeholderText: i18n.tr("Type or say a command") }
101− PropertyChanges { target: searchBar; searchEnabled: true }
102− }
103− ]
104−
105− transitions: [
106− Transition {
107− from: "initial"
108− to: "voice_recognition_loading"
109− SequentialAnimation {
110− NumberAnimation { // hide these components
111− targets: [toolBarAnimator, searchBarAnimator, resultsCardAnimator]
112− property: "progress"; duration: animationDuration; to: 0
113− }
114−
115− PropertyAction { targets: [toolBarAnimator, resultsCardAnimator]; property: "visible"; value: false}
116− PropertyAction { target: soundAmplitudeVisualAnimator; property: "visible"; value: true}
117−
118− AnchorAnimation { duration: 0 } // so anchor change happens at this point
119−
120− NumberAnimation { // show these components
121− targets: [searchBarAnimator, soundAmplitudeVisualAnimator]
122− property: "progress"; duration: animationDuration; from: 0; to: 1
123− }
124− }
125− },
126− Transition {
127− from: "showing_results"
128− to: "voice_recognition_loading"
129− SequentialAnimation {
130− PropertyAction { target: soundAmplitudeVisualAnimator; property: "progress"; value: 0}
131−
132− PropertyAction { // hide these components
133− target: resultsCardAnimator; property: "progress"; value: 0
134− }
135−
136− NumberAnimation { // show these components
137− target: soundAmplitudeVisualAnimator; property: "progress"; duration: animationDuration; from: 0; to: 1
138− }
139− }
140− },
141− Transition {
142− from: "voice_recognition_processing"
143− to: "showing_results"
144− SequentialAnimation {
145− NumberAnimation { // hide these components
146− target: soundAmplitudeVisualAnimator; property: "progress"; duration: animationDuration; to: 0
147− }
148− PropertyAction { target: resultsCardAnimator; property: "visible"; value: true}
149−
150− NumberAnimation { // show these components
151− target: resultsCardAnimator; property: "progress"; duration: animationDuration; from: 0; to: 1
152− }
153− }
154− },
155− Transition {
156− from: "initial"
157− to: "showing_results"
158− SequentialAnimation {
159− NumberAnimation {
160− targets: [toolBarAnimator, searchBarAnimator, resultsCardAnimator]
161− property: "progress"; duration: animationDuration; to: 0
162− }
163−
164− PropertyAction { target: toolBarAnimator; property: "visible"; value: false}
165−
166− AnchorAnimation { duration: 0 } // so anchor change happens at this point
167−
168− NumberAnimation {
169− targets: [searchBarAnimator, resultsCardAnimator]
170− property: "progress"; duration: animationDuration; from: 0; to: 1
171− }
172− }
173− }
174− ]
175−
176− state: "initial"
177−
178− HudClient {
179− id: hudClient
180−
181− onCommandExecuted: {
182− hudShowable.hide()
183− }
184−
185− onShowParametrizedAction: {
186− parametrizedActionsPage.header = action
187− parametrizedActionsPage.setItems(items)
188− parametrizedActionsPage.shown = true
189− }
190−
191− onVoiceQueryLoading: {
192− hud.state = "voice_recognition_loading"
193− searchBar.ignoreNextTextChange = true
194− searchBar.text = ""
195− searchBar.unfocus()
196− soundAmplitudeVisual.startIdle()
197− }
198− onVoiceQueryListening: {
199− if (hud.state == "voice_recognition_loading" || hud.state == "showing_results") {
200− searchBar.ignoreNextTextChange = true
201− searchBar.text = ""
202− searchBar.unfocus()
203− hud.state = "voice_recognition_listening"
204− }
205− }
206− onVoiceQueryHeardSomething: {
207− if (hud.state == "voice_recognition_listening") {
208− hud.state = "voice_recognition_processing"
209− soundAmplitudeVisual.setDetectorEnabled(true)
210− }
211− }
212− onVoiceQueryFinished: {
213− hud.state = "showing_results"
214− searchBar.text = query
215− soundAmplitudeVisual.setDetectorEnabled(false)
216− }
217− onVoiceQueryFailed: {
218− hud.state = "showing_results"
219− searchBar.text = ""
220− soundAmplitudeVisual.setDetectorEnabled(false)
221− }
222− }
223−
224− Showable {
225− id: hudShowable
226− objectName: "hudShowable"
227− height: parent.height
228− width: parent.width
229−
230− onYChanged: {
231− if (greeter.shown) {
232− showAnimation.duration = 0
233− hideAnimation.duration = 0
234− } else if (!showAnimation.running && !hideAnimation.running) {
235− if (parent.height > 0) {
236− showAnimation.duration = Math.min(showableAnimationDuration * (1 - (parent.height - y) / parent.height), showableAnimationDuration)
237− hideAnimation.duration = showableAnimationDuration - showAnimation.duration
238− }
239− }
240− }
241−
242− MouseArea {
243− // Eat everything that doesn't go to other places
244− anchors.fill: parent
245− }
246−
247− Image {
248− anchors.fill: parent
249− fillMode: Image.Tile
250− source: "graphics/hud_bg.png"
251− }
252−
253− Connections {
254− target: hideAnimation
255− onRunningChanged: {
256− if (!hideAnimation.running) {
257− showAnimation.duration = showableAnimationDuration
258− hud.resetToInitialState()
259− }
260− }
261− }
262−
263− Connections {
264− target: showAnimation
265− onRunningChanged: {
266− if (!showAnimation.running) {
267− hideAnimation.duration = showableAnimationDuration
268− }
269− }
270− }
271− }
272−
273− Item {
274− id: handle
275− objectName: "handle"
276−
277− y: hudShowable.y
278− anchors {
279− left: parent.left
280− right: parent.right
281− }
282− height: handleImage.height
283−
284− Image {
285− id: handleImage
286− anchors {
287− left: parent.left
288− right: parent.right
289− }
290− source: "graphics/hud_handlebar.png"
291− }
292−
293− Image {
294− id: handleArrow
295− y: units.gu(1)
296− anchors.horizontalCenter: parent.horizontalCenter
297− source: "graphics/hud_handlearrow.png"
298− cache: false
299− }
300− }
301−
302− Item {
303− id: hudContentClipper
304−
305− anchors {
306− left: parent.left
307− right: parent.right
308− bottom: parent.bottom
309− top: handle.bottom
310− }
311− clip: visible && hudContent.height !== height
312− visible: hudContent.height >= 0
313−
314− Item {
315− id: hudContent
316− anchors {
317− left: parent.left
318− right: parent.right
319− bottom: parent.bottom
320− }
321− height: hud.height
322−
323− Item {
324− id: mainPage
325− x: parametrizedActionsPage.x - width
326− height: hud.height
327− width: hud.width
328−
329− ShowingAnimation {
330− id: toolBarAnimator
331− objectName: "toolBarAnimator"
332− anchors {
333− left: parent.left
334− right: parent.right
335− bottom: searchBarAnimator.top
336− margins: 2*elementsPadding //ensures positioning correct
337− }
338− progress: MathUtils.clamp((y - hudShowable.y - anchors.margins)/elementsYSliding, 0, 1)
339−
340− ToolBar {
341− id: toolBar
342− objectName: "toolBar"
343− model: hudClient.toolBarModel
344− anchors.horizontalCenter: parent.horizontalCenter
345− onActionTriggered: {
346− hudClient.executeToolBarAction(action)
347− }
348− }
349− }
350−
351− ShowingAnimation {
352− id: searchBarAnimator
353− objectName: "searchBarAnimator"
354− anchors {
355− left: parent.left
356− right: parent.right
357− bottom: parent.bottom
358− margins: elementsPadding
359− topMargin: handle.height + units.dp(1) + elementsPadding
360− }
361− progress: MathUtils.clamp((y - hudShowable.y - anchors.margins)/elementsYSliding, 0, 1)
362−
363− SearchBar {
364− id: searchBar
365− objectName: "searchBar"
366−
367− property bool ignoreNextTextChange: false
368−
369− anchors.left: parent.left
370− anchors.right: parent.right
371− height: units.gu(5)
372−
373− placeholderText: i18n.tr("Type or say a command")
374− activityIndicatorVisible: hud.state == "voice_recognition_processing"
375−
376− onMicrophoneClicked: hudClient.startVoiceQuery()
377−
378− onTextChanged: {
379− if (ignoreNextTextChange) {
380− ignoreNextTextChange = false
381− } else {
382− hudClient.setQuery(searchBar.text)
383− }
384− }
385−
386− onTextFocused: {
387− hud.state = "showing_results"
388− }
389− }
390− }
391−
392− ShowingAnimation {
393− id: resultsCardAnimator
394− objectName: "resultsCardAnimator"
395−
396− anchors {
397− left: parent.left
398− right: parent.right
399− top: searchBarAnimator.bottom
400− margins: elementsPadding
401− }
402− progress: MathUtils.clamp((y - hudShowable.y + height - units.gu(8))/elementsYSliding, 0, 1)
403−
404− Flickables.Flickable {
405− anchors.left: parent.left
406− anchors.right: parent.right
407− contentHeight: resultList.height
408− contentWidth: width
409− clip: height < contentHeight
410− interactive: height < contentHeight
411−
412− height: {
413− if (hud.state == "showing_results") {
414− return shell.applicationManager.keyboardVisible ? Math.min(hud.height - searchBarAnimator.y - searchBarAnimator.height - units.gu(2) - shell.applicationManager.keyboardHeight, contentHeight) : contentHeight
415− } else {
416− return contentHeight
417− }
418− }
419−
420−
421− ResultList {
422− id: resultList
423−
424− anchors.left: parent.left
425− anchors.right: parent.right
426− height: childrenRect.height
427−
428− onActivated: {
429− hudClient.executeCommand(index)
430− }
431−
432− model: hudClient.results
433− }
434− }
435− }
436−
437− ShowingAnimation {
438− id: soundAmplitudeVisualAnimator
439−
440− anchors {
441− horizontalCenter: parent.horizontalCenter
442− verticalCenter: parent.verticalCenter
443− verticalCenterOffset: (searchBar.height + 2*elementsPadding)/2
444− }
445− visible: false
446− width: units.gu(33)
447− progress: MathUtils.clamp((y - hudShowable.y - anchors.verticalCenterOffset)/elementsYSliding, 0, 1)
448−
449− SoundAmplitudeVisual {
450− id: soundAmplitudeVisual
451− width: units.gu(33)
452− height: width
453− }
454− }
455− }
456−
457− HudParametrizedActionsPage {
458− id: parametrizedActionsPage
459− objectName: "parametrizedActionsPage"
460− property bool shown: false
461−
462− anchors.bottom: parent.bottom
463− height: hud.height - handle.height - units.dp(1)
464− width: parent.width
465− x: shown ? 0 : width
466− onConfirmPressed: {
467− hudClient.executeParametrizedAction(values())
468− }
469− onValuesUpdated: {
470− hudClient.updateParametrizedAction(values())
471− }
472− onBackPressed: {
473− shown = false
474− }
475− onShownChanged: {
476− if (!shown) {
477− hudClient.cancelParametrizedAction()
478− }
479− }
480− Behavior on x {
481− NumberAnimation {
482− easing.type: outEasing
483− duration: animationDuration
484− }
485− }
486− }
487− }
488− }
489−
490− Image {
491− anchors.left: hudContentClipper.right
492− anchors.top: hudContentClipper.top
493− anchors.bottom: hudContentClipper.bottom
494− fillMode: Image.Tile
495− source: "../graphics/dropshadow_right.png"
496− }
497−}
qml/Hud/HudParametrizedActionsPage.qmldeleted−180
@@ -1,180 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 1.1
19−import Ubuntu.Components.Themes.Ambiance 1.1
20−import "../Components"
21−import "../Components/Flickables" as Flickables
22−
23−Item {
24− property alias header: header.title
25− signal backPressed
26− signal confirmPressed
27− signal valuesUpdated
28− id: root
29−
30− ListModel {
31− id: actionItems
32− }
33−
34− function setItems(items) {
35− while (actionItems.count > 0) {
36− var item = actionItems.get(0).item
37− actionItems.remove(0)
38− item.visible = false
39− item.destroy()
40− }
41−
42− var sliderCreator = Qt.createComponent("SliderLabel.qml");
43− var first = true
44− var topAnchor = header.bottom
45− for (var i = 0; i < items.length; i++) {
46− var item = items[i]
47− if (item["parameter-type"] == "slider")
48− {
49− var slider = sliderCreator.createObject(flickableColumn);
50− slider.anchors.left = flickableColumn.left
51− slider.anchors.right = flickableColumn.right
52− slider.anchors.topMargin = first ? units.gu(1) : units.gu(2)
53− slider.anchors.top = topAnchor
54− slider.tooltip = tooltip
55− slider.sliderData = item
56− topAnchor = slider.bottom
57− actionItems.append({"item": slider})
58− slider.onValueChanged.connect(valueChanged)
59− }
60− first = false
61− }
62− }
63−
64− function valueChanged()
65− {
66− valuesUpdated()
67− }
68−
69− function values() {
70− var values = {}
71− for (var i = 0; i < actionItems.count; ++i) {
72− var item = actionItems.get(i).item
73− values[item.action] = item.value
74− }
75− return values
76− }
77−
78− Flickables.Flickable {
79− anchors.top: parent.top
80− anchors.bottom: buttons.top
81− anchors.left: parent.left
82− anchors.right: parent.right
83− clip: true
84−
85− flickableDirection: Flickable.VerticalFlick
86− interactive: !tooltip.visible
87−
88− Item {
89− id: flickableColumn
90− anchors.top: parent.top
91− anchors.left: parent.left
92− anchors.right: parent.right
93−
94− PageHeadStyle {
95− id: header
96− anchors.top: parent.top
97− anchors.left: parent.left
98− anchors.right: parent.right
99− anchors.topMargin: units.gu(1)
100− height: units.gu(6.5)
101− contentHeight: height
102− separatorSource: ""
103− property var styledItem: header
104− property string title
105− property var config: PageHeadConfiguration { }
106− }
107− }
108− }
109− Item {
110− id: buttons
111− anchors.bottom: parent.bottom
112− anchors.left: parent.left
113− anchors.right: parent.right
114− anchors.margins: units.gu(1)
115− height: confirmButton.height
116−
117− Button {
118− id: backButton
119− anchors.left: parent.left
120− anchors.top: parent.top
121− anchors.bottom: parent.bottom
122− width: units.gu(7)
123− color: "black"
124− opacity: 0.25
125− MouseArea {
126− anchors.fill: parent
127− onClicked: backPressed()
128− }
129− }
130− Image {
131− anchors.centerIn: backButton
132− source: "graphics/icon_arrow.png"
133− }
134−
135− Button {
136− id: confirmButton
137− anchors.right: parent.right
138− width: units.gu(13)
139− height: units.gu(5)
140− text: i18n.tr("Confirm")
141− color: "#F05D22"
142− onClicked: confirmPressed()
143− }
144− }
145−
146− Item {
147− id: tooltip
148− property variant target: undefined
149− visible: target != undefined
150− y: visible ? root.mapFromItem(target.parent, 0, target.y).y - height : 0
151− x: visible ? target.anchors.leftMargin + target.__internals.thumb.x + target.__internals.thumb.width / 2 - width / 2 : 0
152−
153− width: childrenRect.width
154− height: childrenRect.height
155−
156− Rectangle {
157− id: tooltipRectangle
158− width: units.gu(8)
159− height: units.gu(6)
160− color: "white"
161− radius: units.gu(0.5)
162−
163− Label {
164− anchors.fill: parent
165− text: tooltip.target ? tooltip.target.realFormatValue(tooltip.target.value) : ""
166− horizontalAlignment: Text.AlignHCenter
167− verticalAlignment: Text.AlignVCenter
168− fontSize: "large"
169− }
170− }
171− Image {
172− id: tooltipTip
173− source: "graphics/popup_triangle.png"
174−
175− anchors.top: tooltipRectangle.bottom
176− anchors.horizontalCenter: parent.horizontalCenter
177− }
178−
179− }
180−}
qml/Hud/Result.qmldeleted−84
@@ -1,84 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−Item {
21− property string contextSnippetText
22− property variant contextSnippetHighlights
23− property string nameText
24− property variant nameHighlights
25−
26− function highlightedText(text, highlights) {
27− var hText = "";
28− var nextIndexToProcess = 0;
29− if (highlights && highlights.length % 2 == 0) {
30− for (var i = 0; i < highlights.length - 1; i += 2) {
31− var highlightStart = highlights[i];
32− var highlightEnd = highlights[i + 1];
33− if (highlightEnd < highlightStart)
34− continue;
35− if (highlightStart < nextIndexToProcess)
36− continue;
37− if (highlightStart != nextIndexToProcess) {
38− // Prev non marked text
39− hText += text.substr(nextIndexToProcess, highlightStart - nextIndexToProcess);
40− }
41−
42− // Marked text
43− hText += "<font color=\"#ffffff\">" + text.substr(highlightStart, highlightEnd - highlightStart + 1) + "</font>";
44− nextIndexToProcess = highlightEnd + 1;
45− }
46− }
47− if (nextIndexToProcess != text.length) {
48− // End non marked text
49− hText += text.substr(nextIndexToProcess);
50− }
51− return hText;
52− }
53−
54− Label {
55− id: actionLabel
56− objectName: "actionLabel"
57− anchors.left: parent.left
58− anchors.leftMargin: units.gu(1)
59− anchors.verticalCenter: parent.verticalCenter
60− width: parent.width / 2
61− fontSize: "medium"
62− elide: Text.ElideRight
63− maximumLineCount: 1
64− text: highlightedText(nameText, nameHighlights)
65− color: "#80ffffff"
66− }
67−
68− Label {
69− horizontalAlignment: Text.AlignRight
70− id: contextSnippetLabel
71− objectName: "contextSnippetLabel"
72− width: parent.width / 2 - units.gu(1)
73− visible: text != ""
74− anchors.right: parent.right
75− anchors.rightMargin: units.gu(1)
76− anchors.verticalCenter: parent.verticalCenter
77− fontSize: "small"
78− opacity: 0.5
79− elide: Text.ElideRight
80− maximumLineCount: 2
81− text: highlightedText(contextSnippetText, contextSnippetHighlights)
82− color: "#80ffffff"
83− }
84−}
qml/Hud/ResultList.qmldeleted−106
@@ -1,106 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−Column {
21− property var model: undefined
22−
23− // Hud gives lots of results, make sure we have 5 at most
24− // FIXME This should use SortFilterProxyModel
25− // but there is a problem with the hud-service refreshing the
26− // data for no reason so we use the internal model + timer
27− // to fix those issues
28− ListModel {
29− id: internalModel
30− }
31−
32− Connections {
33− target: model
34− // Accumulate count changes since hud clears
35− // and then readds items to the models which means
36− // even if the result is the same we get lots of count changes
37− onCountChanged: updateModelTimer.restart()
38− }
39−
40− onModelChanged: updateModelTimer.restart()
41−
42− Timer {
43− id: updateModelTimer
44− interval: 30
45− onTriggered: updateModel()
46− }
47−
48− function updateModel() {
49− internalModel.clear()
50− for (var i = 0; i < 5 && i < model.count; ++i) {
51− var itemData = model.get(i)
52− internalModel.append({"name": itemData.column_1, "highlights": itemData.column_2, "context": itemData.column_3, "contextHighlights": itemData.column_4})
53− }
54− }
55−
56− signal activated(int index)
57−
58− height: repeater.height
59−
60− Repeater {
61− id: repeater
62− objectName: "resultListRepeater"
63− model: internalModel
64−
65− delegate: MouseArea {
66− id: delegate
67− height: result.height + separatorLine.height * 2
68− anchors.left: parent.left
69− anchors.right: parent.right
70−
71− onClicked: activated(index)
72−
73− BorderImage {
74− id: separatorLine
75− anchors.top: parent.top
76− anchors.left: parent.left
77− anchors.right: parent.right
78− source: "graphics/divider.sci"
79− visible: index == 0
80− }
81−
82− Result {
83− id: result
84− height: units.gu(6)
85− anchors.top: separatorLine.bottom
86− anchors.left: parent.left
87− anchors.right: parent.right
88−
89− nameText: name
90− nameHighlights: highlights
91− contextSnippetText: context
92− contextSnippetHighlights: contextHighlights
93− }
94−
95− BorderImage {
96− anchors.top: result.bottom
97− anchors.left: parent.left
98− anchors.right: parent.right
99− source: "graphics/divider.sci"
100− }
101−
102− Component.onCompleted: fadeIn.start()
103− NumberAnimation { id: fadeIn; target: resultList; alwaysRunToEnd: true; property: "opacity"; duration: 200; from: 0; to: 1 }
104− }
105− }
106−}
qml/Hud/SearchBar.qmldeleted−100
@@ -1,100 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−Item {
21− id: root
22− property alias activityIndicatorVisible: activityIndicator.visible
23− property alias text: searchBar.text
24− property alias placeholderText: searchBar.placeholderText
25− property alias searchEnabled: searchBar.enabled
26− signal microphoneClicked
27− signal textFocused
28−
29− readonly property real imageSize: units.gu(3)
30−
31− function unfocus()
32− {
33− searchBar.focus = false
34− }
35−
36− ActivityIndicator {
37− id: activityIndicator
38− height: imageSize
39− width: height
40− x: magnifierImage.x
41− y: magnifierImage.y
42− running: visible
43− }
44−
45− TextField {
46− id: searchBar
47− anchors.fill: parent
48−
49− hasClearButton: false
50− font.pixelSize: FontUtils.sizeToPixels("large")
51−
52− onActiveFocusChanged: {
53− if (activeFocus) {
54− root.textFocused()
55− }
56− }
57−
58− Item {
59− id: primary
60− height: searchBar.height
61− width: height
62−
63− Image {
64− id: magnifierImage
65− height: imageSize
66− width: height
67− anchors.centerIn: parent
68− source: "graphics/icon_search.png"
69− visible: !activityIndicator.visible && !clearImage.visible
70− }
71−
72− Image {
73− id: clearImage
74− height: imageSize
75− width: height
76− anchors.centerIn: parent
77− source: "graphics/icon_clear.png"
78− visible: !activityIndicator.visible && searchBar.text != ""
79− MouseArea {
80− anchors.fill: parent
81− onClicked: searchBar.text = ""
82− }
83− }
84− }
85−
86− primaryItem: primary
87− secondaryItem: MouseArea {
88− height: searchBar.height
89− width: height
90− onClicked: microphoneClicked()
91−
92− Image {
93− height: imageSize
94− width: height
95− anchors.centerIn: parent
96− source: "graphics/microphone.png"
97− }
98− }
99− }
100−}
qml/Hud/ShowingAnimation.qmldeleted−54
@@ -1,54 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−import "../Components"
20−
21−Item {
22− id: root
23− property real yOffsetAtAnimationStart: units.gu(2)
24− property real progress: 0
25− property int animationDuration: 200
26− default property alias __itemsToAnimate: container.children
27−
28− property bool showing: progress > 0
29−
30− height: childrenRect.height
31−
32− Item {
33− id: container
34− anchors {
35− left: parent.left
36− right: parent.right
37− }
38− height: childrenRect.height
39− }
40−
41− NumberAnimation {id: opacityAnimation; target: container; property: "opacity"; from: 0; to: 1; duration: animationDuration}
42− NumberAnimation {id: yAnimation; target: container; property: "y"; from: yOffsetAtAnimationStart; to: 0; duration: animationDuration}
43−
44− // FIXME This would much more sense in a ParallelAnimation and just
45− // one AnimationController but that goes something crazy and rendering never stops
46− AnimationController {
47− animation: opacityAnimation
48− progress: root.progress
49− }
50− AnimationController {
51− animation: yAnimation
52− progress: root.progress
53− }
54−}
qml/Hud/SliderLabel.qmldeleted−76
@@ -1,76 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−Item {
21− height: childrenRect.height
22− width: childrenRect.width
23− property variant tooltip
24−
25− property variant sliderData
26− property string action
27− property alias value: slider.value
28− onValueChanged: {
29− // TODO We should not need this but without it
30− // slider.onValueChanged.connect(valueChanged) in
31− // HudParametrizedActionsPage.qml doesn't work
32− // Michael thinks it's related to https://bugreports.qt-project.org/browse/QTBUG-29141
33− }
34−
35− onSliderDataChanged: {
36− label.text = sliderData["label"]
37− slider.minimumValue = sliderData["min"]
38− slider.maximumValue = sliderData["max"]
39− if("live" in sliderData)
40− slider.live = sliderData["live"]
41− // SDK Slider does not support step yet
42−// slider.step = sliderData["step"]
43− if("value" in sliderData)
44− slider.value = sliderData["value"]
45− action = sliderData["action"]
46− }
47−
48− Label {
49− id: label
50− anchors.top: parent.top
51− anchors.left: parent.left
52− anchors.right: parent.right
53− anchors.margins: units.gu(1)
54− anchors.leftMargin: units.gu(2)
55− color: "white"
56− }
57− Slider {
58− id: slider
59− anchors.top: label.bottom
60− anchors.left: parent.left
61− anchors.right: parent.right
62− anchors.margins: units.gu(1)
63− height: units.gu(6)
64− live: true
65− function realFormatValue(v) { return Math.round(v) + " %" }
66− function formatValue(v) { return tooltip.target == slider ? "" : realFormatValue(v) }
67− onPressedChanged: tooltip.target = pressed ? slider : undefined
68− }
69− BorderImage {
70− source: "graphics/divider.sci"
71− anchors.top: slider.bottom
72− anchors.left: parent.left
73− anchors.right: parent.right
74− anchors.topMargin: units.gu(2)
75− }
76−}
qml/Hud/SoundAmplitudeDelegate.qmldeleted−52
@@ -1,52 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−
19−Rectangle {
20− id: delegate
21− property real amplitude: 0
22− property int totalCount
23− property int ballIndex
24− width: {
25− var t = amplitude / 0.6
26− t = -t * (t - 2)
27− return units.gu(0.25) + units.gu(5) * t
28− }
29− visible: amplitude != 0
30− height: width
31− color: "#DD4814"
32− radius: width * 0.5
33− antialiasing: true
34− opacity: {
35− // TODO This formula has hardocded values everywhere :D
36− var t
37− var dampenAfterThisIndex = 7
38− if (ballIndex < dampenAfterThisIndex) {
39− t = (totalCount - ballIndex) / totalCount
40− return Math.pow(t, 4);
41− } else {
42− t = (totalCount - dampenAfterThisIndex) / totalCount
43− t = Math.pow(t, 4);
44− t = t * 0.7;
45− return 0.09 + t * (totalCount - ballIndex) / (totalCount - dampenAfterThisIndex)
46− }
47− }
48−
49− property double orbitRadius: ((parent.width - units.gu(6)) / 2)
50− x: -(width / 2) + (parent.width / 2) + orbitRadius * Math.sin((ballIndex / totalCount) * (2 * Math.PI))
51− y: -(height / 2) + (parent.height / 2) - orbitRadius * Math.cos((ballIndex / totalCount) * (2 * Math.PI))
52−}
qml/Hud/SoundAmplitudeVisual.qmldeleted−146
@@ -1,146 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import HudClient 0.1
19−
20−Item {
21− id: voiceInput
22−
23− readonly property int totalSpots: 30
24− readonly property int totalIdles: 7
25−
26− property real __newPeak: 0
27−
28− VolumePeakDetector {
29− id: peakDetector
30− desiredInterval: peakMover.interval
31− onNewPeak: {
32− __newPeak = volume
33− }
34− }
35−
36− Timer {
37− id: peakMover
38− interval: 10
39− repeat: true
40− onTriggered: {
41− moveBalls()
42− voiceAmplitudes.itemAt(0).amplitude = __newPeak
43− }
44− }
45−
46− Repeater {
47− id: fixedPositionSoundAmplitudes
48− model: totalSpots
49− delegate: SoundAmplitudeDelegate {
50− totalCount: fixedPositionSoundAmplitudes.count
51− ballIndex: index
52− opacity: 1
53− visible: true
54− }
55− }
56−
57− Repeater {
58− id: voiceAmplitudes
59− model: totalSpots
60− delegate: SoundAmplitudeDelegate {
61− totalCount: voiceAmplitudes.count
62− ballIndex: index
63− }
64− }
65−
66− Repeater {
67− id: idleAmplitudes
68− model: totalSpots
69− delegate: SoundAmplitudeDelegate {
70− totalCount: idleAmplitudes.count
71− ballIndex: index
72− amplitude: 0.05
73− visible: idleAmplitudes.enabled
74− }
75− }
76−
77− function setDetectorEnabled(enabled) {
78− idleAmplitudes.enabled = false
79− if (enabled) {
80− peakMover.start()
81− } else {
82− peakDetector.enabled = false
83− peakMover.stop()
84− }
85− }
86−
87− function moveBalls() {
88− var i = 0
89− var amplitude = voiceAmplitudes.itemAt(0).amplitude
90− for (var i = 1; i < totalSpots; ++i) {
91− var item = voiceAmplitudes.itemAt(i)
92− var tempAmplitude = item.amplitude
93− item.amplitude = amplitude
94− amplitude = tempAmplitude
95− }
96− }
97−
98− property int __firstIdle
99− property int __idleCount
100−
101− Timer {
102− id: idleBallsTimer
103− interval: 40
104− onTriggered: moveAndAddIdleBalls()
105− }
106−
107− function moveAndAddIdleBalls() {
108− // Check if we are doing the real thing
109− if (!idleAmplitudes.enabled) {
110− return
111− }
112−
113− for (var i = 0; i < __idleCount; ++i) {
114− var index = __firstIdle - i
115− var item = idleAmplitudes.itemAt(index % totalSpots)
116− var nextItem = idleAmplitudes.itemAt((index + 1) % totalSpots)
117− nextItem.opacity = item.opacity
118− }
119− __firstIdle++
120− idleAmplitudes.itemAt((__firstIdle - __idleCount) % totalSpots).opacity = 0
121−
122− if (__idleCount < totalIdles) {
123− idleAmplitudes.itemAt(0).opacity = 1 - (__idleCount / totalIdles)
124− __idleCount++
125− }
126− idleBallsTimer.start()
127− }
128−
129− function startIdle() {
130− // On the device the peak detector takes quite a lot to start up
131− // so enable it as soon as we know we are going to do voice capture
132− peakDetector.enabled = true
133− for (var i = 0; i < totalSpots; ++i) {
134− idleAmplitudes.itemAt(i).opacity = 0
135− }
136− for (var i = 0; i < totalSpots; ++i) {
137− voiceAmplitudes.itemAt(i).amplitude = 0
138− }
139−
140− idleAmplitudes.enabled = true
141− idleAmplitudes.itemAt(0).opacity = 1
142− __idleCount = 1
143− __firstIdle = 0
144− idleBallsTimer.start()
145− }
146−}
qml/Hud/ToolBar.qmldeleted−33
@@ -1,33 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−import QtQuick 2.0
18−import HudClient 0.1
19−
20−Row {
21− signal actionTriggered(int action)
22− property alias model: repeater.model
23−
24− spacing: units.gu(3)
25− Repeater {
26− id: repeater
27− ToolBarIcon {
28− source: model.iconPath
29− onClicked: actionTriggered(model.action)
30− enabled: model.enabled
31− }
32− }
33−}
qml/Hud/ToolBarIcon.qmldeleted−32
@@ -1,32 +0,0 @@
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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−AbstractButton {
21− property alias source: image.source
22−
23− height: units.gu(4)
24− width: height
25− opacity: enabled ? 1 : 0.5
26− Behavior on opacity { NumberAnimation { duration: 150 } }
27−
28− Image {
29− id: image
30− anchors.fill: parent
31− }
32−}
qml/Hud/graphics/divider@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/divider@20.scideleted−5
@@ -1,5 +0,0 @@
1−border.left: 0
2−border.top: 0
3−border.bottom: 0
4−border.right: 2
5−source: divider@20.png
qml/Hud/graphics/help@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/hud_bg@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/hud_handlearrow@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/hud_handlebar@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/icon_arrow@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/icon_clear@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/icon_search@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/microphone@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/popup_triangle@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/settings@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/undo@20.pngdeleted

Binary file not shown.

qml/Hud/graphics/view-fullscreen@20.pngdeleted

Binary file not shown.

tests/autopilot/unity8/shell/emulators/hud.pydeleted−94
@@ -1,94 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
5−#
6−# This program is free software: you can redistribute it and/or modify
7−# it under the terms of the GNU General Public License as published by
8−# the Free Software Foundation, either version 3 of the License, or
9−# (at your option) any later version.
10−#
11−# This program is distributed in the hope that it will be useful,
12−# but WITHOUT ANY WARRANTY; without even the implied warranty of
13−# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14−# GNU General Public License for more details.
15−#
16−# You should have received a copy of the GNU General Public License
17−# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−#
19−
20−from collections import namedtuple
21−
22−from unity8 import get_grid_size
23−from unity8.shell.emulators import UnityEmulatorBase
24−from unity8.shell import DragMixin
25−from autopilot.input import Touch
26−
27−SwipeCoords = namedtuple('SwipeCoords', 'start_x end_x start_y end_y')
28−
29−
30−class Hud(UnityEmulatorBase, DragMixin):
31−
32− """An emulator that understands the Hud."""
33−
34− def show(self):
35− """Swipes open the Hud."""
36− self.touch = Touch.create()
37−
38− window = self.get_root_instance().wait_select_single('QQuickView')
39− hud_show_button = window.wait_select_single("HudButton")
40−
41− swipe_coords = self.get_button_swipe_coords(window, hud_show_button)
42−
43− self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
44− self._drag(
45− swipe_coords.start_x,
46− swipe_coords.start_y,
47− swipe_coords.start_x,
48− swipe_coords.end_y
49− )
50− try:
51− hud_show_button.opacity.wait_for(1.0)
52− self.touch.release()
53− self.shown.wait_for(True)
54− except AssertionError:
55− raise
56− finally:
57− # XXX This ugly code is here just temporarily, waiting for uinput
58− # improvements to land on autopilot so we don't have to access
59− # device private internal attributes. --elopio - 2014-02-12
60− try:
61− pressed = self.touch._touch_finger is not None
62− except AttributeError:
63− pressed = self.touch.pressed
64− if pressed:
65− self.touch.release()
66−
67− def dismiss(self):
68− """Closes the open Hud."""
69− # Ensure that the Hud is actually open
70− self.shown.wait_for(True)
71− touch = Touch.create()
72− x, y = self.get_close_button_coords()
73− touch.tap(x, y)
74− self.y.wait_for(self.height)
75−
76− def get_close_button_coords(self):
77− """Returns the coordinates of the Huds close button bar."""
78− rect = self.globalRect
79− x = int(rect[0] + rect[2] / 2)
80− y = rect[1] + get_grid_size()
81− return x, y
82−
83− def get_button_swipe_coords(self, main_view, hud_show_button):
84− """Returns the coords both start and end x,y for swiping to make the
85− 'hud show' button appear.
86− """
87− start_x = int(main_view.x + (main_view.width / 2))
88− end_x = start_x
89− start_y = main_view.y + (main_view.height - 3)
90− end_y = main_view.y + int(
91− hud_show_button.y + (hud_show_button.height/2)
92− )
93−
94− return SwipeCoords(start_x, end_x, start_y, end_y)
tests/autopilot/unity8/shell/emulators/main_window.py−13
@@ -24,7 +24,6 @@ from autopilot import input
2424
2525from unity8.shell import emulators
2626from unity8.shell.emulators.greeter import Greeter
27−from unity8.shell.emulators.hud import Hud
2827from unity8.shell.emulators.launcher import Launcher
2928
3029logger = logging.getLogger(__name__)
@@ -48,18 +47,6 @@ class QQuickView(emulators.UnityEmulatorBase):
4847 def get_login_list(self):
4948 return self.select_single("LoginList")
5049
51− def get_hud(self):
52− return self.select_single(Hud)
53−
54− def get_hud_showable(self):
55− return self.select_single("Showable", objectName="hudShowable")
56−
57− def get_hud_show_button(self):
58− return self.select_single("HudButton")
59−
60− def get_hud_edge_drag_area(self):
61− return self.select_single(objectName="hudDragArea")
62−
6350 def get_bottombar(self):
6451 return self.select_single("Bottombar")
6552
tests/autopilot/unity8/shell/tests/__init__.py−3
@@ -203,9 +203,6 @@ class UnityTestCase(AutopilotTestCase):
203203 else:
204204 self.grid_size = int(self.grid_unit_px / scale_divisor)
205205 self._environment["GRID_UNIT_PX"] = str(self.grid_size)
206− # FIXME this is only needed for Hud.get_close_button_coords
207− # we should probably rework it so that it's not required
208− self.patch_environment("GRID_UNIT_PX", str(self.grid_size))
209206
210207 def _geo_larger_than_display(self, width, height):
211208 should_scale = getattr(self, 'scale_geo', True)
tests/autopilot/unity8/shell/tests/disabled_test_hud.pydeleted−225
@@ -1,225 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014 Canonical
5−#
6−# This program is free software: you can redistribute it and/or modify
7−# it under the terms of the GNU General Public License as published by
8−# the Free Software Foundation, either version 3 of the License, or
9−# (at your option) any later version.
10−#
11−# This program is distributed in the hope that it will be useful,
12−# but WITHOUT ANY WARRANTY; without even the implied warranty of
13−# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14−# GNU General Public License for more details.
15−#
16−# You should have received a copy of the GNU General Public License
17−# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−#
19−
20−from __future__ import absolute_import
21−
22−from unity8.process_helpers import unlock_unity
23−from unity8.shell import DragMixin
24−from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25−
26−from testtools.matchers import Equals
27−from autopilot.matchers import Eventually
28−
29−
30−class TestHud(UnityTestCase, DragMixin):
31−
32− """Tests the Shell HUD."""
33−
34− scenarios = _get_device_emulation_scenarios()
35−
36− def test_show_hud_button_appears(self):
37− """Swiping up while an app is active must show the 'show hud' button.
38−
39− It should follow some behaviours.
40− The button must disappear not opening the HUD when releasing the
41− mouse again somewhere on the screen except on the button itself
42− following a timeout.
43− The button must disappear when touching somewhere on the screen
44− except the button itself.
45−
46− """
47− unity_proxy = self.launch_unity()
48− unlock_unity(unity_proxy)
49− hud_show_button = self.main_window.get_hud_show_button()
50− edge_drag_area = self.main_window.get_hud_edge_drag_area()
51− hud = self.main_window.get_hud()
52−
53− self._launch_test_app_from_app_screen()
54−
55− swipe_coords = hud.get_button_swipe_coords(
56− self.main_window,
57− hud_show_button
58− )
59− initialBottomMargin = int(hud_show_button.bottomMargin)
60−
61− self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
62− self.addCleanup(self._maybe_release_finger)
63− self._drag(
64− swipe_coords.start_x,
65− swipe_coords.start_y,
66− swipe_coords.start_x,
67− swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5)
68− self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5)))
69− self.assertThat(
70− hud_show_button.bottomMargin,
71− Eventually(Equals(initialBottomMargin)))
72− self._drag(
73− swipe_coords.start_x,
74− swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5,
75− swipe_coords.end_x,
76− swipe_coords.start_y - int(edge_drag_area.distanceThreshold) -
77− int(edge_drag_area.commitDistance) - 5)
78− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
79− self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
80− self.touch.release()
81− self.assertThat(hud.shown, Equals(False))
82− self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
83−
84− self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
85− self._drag(
86− swipe_coords.start_x,
87− swipe_coords.start_y,
88− swipe_coords.start_x,
89− swipe_coords.end_y - int(hud_show_button.height))
90− self.assertThat(hud.shown, Equals(False))
91− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
92− self.touch.release()
93− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
94− self.touch.tap(
95− swipe_coords.end_x,
96− swipe_coords.end_y - int(hud_show_button.height))
97− self.assertThat(hud.shown, Equals(False))
98− self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
99−
100− def test_show_hud_appears(self):
101− """Releasing the touch on the 'show hud' button must display the hud.
102− Test that the hud button stays on screen and tapping it opens the
103− hud.
104−
105− """
106− unity_proxy = self.launch_unity()
107− unlock_unity(unity_proxy)
108− hud_show_button = self.main_window.get_hud_show_button()
109− hud = self.main_window.get_hud()
110−
111− self._launch_test_app_from_app_screen()
112−
113− swipe_coords = hud.get_button_swipe_coords(
114− self.main_window,
115− hud_show_button
116− )
117−
118− self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
119− self.addCleanup(self._maybe_release_finger)
120− self._drag(
121− swipe_coords.start_x,
122− swipe_coords.start_y,
123− swipe_coords.start_x,
124− swipe_coords.end_y)
125− self.assertThat(hud.shown, Eventually(Equals(False)))
126− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
127− self.touch.release()
128− self.assertThat(hud.shown, Eventually(Equals(True)))
129− self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
130− x, y = hud.get_close_button_coords()
131− self.touch.tap(x, y)
132− self.assertThat(hud.shown, Eventually(Equals(False)))
133−
134− self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
135− self._drag(
136− swipe_coords.start_x,
137− swipe_coords.start_y,
138− swipe_coords.start_x,
139− swipe_coords.end_y - int(hud_show_button.height))
140− self.assertThat(hud.shown, Equals(False))
141− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
142− self.touch.release()
143− self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
144− self.touch.tap(swipe_coords.end_x, swipe_coords.end_y)
145− self.assertThat(hud.shown, Eventually(Equals(True)))
146− self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
147−
148− def test_hide_hud_click(self):
149− """Tapping the close button of the Hud must dismiss it."""
150− unity_proxy = self.launch_unity()
151− unlock_unity(unity_proxy)
152− hud = self.main_window.get_hud()
153−
154− self._launch_test_app_from_app_screen()
155−
156− hud.show()
157−
158− x, y = hud.get_close_button_coords()
159− self.touch.tap(x, y)
160− self.assertThat(hud.shown, Eventually(Equals(False)))
161−
162− def test_hide_hud_dragging(self):
163− """Once open the Hud must close if the upper bar is dragged and
164− released downward.
165−
166− """
167− unity_proxy = self.launch_unity()
168− unlock_unity(unity_proxy)
169− hud = self.main_window.get_hud()
170−
171− self._launch_test_app_from_app_screen()
172−
173− hud.show()
174−
175− start_x, start_y = hud.get_close_button_coords()
176− end_x = start_x
177− end_y = int(self.main_window.height / 2)
178−
179− self.touch.drag(start_x, start_y, end_x, end_y)
180− self.assertThat(hud.shown, Eventually(Equals(False)))
181−
182− def test_launcher_hides_hud(self):
183− """Opening the Launcher while the Hud is active must close the Hud."""
184− unity_proxy = self.launch_unity()
185− unlock_unity(unity_proxy)
186− hud = self.main_window.get_hud()
187−
188− self._launch_test_app_from_app_screen()
189−
190− hud.show()
191− self.main_window.open_launcher()
192−
193− self.assertThat(hud.shown, Eventually(Equals(False)))
194−
195− def _launch_test_app_from_app_screen(self):
196− """Launches the browser app using the Dash UI.
197−
198− Because when testing on the desktop running
199− self.launch_application() will launch the application on the desktop
200− itself and not within the Unity UI.
201−
202− """
203− dash = self.main_window.get_dash()
204− icon = dash.get_application_icon('Browser')
205− self.touch.tap_object(icon)
206−
207− # Ensure application is open
208− bottombar = self.main_window.get_bottombar()
209− self.assertThat(bottombar.applicationIsOnForeground,
210− Eventually(Equals(True)))
211−
212− # Because some tests are manually manipulating the finger, we want to
213− # cleanup if the test fails, but we don't want to fail with an exception if
214− # we don't.
215− def _maybe_release_finger(self):
216− """Only release the finger if it is in fact down."""
217− # XXX This ugly code is here just temporarily, waiting for uinput
218− # improvements to land on autopilot so we don't have to access device
219− # private internal attributes. --elopio - 2014-02-12
220− try:
221− pressed = self.touch._touch_finger is not None
222− except AttributeError:
223− pressed = self.touch.pressed
224− if pressed:
225− self.touch.release()
tests/mocks/CMakeLists.txt−1
@@ -30,7 +30,6 @@ endmacro()
3030
3131add_subdirectory(AccountsService)
3232add_subdirectory(GSettings.1.0)
33−add_subdirectory(HudClient)
3433add_subdirectory(libusermetrics)
3534add_subdirectory(LightDM)
3635add_subdirectory(Powerd)
tests/mocks/HudClient/CMakeLists.txtdeleted−38
@@ -1,38 +0,0 @@
1−pkg_search_module(DEE dee-1.0 REQUIRED)
2−pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
3−pkg_search_module(HUDCLIENT hud-client-2 REQUIRED)
4−pkg_search_module(DEEQT libdee-qt5 REQUIRED)
5−pkg_search_module(PULSE libpulse REQUIRED)
6−
7−include_directories(
8− ${CMAKE_SOURCE_DIR}/plugins/HudClient
9− ${CMAKE_CURRENT_BINARY_DIR}
10− ${Qt5Core_INCLUDE_DIRS}
11− ${Qt5Quick_INCLUDE_DIRS}
12− ${DEE_INCLUDE_DIRS}
13− ${DEEQT_INCLUDE_DIRS}
14− ${HUDCLIENT_INCLUDE_DIRS}
15− ${PULSE_INCLUDE_DIRS}
16−)
17−
18−set(HudQML_SOURCES
19− ${CMAKE_SOURCE_DIR}/plugins/HudClient/hudclient.cpp
20− ${CMAKE_SOURCE_DIR}/plugins/HudClient/volumepeakdetector.cpp
21− ${CMAKE_SOURCE_DIR}/plugins/HudClient/hudtoolbarmodel.cpp
22− fake_hud_plugin.cpp
23− fake_libhud_client.cpp
24− libhud_client_stub.cpp
25−)
26−
27−add_library(FakeHudClientQml MODULE ${HudQML_SOURCES})
28−target_link_libraries(FakeHudClientQml
29− ${Qt5Core_LIBRARIES}
30− ${Qt5Quick_LIBRARIES}
31− ${DEEQT_LDFLAGS}
32− ${GOBJECT_LDFLAGS}
33− ${PULSE_LDFLAGS}
34−)
35−
36−qt5_use_modules(FakeHudClientQml Qml)
37−
38−add_unity8_mock(HudClient 0.1 HudClient TARGETS FakeHudClientQml)
tests/mocks/HudClient/HudClient.qmltypesdeleted−113
@@ -1,113 +0,0 @@
1−import QtQuick.tooling 1.1
2−
3−// This file describes the plugin-supplied types contained in the library.
4−// It is used for QML tooling purposes only.
5−//
6−// This file was auto-generated by:
7−// 'qmlplugindump -notrelocatable HudClient 0.1 tests/mocks'
8−
9−Module {
10− Component {
11− name: "DeeListModel"
12− prototype: "QAbstractListModel"
13− Property { name: "name"; type: "string" }
14− Property { name: "synchronized"; type: "bool"; isReadonly: true }
15− Property { name: "count"; type: "int"; isReadonly: true }
16− Signal {
17− name: "nameChanged"
18− Parameter { type: "string" }
19− }
20− Signal {
21− name: "synchronizedChanged"
22− Parameter { type: "bool" }
23− }
24− Signal {
25− name: "roleNamesChanged"
26− Parameter { type: "QHash<int,QByteArray>" }
27− }
28− Method {
29− name: "get"
30− type: "QVariantMap"
31− Parameter { name: "row"; type: "int" }
32− }
33− Method { name: "count"; type: "int" }
34− }
35− Component {
36− name: "HudClient"
37− prototype: "QObject"
38− exports: ["HudClient/HudClient 0.1"]
39− exportMetaObjectRevisions: [0]
40− Property { name: "results"; type: "DeeListModel"; isReadonly: true; isPointer: true }
41− Property { name: "toolBarModel"; type: "QAbstractItemModel"; isReadonly: true; isPointer: true }
42− Signal { name: "voiceQueryLoading" }
43− Signal { name: "voiceQueryListening" }
44− Signal { name: "voiceQueryHeardSomething" }
45− Signal { name: "voiceQueryFailed" }
46− Signal {
47− name: "voiceQueryFinished"
48− Parameter { name: "query"; type: "string" }
49− }
50− Signal { name: "commandExecuted" }
51− Signal {
52− name: "showParametrizedAction"
53− Parameter { name: "action"; type: "string" }
54− Parameter { name: "items"; type: "QVariant" }
55− }
56− Method {
57− name: "executeCommand"
58− Parameter { name: "index"; type: "int" }
59− }
60− Method {
61− name: "setQuery"
62− Parameter { name: "new_query"; type: "string" }
63− }
64− Method { name: "startVoiceQuery" }
65− Method {
66− name: "executeParametrizedAction"
67− Parameter { name: "values"; type: "QVariant" }
68− }
69− Method {
70− name: "updateParametrizedAction"
71− Parameter { name: "values"; type: "QVariant" }
72− }
73− Method { name: "cancelParametrizedAction" }
74− Method {
75− name: "executeToolBarAction"
76− Parameter { name: "action"; type: "HudClientQueryToolbarItems" }
77− }
78− }
79− Component {
80− name: "HudClientStub"
81− prototype: "QObject"
82− exports: ["HudClient/HudClientStub 0.1"]
83− exportMetaObjectRevisions: [0]
84− Property { name: "lastExecutedToolbarItem"; type: "int"; isReadonly: true }
85− Property { name: "lastSetQuery"; type: "string"; isReadonly: true }
86− Property { name: "lastExecutedCommandRow"; type: "int"; isReadonly: true }
87− Property { name: "lastExecutedParametrizedCommandRow"; type: "int"; isReadonly: true }
88− Property { name: "lastParametrizedCommandCommited"; type: "bool"; isReadonly: true }
89− Property { name: "activatedActions"; type: "QVariantMap"; isReadonly: true }
90− Method { name: "reset" }
91− Method { name: "fullScreenToolbarItemValue"; type: "int" }
92− Method { name: "helpToolbarItemValue"; type: "int" }
93− Method { name: "preferencesToolbarItemValue"; type: "int" }
94− Method { name: "undoToolbarItemValue"; type: "int" }
95− Method {
96− name: "setHelpToolbarItemEnabled"
97− Parameter { name: "enabled"; type: "bool" }
98− }
99− }
100− Component { name: "HudToolBarModel"; prototype: "QAbstractListModel" }
101− Component {
102− name: "VolumePeakDetector"
103− prototype: "QObject"
104− exports: ["HudClient/VolumePeakDetector 0.1"]
105− exportMetaObjectRevisions: [0]
106− Property { name: "enabled"; type: "bool" }
107− Property { name: "desiredInterval"; type: "int" }
108− Signal {
109− name: "newPeak"
110− Parameter { name: "volume"; type: "float" }
111− }
112− }
113−}
tests/mocks/HudClient/fake_hud_plugin.cppdeleted−39
@@ -1,39 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include "fake_hud_plugin.h"
18−
19−#include "hudclient.h"
20−#include "volumepeakdetector.h"
21−#include "libhud_client_stub.h"
22−
23−#include <deelistmodel.h>
24−
25−#include <qqml.h>
26−
27−void FakeHudQmlPlugin::registerTypes(const char *uri)
28−{
29−#ifndef GLIB_VERSION_2_36
30− g_type_init();
31−#endif
32−
33− qmlRegisterType<QAbstractItemModel>();
34− qmlRegisterType<DeeListModel>();
35−
36− qmlRegisterType<HudClient>(uri, 0, 1, "HudClient");
37− qmlRegisterType<VolumePeakDetector>(uri, 0, 1, "VolumePeakDetector");
38− qmlRegisterType<HudClientStub>(uri, 0, 1, "HudClientStub");
39−}
tests/mocks/HudClient/fake_hud_plugin.hdeleted−31
@@ -1,31 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#ifndef PLUGIN_H
18−#define PLUGIN_H
19−
20−#include <QQmlExtensionPlugin>
21−
22−class FakeHudQmlPlugin : public QQmlExtensionPlugin
23−{
24− Q_OBJECT
25− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26−public:
27− void registerTypes(const char *uri);
28−};
29−
30−
31−#endif
tests/mocks/HudClient/fake_libhud_client.cppdeleted−247
@@ -1,247 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include <hud-client.h>
18−
19−#include "libhud_client_stub.h"
20−
21−/* Schema that is used in the DeeModel representing
22− the results */
23−static const gchar * results_model_schema[] = {
24− "v", /* Command ID */
25− "s", /* Command Name */
26− "a(ii)", /* Highlights in command name */
27− "s", /* Description */
28− "a(ii)", /* Highlights in description */
29− "s", /* Shortcut */
30− "u", /* Distance */
31− "b", /* Parameterized */
32−};
33−
34−DeeModel *resultsModel = 0;
35−GMenuModel *parametrizedActionModel = 0;
36−GActionGroup *parametrizedActionGroup = 0;
37−
38−static void hud_client_query_class_init(HudClientQueryClass *klass);
39−static void hud_client_query_init(HudClientQuery *self);
40−G_DEFINE_TYPE(HudClientQuery, hud_client_query, G_TYPE_OBJECT)
41−
42−static void hud_client_query_init(HudClientQuery * /*self*/)
43−{
44−}
45−static void hud_client_query_class_init(HudClientQueryClass * /*klass*/)
46−{
47− HudClientStub::m_querySignalToolbarUpdated = g_signal_new (HUD_CLIENT_QUERY_SIGNAL_TOOLBAR_UPDATED,
48− HUD_CLIENT_TYPE_QUERY,
49− G_SIGNAL_RUN_LAST,
50− 0, /* offset */
51− nullptr, nullptr, /* Accumulator */
52− g_cclosure_marshal_VOID__VOID,
53− G_TYPE_NONE, 0, G_TYPE_NONE);
54−}
55−
56−HudClientQuery *hud_client_query_new(const gchar *query)
57−{
58− HudClientStub::m_lastSetQuery = QString::fromUtf8(query);
59− HudClientStub::m_query = HUD_CLIENT_QUERY(g_object_new(HUD_CLIENT_TYPE_QUERY, nullptr));
60− return HudClientStub::m_query;
61−}
62−
63−DeeModel *hud_client_query_get_results_model(HudClientQuery *cquery)
64−{
65− Q_ASSERT(cquery == HudClientStub::m_query);
66− Q_UNUSED(cquery);
67− if (!resultsModel) {
68− resultsModel = dee_sequence_model_new();
69− dee_model_set_schema_full(resultsModel, results_model_schema, G_N_ELEMENTS(results_model_schema));
70−
71− GVariant * columns[G_N_ELEMENTS(results_model_schema) + 1];
72− columns[0] = g_variant_new_variant(g_variant_new_uint64(0));
73− columns[1] = g_variant_new_string("Help");
74− columns[2] = g_variant_new_array(G_VARIANT_TYPE("(ii)"), nullptr, 0);
75− columns[3] = g_variant_new_string("Get Help");
76− columns[4] = g_variant_new_array(G_VARIANT_TYPE("(ii)"), nullptr, 0);
77− columns[5] = g_variant_new_string("");
78− columns[6] = g_variant_new_uint32(3);
79− columns[7] = g_variant_new_boolean(false);
80− columns[8] = nullptr;
81− dee_model_append_row(resultsModel, columns);
82−
83− columns[0] = g_variant_new_variant(g_variant_new_uint64(1));
84− columns[1] = g_variant_new_string("About");
85− columns[3] = g_variant_new_string("Show About");
86− dee_model_append_row(resultsModel, columns);
87−
88− columns[0] = g_variant_new_variant(g_variant_new_uint64(2));
89− columns[1] = g_variant_new_string("Foo");
90− columns[3] = g_variant_new_string("Show Foo");
91− columns[7] = g_variant_new_boolean(true);
92− dee_model_append_row(resultsModel, columns);
93−
94− columns[0] = g_variant_new_variant(g_variant_new_uint64(3));
95− columns[1] = g_variant_new_string("Bar");
96− columns[3] = g_variant_new_string("Show Bar");
97− columns[7] = g_variant_new_boolean(false);
98− dee_model_append_row(resultsModel, columns);
99−
100− columns[0] = g_variant_new_variant(g_variant_new_uint64(4));
101− columns[1] = g_variant_new_string("FooBar");
102− columns[3] = g_variant_new_string("Show FooBar");
103− dee_model_append_row(resultsModel, columns);
104−
105− columns[0] = g_variant_new_variant(g_variant_new_uint64(5));
106− columns[1] = g_variant_new_string("UltraFooBar");
107− columns[3] = g_variant_new_string("Show UltraFooBar");
108− dee_model_append_row(resultsModel, columns);
109− }
110− return resultsModel;
111−}
112−
113−void hud_client_query_execute_toolbar_item(HudClientQuery *cquery, HudClientQueryToolbarItems item, guint timestamp)
114−{
115− Q_ASSERT(cquery == HudClientStub::m_query);
116− Q_UNUSED(timestamp);
117− Q_UNUSED(cquery);
118− HudClientStub::m_lastExecutedToolbarItem = item;
119−}
120−
121−void hud_client_query_set_query(HudClientQuery *cquery, const char *query)
122−{
123− Q_ASSERT(cquery == HudClientStub::m_query);
124− Q_UNUSED(cquery);
125− HudClientStub::m_lastSetQuery = QString::fromUtf8(query);
126−}
127−
128−void hud_client_query_execute_command(HudClientQuery *cquery, GVariant *command_key, guint timestamp)
129−{
130− Q_ASSERT(cquery == HudClientStub::m_query);
131− Q_UNUSED(cquery);
132− Q_UNUSED(timestamp);
133− for (uint i = 0; i < dee_model_get_n_rows(resultsModel); ++i) {
134− DeeModelIter *iter = dee_model_get_iter_at_row(resultsModel, i);
135− if (!dee_model_get_bool(resultsModel, iter, 7)) {
136− GVariant *it_command = dee_model_get_value(resultsModel, iter, 0);
137− if (g_variant_equal (command_key, it_command)) {
138− HudClientStub::m_lastExecutedCommandRow = i;
139− g_variant_unref(it_command);
140− return;
141− }
142− g_variant_unref(it_command);
143− }
144− }
145− HudClientStub::m_lastExecutedCommandRow = -1;
146−}
147−
148−HudClientParam *hud_client_query_execute_param_command(HudClientQuery *cquery, GVariant *command_key, guint timestamp)
149−{
150− Q_ASSERT(cquery == HudClientStub::m_query);
151− Q_UNUSED(cquery);
152− Q_UNUSED(timestamp);
153− for (uint i = 0; i < dee_model_get_n_rows(resultsModel); ++i) {
154− DeeModelIter *iter = dee_model_get_iter_at_row(resultsModel, i);
155− if (dee_model_get_bool(resultsModel, iter, 7)) {
156− GVariant *it_command = dee_model_get_value(resultsModel, iter, 0);
157− if (g_variant_equal (command_key, it_command)) {
158− HudClientStub::m_lastExecutedParametrizedCommandRow = i;
159− g_variant_unref(it_command);
160− // No need to create a real HudClientParam since it's always passed down to us
161− return (HudClientParam *)g_object_new(G_TYPE_OBJECT, nullptr);
162− }
163− g_variant_unref(it_command);
164− }
165− }
166− HudClientStub::m_lastExecutedParametrizedCommandRow = -1;
167− return nullptr;
168−}
169−
170−void hud_client_query_voice_query(HudClientQuery *cquery)
171−{
172− Q_ASSERT(cquery == HudClientStub::m_query);
173− Q_UNUSED(cquery);
174− // TODO We are not testing voice queries yet
175−}
176−
177−gboolean hud_client_query_toolbar_item_active(HudClientQuery *cquery, HudClientQueryToolbarItems item)
178−{
179− Q_ASSERT(cquery == HudClientStub::m_query);
180− Q_UNUSED(cquery);
181− if (item == HUD_CLIENT_QUERY_TOOLBAR_HELP)
182− return HudClientStub::m_helpToolbarItemEnabled;
183−
184− return true;
185−}
186−
187−GMenuModel *hud_client_param_get_model(HudClientParam *param)
188−{
189− Q_UNUSED(param);
190−
191− if (!parametrizedActionModel) {
192− GMenu *menu = g_menu_new();
193− GMenuItem *item = g_menu_item_new("Item1Label", nullptr);
194− g_menu_item_set_attribute_value(item, "parameter-type", g_variant_new_string("slider"));
195− g_menu_item_set_attribute_value(item, "min", g_variant_new_double(10));
196− g_menu_item_set_attribute_value(item, "max", g_variant_new_double(80));
197− g_menu_item_set_attribute_value(item, "live", g_variant_new_boolean(true));
198− g_menu_item_set_attribute_value(item, "value", g_variant_new_double(75));
199− g_menu_item_set_attribute_value(item, "action", g_variant_new_string("costAction"));
200− g_menu_append_item (menu, item);
201−
202− parametrizedActionModel = G_MENU_MODEL(menu);
203− }
204−
205− return parametrizedActionModel;
206−}
207−
208−void hud_client_param_send_cancel(HudClientParam *param)
209−{
210− Q_UNUSED(param);
211− g_clear_object(&parametrizedActionModel);
212− parametrizedActionModel = 0;
213− HudClientStub::m_lastParametrizedCommandCommited = false;
214−}
215−
216−static void on_signal_activated (GSimpleAction *action, GVariant *parameter, gpointer /*user_data*/)
217−{
218− // Only double for the moment
219− HudClientStub::m_activatedActions.insert(g_action_get_name(G_ACTION(action)), QVariant(g_variant_get_double(parameter)));
220−}
221−
222−GActionGroup *hud_client_param_get_actions(HudClientParam *param)
223−{
224− Q_UNUSED(param);
225− if (!parametrizedActionGroup) {
226− GSimpleActionGroup *actionGroup = g_simple_action_group_new();
227− GSimpleAction *action = g_simple_action_new("costAction", G_VARIANT_TYPE_DOUBLE);
228− g_action_map_add_action(G_ACTION_MAP(actionGroup), G_ACTION(action));
229−
230− g_signal_connect (action, "activate", G_CALLBACK (on_signal_activated), nullptr);
231−
232−
233− parametrizedActionGroup = G_ACTION_GROUP(actionGroup);
234− }
235−
236− return parametrizedActionGroup;
237−}
238−
239−void hud_client_param_send_commit(HudClientParam *param)
240−{
241− Q_UNUSED(param);
242− g_object_unref(parametrizedActionGroup);
243− parametrizedActionGroup = 0;
244− g_clear_object(&parametrizedActionModel);
245− parametrizedActionModel = 0;
246− HudClientStub::m_lastParametrizedCommandCommited = true;
247−}
tests/mocks/HudClient/libhud_client_stub.cppdeleted−93
@@ -1,93 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#include "libhud_client_stub.h"
18−
19−HudClientQuery *HudClientStub::m_query;
20−guint HudClientStub::m_querySignalToolbarUpdated;
21−int HudClientStub::m_lastExecutedToolbarItem;
22−QString HudClientStub::m_lastSetQuery;
23−int HudClientStub::m_lastExecutedCommandRow;
24−int HudClientStub::m_lastExecutedParametrizedCommandRow;
25−bool HudClientStub::m_lastParametrizedCommandCommited;
26−QVariantMap HudClientStub::m_activatedActions;
27−bool HudClientStub::m_helpToolbarItemEnabled = true;
28−
29−int HudClientStub::lastExecutedToolbarItem() const
30−{
31− return m_lastExecutedToolbarItem;
32−}
33−
34−QString HudClientStub::lastSetQuery() const
35−{
36− return m_lastSetQuery;
37−}
38−
39−int HudClientStub::lastExecutedCommandRow() const
40−{
41− return m_lastExecutedCommandRow;
42−}
43−
44−int HudClientStub::lastExecutedParametrizedCommandRow() const
45−{
46− return m_lastExecutedParametrizedCommandRow;
47−}
48−
49−bool HudClientStub::lastParametrizedCommandCommited() const
50−{
51− return m_lastParametrizedCommandCommited;
52−}
53−
54−QVariantMap HudClientStub::activatedActions() const
55−{
56− return m_activatedActions;
57−}
58−
59−void HudClientStub::reset()
60−{
61− m_lastExecutedToolbarItem = -1;
62− m_lastSetQuery.clear();
63− m_lastExecutedCommandRow = -1;
64− m_lastExecutedParametrizedCommandRow = -1;
65− m_lastParametrizedCommandCommited = false;
66− m_activatedActions.clear();
67−}
68−
69−int HudClientStub::fullScreenToolbarItemValue() const
70−{
71− return HUD_CLIENT_QUERY_TOOLBAR_FULLSCREEN;
72−}
73−
74−int HudClientStub::helpToolbarItemValue() const
75−{
76− return HUD_CLIENT_QUERY_TOOLBAR_HELP;
77−}
78−
79−int HudClientStub::preferencesToolbarItemValue() const
80−{
81− return HUD_CLIENT_QUERY_TOOLBAR_PREFERENCES;
82−}
83−
84−int HudClientStub::undoToolbarItemValue() const
85−{
86− return HUD_CLIENT_QUERY_TOOLBAR_UNDO;
87−}
88−
89−void HudClientStub::setHelpToolbarItemEnabled(bool enabled) const
90−{
91− m_helpToolbarItemEnabled = enabled;
92− g_signal_emit(G_OBJECT(m_query), m_querySignalToolbarUpdated, 0);
93−}
tests/mocks/HudClient/libhud_client_stub.hdeleted−64
@@ -1,64 +0,0 @@
1−/*
2− * Copyright (C) 2012, 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− */
16−
17−#ifndef HUDCLIENTSTUB_H
18−#define HUDCLIENTSTUB_H
19−
20−#include <QObject>
21−
22−#include <QVariantMap>
23−
24−#include <hud-client.h>
25−
26−class HudClientStub : public QObject
27−{
28− Q_OBJECT
29−
30− Q_PROPERTY(int lastExecutedToolbarItem READ lastExecutedToolbarItem)
31− Q_PROPERTY(QString lastSetQuery READ lastSetQuery)
32− Q_PROPERTY(int lastExecutedCommandRow READ lastExecutedCommandRow)
33− Q_PROPERTY(int lastExecutedParametrizedCommandRow READ lastExecutedParametrizedCommandRow)
34− Q_PROPERTY(bool lastParametrizedCommandCommited READ lastParametrizedCommandCommited)
35− Q_PROPERTY(QVariantMap activatedActions READ activatedActions)
36−
37−public:
38− int lastExecutedToolbarItem() const;
39− QString lastSetQuery() const;
40− int lastExecutedCommandRow() const;
41− int lastExecutedParametrizedCommandRow() const;
42− bool lastParametrizedCommandCommited() const;
43− QVariantMap activatedActions() const;
44−
45− Q_INVOKABLE void reset();
46− Q_INVOKABLE int fullScreenToolbarItemValue() const;
47− Q_INVOKABLE int helpToolbarItemValue() const;
48− Q_INVOKABLE int preferencesToolbarItemValue() const;
49− Q_INVOKABLE int undoToolbarItemValue() const;
50− Q_INVOKABLE void setHelpToolbarItemEnabled(bool enabled) const;
51−
52− static HudClientQuery *m_query;
53− static guint m_querySignalToolbarUpdated;
54− static int m_lastExecutedToolbarItem;
55− static QString m_lastSetQuery;
56− static int m_lastExecutedCommandRow;
57− static int m_lastExecutedParametrizedCommandRow;
58− static bool m_lastParametrizedCommandCommited;
59− static QVariantMap m_activatedActions;
60− static bool m_helpToolbarItemEnabled;
61−};
62−
63−
64−#endif
tests/mocks/HudClient/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module HudClient
2−plugin FakeHudClientQml
3−typeinfo HudClient.qmltypes
tests/qmltests/CMakeLists.txt−2
@@ -66,8 +66,6 @@ add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DI
6666add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
6767add_qml_test(Greeter Infographics ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
6868add_qml_test(Greeter Clock ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
69−add_qml_test(Hud Hud)
70−add_qml_test(Hud Result)
7169add_qml_test(Launcher Launcher)
7270add_qml_test(Notifications Notifications)
7371add_qml_test(Notifications VisualSnapDecisionsQueue)
tests/qmltests/Hud/tst_Hud.qmldeleted−239
@@ -1,239 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import ".."
20−import "../../../qml/Hud"
21−import HudClient 0.1
22−import Unity.Test 0.1 as UT
23−
24−Hud {
25− id: hud
26− height: units.gu(80)
27− width: units.gu(50)
28−
29− // Mock shell to shut up some warnings
30− property QtObject shell: QtObject {
31− property QtObject applicationManager: QtObject {
32− id: applicationManager
33− property bool keyboardVisible: false
34− }
35− }
36−
37− HudClientStub {
38− id: hudClientStub
39− }
40−
41− UT.UnityTestCase {
42− name: "Hud"
43− when: windowShown
44−
45− function resetToInitialState() {
46− var parametrizedActionsPage = findChild(hud, "parametrizedActionsPage")
47−
48− hud.show()
49− hud.resetToInitialState()
50− hudClientStub.reset()
51− tryCompare(parametrizedActionsPage, "x", hud.width) // Make sure the parametrized page action animation is finished
52− }
53−
54− function test_hud_toolbar() {
55− var toolBar = findChild(hud, "toolBar")
56− resetToInitialState()
57−
58− var toolBarIconCount = 0
59− for (var i in toolBar.children) {
60− if (UT.Util.isInstanceOf(toolBar.children[i], "ToolBarIcon")) {
61− toolBarIconCount++
62− }
63− }
64− compare(toolBarIconCount, 4, "toolbar item count")
65−
66− mouseClick(toolBar.children[0], 0, 0)
67− compare(hudClientStub.lastExecutedToolbarItem, hudClientStub.undoToolbarItemValue(), "Click on undo")
68−
69− mouseClick(toolBar.children[1], 0, 0)
70− compare(hudClientStub.lastExecutedToolbarItem, hudClientStub.helpToolbarItemValue(), "Click on help")
71−
72− mouseClick(toolBar.children[2], 0, 0)
73− compare(hudClientStub.lastExecutedToolbarItem, hudClientStub.fullScreenToolbarItemValue(), "Click on fullscreen")
74−
75− mouseClick(toolBar.children[3], 0, 0)
76− compare(hudClientStub.lastExecutedToolbarItem, hudClientStub.preferencesToolbarItemValue(), "Click on preferences")
77−
78− compare(toolBar.children[0].enabled, true)
79− compare(toolBar.children[1].enabled, true)
80− compare(toolBar.children[2].enabled, true)
81− compare(toolBar.children[3].enabled, true)
82−
83− hudClientStub.setHelpToolbarItemEnabled(false);
84− compare(toolBar.children[0].enabled, true)
85− compare(toolBar.children[1].enabled, false)
86− compare(toolBar.children[2].enabled, true)
87− compare(toolBar.children[3].enabled, true)
88− }
89−
90− function test_hud_results() {
91− var resultListRepeater = findChild(hud, "resultListRepeater")
92− resetToInitialState()
93−
94− tryCompare(resultListRepeater, "count", 5)
95−
96− compare(resultListRepeater.itemAt(0).children[1].nameText, "Help", "First result name")
97− compare(resultListRepeater.itemAt(0).children[1].contextSnippetText, "Get Help", "First result description")
98−
99− compare(resultListRepeater.itemAt(1).children[1].nameText, "About", "Second result name")
100− compare(resultListRepeater.itemAt(1).children[1].contextSnippetText, "Show About", "Second result description")
101−
102− compare(resultListRepeater.itemAt(2).children[1].nameText, "Foo", "Third result name")
103− compare(resultListRepeater.itemAt(2).children[1].contextSnippetText, "Show Foo", "Third result description")
104−
105− compare(resultListRepeater.itemAt(3).children[1].nameText, "Bar", "Fourth result name")
106− compare(resultListRepeater.itemAt(3).children[1].contextSnippetText, "Show Bar", "Fourth result description")
107−
108− compare(resultListRepeater.itemAt(4).children[1].nameText, "FooBar", "Fifth result name")
109− compare(resultListRepeater.itemAt(4).children[1].contextSnippetText, "Show FooBar", "Fifth result description")
110− }
111−
112− function test_hud_set_query() {
113− var searchBar = findChild(hud, "searchBar")
114− resetToInitialState()
115−
116− compare(hudClientStub.lastSetQuery, "", "Query should be empty at start")
117−
118− searchBar.text = "Hi"
119− compare(hudClientStub.lastSetQuery, "Hi", "Query should be updated")
120−
121− searchBar.text = "Ho"
122− compare(hudClientStub.lastSetQuery, "Ho", "Query should be updated")
123− }
124−
125− function compareItemAnchoredAtTopOf(itemA, itemB, spacing, text) {
126− compare(itemA.y - spacing, itemB.y, text)
127− }
128−
129− function compareItemAnchoredAtBottomOf(itemA, itemB, spacing, text) {
130− compare(itemA.y + itemA.height + spacing, itemB.y + itemB.height, text)
131− }
132−
133− function compareItemAnchoredUnderItem(itemUnder, itemTop, spacing, text) {
134− compare(itemUnder.y - spacing, itemTop.y + itemTop.height, text)
135− }
136−
137− function compareItemAnchoredOverItem(itemTop, itemUnder, spacing, text) {
138− compareItemAnchoredUnderItem(itemUnder, itemTop, spacing, text)
139− }
140−
141− function test_hud_elements_positioning() {
142− var searchBar = findChild(hud, "searchBar")
143− var searchBarContainer = findChild(hud, "searchBarAnimator")
144− var resultListContainer = findChild(hud, "resultsCardAnimator")
145− var toolBarContainer = findChild(hud, "toolBarAnimator")
146− var toolBar = findChild(hud, "toolBar")
147− var handle = findChild(hud, "handle")
148− resetToInitialState()
149−
150− compare(toolBar.visible, true, "Toolbar is initially visible")
151− compareItemAnchoredAtTopOf(handle, hud, 0, "Handle is anchored at the top")
152− compareItemAnchoredAtBottomOf(searchBarContainer, hud, hud.elementsPadding, "SearchBar is anchored at the bottom")
153− compareItemAnchoredOverItem(toolBarContainer, searchBarContainer, 2 * hud.elementsPadding, "Toolbar is anchored over the searchBar")
154− compareItemAnchoredOverItem(resultListContainer, toolBarContainer, hud.elementsPadding, "ResultsList is anchored over the toolBar")
155−
156− mouseClick(searchBar, 0, 0)
157−
158− tryCompare(toolBar, "visible", false)
159− compareItemAnchoredAtTopOf(handle, hud, 0, "Handle is anchored at the top")
160− compareItemAnchoredUnderItem(searchBarContainer, handle, hud.elementsPadding + units.dp(1), "SearchBar is anchored under the handle")
161− compareItemAnchoredUnderItem(resultListContainer, searchBarContainer, hud.elementsPadding, "ResultsList is anchored under the searchBar")
162− }
163−
164− function test_hud_result_suggestion_execution() {
165− var resultListRepeater = findChild(hud, "resultListRepeater")
166− resetToInitialState()
167−
168− mouseClick(resultListRepeater.itemAt(1), 0, 0)
169− compare(hudClientStub.lastExecutedCommandRow, 1, "Last executed row was 1")
170− compare(hud.shown, false, "Should not be shown after executing")
171− }
172−
173− function number_of_activated_actions(activatedActionsObject) {
174− var activatedActions = 0
175− for(var key in activatedActionsObject) {
176− ++activatedActions
177− }
178− return activatedActions
179− }
180−
181− function test_hud_result_suggestion_parametrized_execution_and_back() {
182− var resultListRepeater = findChild(hud, "resultListRepeater")
183− var parametrizedActionsPage = findChild(hud, "parametrizedActionsPage")
184− var backButton = parametrizedActionsPage.children[1].children[0]
185− resetToInitialState()
186−
187− compare(parametrizedActionsPage.shown, false, "Parametrized action page should be hidden at start")
188− tryCompare(parametrizedActionsPage, "x", hud.width)
189−
190− mouseClick(resultListRepeater.itemAt(2), 0, 0)
191− compare(hudClientStub.lastExecutedCommandRow, -1, "We executed a param action not a regular one")
192− compare(hudClientStub.lastExecutedParametrizedCommandRow, 2, "Last executed row was 2")
193− compare(parametrizedActionsPage.shown, true, "Parametrized action page should be shown after executing a parametrized action")
194− tryCompare(parametrizedActionsPage, "x", 0)
195−
196− var sliderLabel = parametrizedActionsPage.children[0].children[0].children[0].children[1].children[0]
197− var slider = parametrizedActionsPage.children[0].children[0].children[0].children[1].children[1]
198− compare(sliderLabel.text, "Item1Label")
199− compare(slider.minimumValue, 10)
200− compare(slider.maximumValue, 80)
201− compare(slider.live, true)
202− compare(number_of_activated_actions(hudClientStub.activatedActions), 0)
203−
204− // Since it's live moving the slider will activate it already
205− var slider = parametrizedActionsPage.children[0].children[0].children[0].children[1].children[1]
206− mouseClick(slider, units.gu(1), units.gu(1))
207− compare(number_of_activated_actions(hudClientStub.activatedActions), 1)
208− compare(hudClientStub.activatedActions["costAction"], 10)
209−
210− mouseClick(backButton, 0, 0)
211− compare(parametrizedActionsPage.shown, false, "Parametrized action page should be hidden after going back")
212− compare(hudClientStub.lastParametrizedCommandCommited, false, "Cancelling does not commit")
213− tryCompare(parametrizedActionsPage, "x", hud.width)
214− }
215−
216− function test_hud_result_suggestion_parametrized_execution_and_confirm() {
217− var resultListRepeater = findChild(hud, "resultListRepeater")
218− var parametrizedActionsPage = findChild(hud, "parametrizedActionsPage")
219− var confirmButton = parametrizedActionsPage.children[1].children[2]
220− resetToInitialState()
221−
222− compare(parametrizedActionsPage.shown, false, "Parametrized action page should be hidden at start")
223− tryCompare(parametrizedActionsPage, "x", hud.width)
224−
225− mouseClick(resultListRepeater.itemAt(2), 0, 0)
226− compare(hudClientStub.lastExecutedCommandRow, -1, "We executed a param action not a regular one")
227− compare(hudClientStub.lastExecutedParametrizedCommandRow, 2, "Last executed row was 2")
228− compare(parametrizedActionsPage.shown, true, "Parametrized action page should be shown after executing a parametrized action")
229− tryCompare(parametrizedActionsPage, "x", 0)
230− compare(number_of_activated_actions(hudClientStub.activatedActions), 0)
231−
232− mouseClick(confirmButton, 0, 0)
233− compare(hud.shown, false, "Should not be shown after executing")
234− compare(number_of_activated_actions(hudClientStub.activatedActions), 1)
235− compare(hudClientStub.activatedActions["costAction"], 75)
236− compare(hudClientStub.lastParametrizedCommandCommited, true, "Confirming does commit")
237− }
238− }
239−}
tests/qmltests/Hud/tst_Result.qmldeleted−98
@@ -1,98 +0,0 @@
1−/*
2− * Copyright 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− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import ".."
20−import "../../../qml/Hud"
21−import Unity.Test 0.1 as UT
22−
23−Rectangle {
24− width: 600
25− height: 600
26− color: "black"
27− Column {
28− anchors.fill: parent
29− Repeater {
30− model: test.test_highlightedText_data().length
31− Result {
32− width: parent.width
33− height: units.gu(4)
34− nameText: test.test_highlightedText_data()[index].text
35− nameHighlights: test.test_highlightedText_data()[index].highlights
36− }
37− }
38− }
39−
40− UT.UnityTestCase {
41− name: "Result"
42− id: test
43−
44− Result {
45− id: result
46− }
47−
48− function test_highlightedText_data() {
49− return [
50− {
51− text: "Copy",
52− highlights: [],
53− result: "Copy"
54− },
55− {
56− text: "Copy",
57− highlights: [0, 0],
58− result: "<font color=\"#ffffff\">C</font>opy"
59− },
60− {
61− text: "Copy",
62− highlights: [1, 1],
63− result: "C<font color=\"#ffffff\">o</font>py"
64− },
65− {
66− text: "Pastel",
67− highlights: [1, 1, 3, 4],
68− result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l"
69− },
70− {
71− text: "Pastel",
72− highlights: [1, 1, 3, 5],
73− result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>"
74− },
75− {
76− text: "Pastel",
77− highlights: [0, 0, 3, 5],
78− result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>"
79− },
80− {
81− text: "Pastel",
82− highlights: [5, 5],
83− result: "Paste<font color=\"#ffffff\">l</font>"
84− },
85− {
86− text: "Two Words",
87− highlights: [1, 2, 5, 5],
88− result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds"
89− }
90− ]
91− }
92−
93− function test_highlightedText(data) {
94− var hText = result.highlightedText(data.text, data.highlights);
95− compare(hText, data.result);
96− }
97− }
98−}