Merge lp:~nick-dedekind/unity8/desktop_menus.gmenumodel into lp:unity8
- desktop_menus.gmenumodel
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~nick-dedekind/unity8/desktop_menus.gmenumodel |
Merge into: | lp:unity8 |
Diff against target: |
3885 lines (+3069/-96) 44 files modified
CMakeLists.txt (+1/-1) debian/control (+2/-2) plugins/Utils/CMakeLists.txt (+1/-0) plugins/Utils/constants.cpp (+1/-0) plugins/Utils/constants.h (+3/-0) plugins/Utils/plugin.cpp (+2/-0) plugins/Utils/shortcutaction.cpp (+122/-0) plugins/Utils/shortcutaction.h (+44/-0) plugins/Utils/windowkeysfilter.cpp (+11/-6) plugins/Utils/windowkeysfilter.h (+1/-1) qml/ApplicationMenus/AppMenuUtils.js (+107/-0) qml/ApplicationMenus/MenuBar.qml (+245/-0) qml/ApplicationMenus/MenuBarItem.qml (+56/-0) qml/ApplicationMenus/MenuBase.qml (+116/-0) qml/ApplicationMenus/MenuItemBase.qml (+32/-0) qml/ApplicationMenus/MenuItemDelegate.qml (+49/-0) qml/ApplicationMenus/MenuItemDelegateBase.qml (+82/-0) qml/ApplicationMenus/MenuItemFactory.qml (+240/-0) qml/ApplicationMenus/MenuPage.qml (+277/-0) qml/CMakeLists.txt (+1/-0) qml/Components/PanelState/PanelState.qml (+2/-1) qml/Panel/Panel.qml (+91/-7) qml/Stages/DecoratedWindow.qml (+50/-16) qml/Stages/DesktopStage.qml (+10/-3) qml/Stages/WindowDecoration.qml (+117/-45) tests/imports/check_imports.py (+2/-1) tests/mocks/QMenuModel/QMenuModel.qmltypes (+5/-1) tests/mocks/QMenuModel/unitymenumodel.cpp (+25/-3) tests/mocks/QMenuModel/unitymenumodel.h (+2/-0) tests/mocks/Unity/Application/MirSurface.cpp (+10/-0) tests/mocks/Unity/Application/MirSurface.h (+3/-0) tests/mocks/Utils/CMakeLists.txt (+1/-0) tests/mocks/Utils/constants.cpp (+7/-0) tests/mocks/Utils/constants.h (+7/-0) tests/mocks/Utils/plugin.cpp (+2/-0) tests/qmltests/ApplicationMenus/tst_MenuBar.qml (+132/-0) tests/qmltests/ApplicationMenus/tst_MenuPage.qml (+256/-0) tests/qmltests/CMakeLists.txt (+3/-0) tests/qmltests/Panel/tst_Panel.qml (+56/-4) tests/qmltests/Stages/ApplicationCheckBox.qml (+4/-0) tests/qmltests/Stages/DesktopMenuData.qml (+702/-0) tests/qmltests/Stages/tst_DesktopStage.qml (+13/-1) tests/qmltests/Stages/tst_WindowDecoration.qml (+163/-0) tests/qmltests/tst_Shell.qml (+13/-4) |
To merge this branch: | bzr merge lp:~nick-dedekind/unity8/desktop_menus.gmenumodel |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Unity8 CI Bot | continuous-integration | Needs Fixing | |
Unity Team | Pending | ||
Review via email: mp+282727@code.launchpad.net |
Commit message
Desktop Menus
Description of the change
Desktop Menus
- 2110. By Nick Dedekind
-
updated control
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2110
https:/
Executed test runs:
Click here to trigger a rebuild:
https:/
- 2111. By Nick Dedekind
-
merged with trunk
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2111
https:/
Executed test runs:
Click here to trigger a rebuild:
https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2110
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2111
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
- 2111. By Nick Dedekind
-
merged with trunk
- 2110. By Nick Dedekind
-
updated control
- 2109. By Nick Dedekind
-
desktop menus
- 2108. By Launchpad Translations on behalf of unity-team
-
Launchpad automatic translations update.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-12-16 13:58:39 +0000 | |||
3 | +++ CMakeLists.txt 2016-01-15 13:11:04 +0000 | |||
4 | @@ -57,7 +57,7 @@ | |||
5 | 57 | find_package(Qt5Concurrent 5.4 REQUIRED) | 57 | find_package(Qt5Concurrent 5.4 REQUIRED) |
6 | 58 | find_package(Qt5Sql 5.4 REQUIRED) | 58 | find_package(Qt5Sql 5.4 REQUIRED) |
7 | 59 | 59 | ||
9 | 60 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=12) | 60 | pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=13) |
10 | 61 | 61 | ||
11 | 62 | # Standard install paths | 62 | # Standard install paths |
12 | 63 | include(GNUInstallDirs) | 63 | include(GNUInstallDirs) |
13 | 64 | 64 | ||
14 | === modified file 'debian/control' | |||
15 | --- debian/control 2016-01-11 17:37:16 +0000 | |||
16 | +++ debian/control 2016-01-15 13:11:04 +0000 | |||
17 | @@ -29,7 +29,7 @@ | |||
18 | 29 | libqt5xmlpatterns5-dev, | 29 | libqt5xmlpatterns5-dev, |
19 | 30 | libsystemsettings-dev, | 30 | libsystemsettings-dev, |
20 | 31 | libudev-dev, | 31 | libudev-dev, |
22 | 32 | libunity-api-dev (>= 7.105), | 32 | libunity-api-dev (>= 7.106), |
23 | 33 | libusermetricsoutput1-dev, | 33 | libusermetricsoutput1-dev, |
24 | 34 | # Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop | 34 | # Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop |
25 | 35 | libx11-dev[!armhf], | 35 | libx11-dev[!armhf], |
26 | @@ -102,7 +102,7 @@ | |||
27 | 102 | qml-module-qtquick-xmllistmodel, | 102 | qml-module-qtquick-xmllistmodel, |
28 | 103 | qml-module-qtsysteminfo, | 103 | qml-module-qtsysteminfo, |
29 | 104 | qtdeclarative5-gsettings1.0, | 104 | qtdeclarative5-gsettings1.0, |
31 | 105 | qtdeclarative5-qtmir-plugin (>= 0.4.5), | 105 | qtdeclarative5-qtmir-plugin (>= 0.4.7), |
32 | 106 | qtdeclarative5-ubuntu-telephony0.1, | 106 | qtdeclarative5-ubuntu-telephony0.1, |
33 | 107 | qtdeclarative5-ubuntu-web-plugin, | 107 | qtdeclarative5-ubuntu-web-plugin, |
34 | 108 | ubuntu-system-settings, | 108 | ubuntu-system-settings, |
35 | 109 | 109 | ||
36 | === modified file 'plugins/Utils/CMakeLists.txt' | |||
37 | --- plugins/Utils/CMakeLists.txt 2015-10-28 10:32:47 +0000 | |||
38 | +++ plugins/Utils/CMakeLists.txt 2016-01-15 13:11:04 +0000 | |||
39 | @@ -24,6 +24,7 @@ | |||
40 | 24 | easingcurve.cpp | 24 | easingcurve.cpp |
41 | 25 | windowstatestorage.cpp | 25 | windowstatestorage.cpp |
42 | 26 | timezoneFormatter.cpp | 26 | timezoneFormatter.cpp |
43 | 27 | shortcutaction.cpp | ||
44 | 27 | plugin.cpp | 28 | plugin.cpp |
45 | 28 | ) | 29 | ) |
46 | 29 | 30 | ||
47 | 30 | 31 | ||
48 | === modified file 'plugins/Utils/constants.cpp' | |||
49 | --- plugins/Utils/constants.cpp 2015-11-20 15:01:39 +0000 | |||
50 | +++ plugins/Utils/constants.cpp 2016-01-15 13:11:04 +0000 | |||
51 | @@ -24,4 +24,5 @@ | |||
52 | 24 | } else { | 24 | } else { |
53 | 25 | m_indicatorValueTimeout = 5000; | 25 | m_indicatorValueTimeout = 5000; |
54 | 26 | } | 26 | } |
55 | 27 | m_menuHoverOpenInterval = 250; | ||
56 | 27 | } | 28 | } |
57 | 28 | 29 | ||
58 | === modified file 'plugins/Utils/constants.h' | |||
59 | --- plugins/Utils/constants.h 2015-03-11 08:07:31 +0000 | |||
60 | +++ plugins/Utils/constants.h 2016-01-15 13:11:04 +0000 | |||
61 | @@ -30,14 +30,17 @@ | |||
62 | 30 | { | 30 | { |
63 | 31 | Q_OBJECT | 31 | Q_OBJECT |
64 | 32 | Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT) | 32 | Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT) |
65 | 33 | Q_PROPERTY(int menuHoverOpenInterval READ menuHoverOpenInterval CONSTANT) | ||
66 | 33 | 34 | ||
67 | 34 | public: | 35 | public: |
68 | 35 | Constants(QObject *parent = 0); | 36 | Constants(QObject *parent = 0); |
69 | 36 | 37 | ||
70 | 37 | int indicatorValueTimeout() const { return m_indicatorValueTimeout; } | 38 | int indicatorValueTimeout() const { return m_indicatorValueTimeout; } |
71 | 39 | int menuHoverOpenInterval() const { return m_menuHoverOpenInterval; } | ||
72 | 38 | 40 | ||
73 | 39 | private: | 41 | private: |
74 | 40 | int m_indicatorValueTimeout; | 42 | int m_indicatorValueTimeout; |
75 | 43 | int m_menuHoverOpenInterval; | ||
76 | 41 | }; | 44 | }; |
77 | 42 | 45 | ||
78 | 43 | #endif | 46 | #endif |
79 | 44 | 47 | ||
80 | === modified file 'plugins/Utils/plugin.cpp' | |||
81 | --- plugins/Utils/plugin.cpp 2015-10-26 16:47:52 +0000 | |||
82 | +++ plugins/Utils/plugin.cpp 2016-01-15 13:11:04 +0000 | |||
83 | @@ -36,6 +36,7 @@ | |||
84 | 36 | #include "constants.h" | 36 | #include "constants.h" |
85 | 37 | #include "timezoneFormatter.h" | 37 | #include "timezoneFormatter.h" |
86 | 38 | #include "applicationsfiltermodel.h" | 38 | #include "applicationsfiltermodel.h" |
87 | 39 | #include "shortcutaction.h" | ||
88 | 39 | 40 | ||
89 | 40 | static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine) | 41 | static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine) |
90 | 41 | { | 42 | { |
91 | @@ -68,6 +69,7 @@ | |||
92 | 68 | [](QQmlEngine*, QJSEngine*) -> QObject* { return new TimezoneFormatter; }); | 69 | [](QQmlEngine*, QJSEngine*) -> QObject* { return new TimezoneFormatter; }); |
93 | 69 | qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger"); | 70 | qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger"); |
94 | 70 | qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel"); | 71 | qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel"); |
95 | 72 | qmlRegisterType<ShortcutAction>(uri, 0, 1, "ShortcutAction"); | ||
96 | 71 | } | 73 | } |
97 | 72 | 74 | ||
98 | 73 | void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 75 | void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
99 | 74 | 76 | ||
100 | === added file 'plugins/Utils/shortcutaction.cpp' | |||
101 | --- plugins/Utils/shortcutaction.cpp 1970-01-01 00:00:00 +0000 | |||
102 | +++ plugins/Utils/shortcutaction.cpp 2016-01-15 13:11:04 +0000 | |||
103 | @@ -0,0 +1,122 @@ | |||
104 | 1 | #include "shortcutaction.h" | ||
105 | 2 | |||
106 | 3 | #include <QQuickItem> | ||
107 | 4 | #include <QQuickWindow> | ||
108 | 5 | #include <QVariant> | ||
109 | 6 | #include <QShortcutEvent> | ||
110 | 7 | #include <private/qguiapplication_p.h> | ||
111 | 8 | |||
112 | 9 | namespace { | ||
113 | 10 | |||
114 | 11 | bool qShortcutContextMatcher(QObject *o, Qt::ShortcutContext context) | ||
115 | 12 | { | ||
116 | 13 | if (!static_cast<ShortcutAction*>(o)->isEnabled()) | ||
117 | 14 | return false; | ||
118 | 15 | |||
119 | 16 | switch (context) { | ||
120 | 17 | case Qt::ApplicationShortcut: | ||
121 | 18 | case Qt::WindowShortcut: | ||
122 | 19 | break; | ||
123 | 20 | case Qt::WidgetShortcut: { | ||
124 | 21 | QQuickItem* target = static_cast<ShortcutAction*>(o)->target(); | ||
125 | 22 | if (target && target->hasActiveFocus()) { | ||
126 | 23 | return true; | ||
127 | 24 | } | ||
128 | 25 | return true; | ||
129 | 26 | } | ||
130 | 27 | case Qt::WidgetWithChildrenShortcut: | ||
131 | 28 | break; | ||
132 | 29 | } | ||
133 | 30 | |||
134 | 31 | return false; | ||
135 | 32 | } | ||
136 | 33 | |||
137 | 34 | } | ||
138 | 35 | |||
139 | 36 | |||
140 | 37 | ShortcutAction::ShortcutAction(QObject* parent) | ||
141 | 38 | : QObject(parent) | ||
142 | 39 | , m_enabled(true) | ||
143 | 40 | { | ||
144 | 41 | } | ||
145 | 42 | |||
146 | 43 | ShortcutAction::~ShortcutAction() | ||
147 | 44 | { | ||
148 | 45 | setShortcut(QString()); | ||
149 | 46 | } | ||
150 | 47 | |||
151 | 48 | QVariant ShortcutAction::shortcut() const | ||
152 | 49 | { | ||
153 | 50 | return m_shortcut.toString(QKeySequence::NativeText); | ||
154 | 51 | } | ||
155 | 52 | |||
156 | 53 | void ShortcutAction::setShortcut(const QVariant &arg) | ||
157 | 54 | { | ||
158 | 55 | QKeySequence sequence; | ||
159 | 56 | if (arg.type() == QVariant::Int) | ||
160 | 57 | sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(arg.toInt())); | ||
161 | 58 | else | ||
162 | 59 | sequence = QKeySequence::fromString(arg.toString()); | ||
163 | 60 | |||
164 | 61 | if (sequence == m_shortcut) | ||
165 | 62 | return; | ||
166 | 63 | |||
167 | 64 | if (!m_shortcut.isEmpty()) | ||
168 | 65 | QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, m_shortcut); | ||
169 | 66 | |||
170 | 67 | m_shortcut = sequence; | ||
171 | 68 | |||
172 | 69 | if (!m_shortcut.isEmpty()) { | ||
173 | 70 | Qt::ShortcutContext context = Qt::WidgetShortcut; | ||
174 | 71 | QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, m_shortcut, context, qShortcutContextMatcher); | ||
175 | 72 | } | ||
176 | 73 | Q_EMIT shortcutChanged(shortcut()); | ||
177 | 74 | } | ||
178 | 75 | |||
179 | 76 | void ShortcutAction::setEnabled(bool e) | ||
180 | 77 | { | ||
181 | 78 | if (e == m_enabled) return; | ||
182 | 79 | m_enabled = e; | ||
183 | 80 | |||
184 | 81 | Q_EMIT enabledChanged(); | ||
185 | 82 | } | ||
186 | 83 | |||
187 | 84 | void ShortcutAction::setTarget(QQuickItem *target) | ||
188 | 85 | { | ||
189 | 86 | if (target == m_target) return; | ||
190 | 87 | m_target = target; | ||
191 | 88 | |||
192 | 89 | Q_EMIT targetChanged(); | ||
193 | 90 | } | ||
194 | 91 | |||
195 | 92 | bool ShortcutAction::event(QEvent *e) | ||
196 | 93 | { | ||
197 | 94 | if (!m_enabled) | ||
198 | 95 | return false; | ||
199 | 96 | |||
200 | 97 | if (e->type() != QEvent::Shortcut) | ||
201 | 98 | return false; | ||
202 | 99 | |||
203 | 100 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | ||
204 | 101 | |||
205 | 102 | Q_ASSERT_X(se->key() == m_shortcut, | ||
206 | 103 | "QQuickAction::event", | ||
207 | 104 | "Received shortcut event from incorrect shortcut"); | ||
208 | 105 | if (se->isAmbiguous()) { | ||
209 | 106 | qWarning("QQuickAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); | ||
210 | 107 | return false; | ||
211 | 108 | } | ||
212 | 109 | |||
213 | 110 | trigger(); | ||
214 | 111 | |||
215 | 112 | return true; | ||
216 | 113 | } | ||
217 | 114 | |||
218 | 115 | void ShortcutAction::trigger(QObject* source) | ||
219 | 116 | { | ||
220 | 117 | if (!m_enabled) | ||
221 | 118 | return; | ||
222 | 119 | |||
223 | 120 | Q_EMIT triggered(source); | ||
224 | 121 | } | ||
225 | 122 | |||
226 | 0 | 123 | ||
227 | === added file 'plugins/Utils/shortcutaction.h' | |||
228 | --- plugins/Utils/shortcutaction.h 1970-01-01 00:00:00 +0000 | |||
229 | +++ plugins/Utils/shortcutaction.h 2016-01-15 13:11:04 +0000 | |||
230 | @@ -0,0 +1,44 @@ | |||
231 | 1 | #ifndef SHORTCUTACTION_H | ||
232 | 2 | #define SHORTCUTACTION_H | ||
233 | 3 | |||
234 | 4 | #include <QObject> | ||
235 | 5 | #include <QKeySequence> | ||
236 | 6 | #include <QQuickItem> | ||
237 | 7 | |||
238 | 8 | class ShortcutAction : public QObject | ||
239 | 9 | { | ||
240 | 10 | Q_OBJECT | ||
241 | 11 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) | ||
242 | 12 | Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) | ||
243 | 13 | Q_PROPERTY(QQuickItem* target READ target WRITE setTarget NOTIFY targetChanged) | ||
244 | 14 | |||
245 | 15 | public: | ||
246 | 16 | ShortcutAction(QObject* parent = nullptr); | ||
247 | 17 | ~ShortcutAction(); | ||
248 | 18 | |||
249 | 19 | QVariant shortcut() const; | ||
250 | 20 | void setShortcut(const QVariant &shortcut); | ||
251 | 21 | |||
252 | 22 | bool isEnabled() const { return m_enabled; } | ||
253 | 23 | void setEnabled(bool e); | ||
254 | 24 | |||
255 | 25 | QQuickItem* target() const { return m_target; } | ||
256 | 26 | void setTarget(QQuickItem* target); | ||
257 | 27 | |||
258 | 28 | bool event(QEvent *e) override; | ||
259 | 29 | |||
260 | 30 | void trigger(QObject* source = nullptr); | ||
261 | 31 | |||
262 | 32 | Q_SIGNALS: | ||
263 | 33 | void targetChanged(); | ||
264 | 34 | void enabledChanged(); | ||
265 | 35 | void triggered(QObject* source = nullptr); | ||
266 | 36 | void shortcutChanged(QVariant shortcut); | ||
267 | 37 | |||
268 | 38 | private: | ||
269 | 39 | QKeySequence m_shortcut; | ||
270 | 40 | bool m_enabled; | ||
271 | 41 | QQuickItem* m_target; | ||
272 | 42 | }; | ||
273 | 43 | |||
274 | 44 | #endif // SHORTCUTACTION_H | ||
275 | 0 | 45 | ||
276 | === modified file 'plugins/Utils/windowkeysfilter.cpp' | |||
277 | --- plugins/Utils/windowkeysfilter.cpp 2015-10-22 17:37:26 +0000 | |||
278 | +++ plugins/Utils/windowkeysfilter.cpp 2016-01-15 13:11:04 +0000 | |||
279 | @@ -24,12 +24,14 @@ | |||
280 | 24 | : QQuickItem(parent), | 24 | : QQuickItem(parent), |
281 | 25 | m_currentEventTimestamp(0) | 25 | m_currentEventTimestamp(0) |
282 | 26 | { | 26 | { |
285 | 27 | connect(this, &QQuickItem::windowChanged, | 27 | connect(this, &QQuickItem::windowChanged, this, &WindowKeysFilter::setupFilter); |
286 | 28 | this, &WindowKeysFilter::setupFilterOnWindow); | 28 | connect(this, &QQuickItem::enabledChanged, this, &WindowKeysFilter::setupFilter); |
287 | 29 | } | 29 | } |
288 | 30 | 30 | ||
289 | 31 | bool WindowKeysFilter::eventFilter(QObject *watched, QEvent *event) | 31 | bool WindowKeysFilter::eventFilter(QObject *watched, QEvent *event) |
290 | 32 | { | 32 | { |
291 | 33 | if (!isEnabled()) return false; | ||
292 | 34 | |||
293 | 33 | Q_ASSERT(!m_filteredWindow.isNull()); | 35 | Q_ASSERT(!m_filteredWindow.isNull()); |
294 | 34 | Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data())); | 36 | Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data())); |
295 | 35 | Q_UNUSED(watched); | 37 | Q_UNUSED(watched); |
296 | @@ -53,16 +55,19 @@ | |||
297 | 53 | } | 55 | } |
298 | 54 | } | 56 | } |
299 | 55 | 57 | ||
301 | 56 | void WindowKeysFilter::setupFilterOnWindow(QQuickWindow *window) | 58 | void WindowKeysFilter::setupFilter() |
302 | 57 | { | 59 | { |
303 | 60 | if (!m_filteredWindow.isNull() == isEnabled() && m_filteredWindow.data() == window()) return; | ||
304 | 61 | |||
305 | 58 | if (!m_filteredWindow.isNull()) { | 62 | if (!m_filteredWindow.isNull()) { |
306 | 59 | m_filteredWindow->removeEventFilter(this); | 63 | m_filteredWindow->removeEventFilter(this); |
307 | 60 | m_filteredWindow.clear(); | 64 | m_filteredWindow.clear(); |
308 | 61 | } | 65 | } |
309 | 62 | 66 | ||
313 | 63 | if (window) { | 67 | QQuickWindow *wnd = window(); |
314 | 64 | window->installEventFilter(this); | 68 | if (wnd && isEnabled()) { |
315 | 65 | m_filteredWindow = window; | 69 | wnd->installEventFilter(this); |
316 | 70 | m_filteredWindow = wnd; | ||
317 | 66 | } | 71 | } |
318 | 67 | } | 72 | } |
319 | 68 | 73 | ||
320 | 69 | 74 | ||
321 | === modified file 'plugins/Utils/windowkeysfilter.h' | |||
322 | --- plugins/Utils/windowkeysfilter.h 2015-10-22 17:37:26 +0000 | |||
323 | +++ plugins/Utils/windowkeysfilter.h 2016-01-15 13:11:04 +0000 | |||
324 | @@ -48,7 +48,7 @@ | |||
325 | 48 | void currentEventTimestampChanged(); | 48 | void currentEventTimestampChanged(); |
326 | 49 | 49 | ||
327 | 50 | private Q_SLOTS: | 50 | private Q_SLOTS: |
329 | 51 | void setupFilterOnWindow(QQuickWindow *window); | 51 | void setupFilter(); |
330 | 52 | 52 | ||
331 | 53 | private: | 53 | private: |
332 | 54 | QPointer<QQuickWindow> m_filteredWindow; | 54 | QPointer<QQuickWindow> m_filteredWindow; |
333 | 55 | 55 | ||
334 | === added directory 'qml/ApplicationMenus' | |||
335 | === added file 'qml/ApplicationMenus/AppMenuUtils.js' | |||
336 | --- qml/ApplicationMenus/AppMenuUtils.js 1970-01-01 00:00:00 +0000 | |||
337 | +++ qml/ApplicationMenus/AppMenuUtils.js 2016-01-15 13:11:04 +0000 | |||
338 | @@ -0,0 +1,107 @@ | |||
339 | 1 | /* | ||
340 | 2 | * Copyright 2015 Canonical Ltd. | ||
341 | 3 | * | ||
342 | 4 | * This program is free software; you can redistribute it and/or modify | ||
343 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
344 | 6 | * the Free Software Foundation; version 3. | ||
345 | 7 | * | ||
346 | 8 | * This program is distributed in the hope that it will be useful, | ||
347 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
348 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
349 | 11 | * GNU Lesser General Public License for more details. | ||
350 | 12 | * | ||
351 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
352 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
353 | 15 | */ | ||
354 | 16 | |||
355 | 17 | .pragma library | ||
356 | 18 | |||
357 | 19 | String.prototype.htmlLabelFromMenuLabel = function (underline) { | ||
358 | 20 | var replacements = [ | ||
359 | 21 | { | ||
360 | 22 | char: "_", | ||
361 | 23 | searchExpr: /_/g, | ||
362 | 24 | doubleReplacement: "_" | ||
363 | 25 | }, { | ||
364 | 26 | char: "&", | ||
365 | 27 | searchExpr: /&(?!amp;)/g, | ||
366 | 28 | doubleReplacement: "&" | ||
367 | 29 | } | ||
368 | 30 | ]; | ||
369 | 31 | var text = this; | ||
370 | 32 | |||
371 | 33 | var i = 0; | ||
372 | 34 | for (; i < replacements.length; i++) { | ||
373 | 35 | text = parseShortcutChararacter(text, underline, replacements[i]); | ||
374 | 36 | } | ||
375 | 37 | return text; | ||
376 | 38 | } | ||
377 | 39 | |||
378 | 40 | function parseShortcutChararacter(text, underline, replacement) { | ||
379 | 41 | text = text.replace(new RegExp(replacement.char + replacement.char, "g"), replacement.doubleReplacement); | ||
380 | 42 | |||
381 | 43 | if (!underline) { | ||
382 | 44 | return text.replace(replacement.searchExpr, ""); | ||
383 | 45 | } | ||
384 | 46 | |||
385 | 47 | var original = text; | ||
386 | 48 | var output = ""; | ||
387 | 49 | var current = 0 | ||
388 | 50 | var next = text.search(replacement.searchExpr); | ||
389 | 51 | if (next === -1) return text; | ||
390 | 52 | |||
391 | 53 | while (next !== -1) { | ||
392 | 54 | output += text.slice(current, next); | ||
393 | 55 | current = next+1; | ||
394 | 56 | |||
395 | 57 | var rest = text.slice(current); | ||
396 | 58 | text = "<u>" + rest[0] + "</u>" + rest.slice(1); | ||
397 | 59 | next = text.search(replacement.searchExpr); | ||
398 | 60 | } | ||
399 | 61 | output += text; | ||
400 | 62 | return output; | ||
401 | 63 | } | ||
402 | 64 | |||
403 | 65 | String.prototype.actionKeyFromMenuLabel = function () { | ||
404 | 66 | var replacements = [ | ||
405 | 67 | { | ||
406 | 68 | char: "_", | ||
407 | 69 | searchExpr: /_/g, | ||
408 | 70 | doubleReplacement: "_" | ||
409 | 71 | }, { | ||
410 | 72 | char: "&", | ||
411 | 73 | searchExpr: /&(?!amp;)/g, | ||
412 | 74 | doubleReplacement: "&" | ||
413 | 75 | } | ||
414 | 76 | ]; | ||
415 | 77 | var text = this; | ||
416 | 78 | |||
417 | 79 | var i = 0; | ||
418 | 80 | var replaced = false; | ||
419 | 81 | for (; i < replacements.length; i++) { | ||
420 | 82 | var actionKey = parseActionKeyChararacter(text, replacements[i]); | ||
421 | 83 | if (actionKey !== "") return actionKey; | ||
422 | 84 | } | ||
423 | 85 | return ""; | ||
424 | 86 | } | ||
425 | 87 | |||
426 | 88 | function parseActionKeyChararacter(original, replacement) { | ||
427 | 89 | var text = original.replace(new RegExp(replacement.char + replacement.char, "g"), replacement.doubleReplacement); | ||
428 | 90 | |||
429 | 91 | var output = ""; | ||
430 | 92 | var iter = 0; | ||
431 | 93 | var next = text.search(replacement.searchExpr); | ||
432 | 94 | if (next === -1) return ""; | ||
433 | 95 | |||
434 | 96 | while (next !== -1) { | ||
435 | 97 | var char = text.slice(next+1, next+2); | ||
436 | 98 | if (char === "") break; | ||
437 | 99 | |||
438 | 100 | if (iter > 0) output += "+"; | ||
439 | 101 | output += char; | ||
440 | 102 | |||
441 | 103 | text = text.slice(next+2); | ||
442 | 104 | next = text.search(replacement.searchExpr) | ||
443 | 105 | } | ||
444 | 106 | return output; | ||
445 | 107 | } | ||
446 | 0 | 108 | ||
447 | === added file 'qml/ApplicationMenus/MenuBar.qml' | |||
448 | --- qml/ApplicationMenus/MenuBar.qml 1970-01-01 00:00:00 +0000 | |||
449 | +++ qml/ApplicationMenus/MenuBar.qml 2016-01-15 13:11:04 +0000 | |||
450 | @@ -0,0 +1,245 @@ | |||
451 | 1 | /* | ||
452 | 2 | * Copyright 2015 Canonical Ltd. | ||
453 | 3 | * | ||
454 | 4 | * This program is free software; you can redistribute it and/or modify | ||
455 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
456 | 6 | * the Free Software Foundation; version 3. | ||
457 | 7 | * | ||
458 | 8 | * This program is distributed in the hope that it will be useful, | ||
459 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
460 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
461 | 11 | * GNU Lesser General Public License for more details. | ||
462 | 12 | * | ||
463 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
464 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
465 | 15 | */ | ||
466 | 16 | |||
467 | 17 | import QtQuick 2.4 | ||
468 | 18 | import QtQuick.Layouts 1.1 | ||
469 | 19 | import Ubuntu.Components 1.3 | ||
470 | 20 | |||
471 | 21 | MenuBase { | ||
472 | 22 | id: root | ||
473 | 23 | objectName: "menuBar" | ||
474 | 24 | |||
475 | 25 | property var focusWindow: undefined | ||
476 | 26 | property alias menuModel: rootDelegate.menuModel | ||
477 | 27 | implicitWidth: listView.width | ||
478 | 28 | readonly property bool hasChildren: repeater.count > 0 | ||
479 | 29 | submenuOffset: -units.gu(1) | ||
480 | 30 | |||
481 | 31 | function close() { | ||
482 | 32 | closePopup(); | ||
483 | 33 | listView.selectedItem = undefined; | ||
484 | 34 | } | ||
485 | 35 | |||
486 | 36 | FocusScope { | ||
487 | 37 | id: scope | ||
488 | 38 | anchors { | ||
489 | 39 | left: parent.left | ||
490 | 40 | } | ||
491 | 41 | width: listView.width | ||
492 | 42 | height: parent.height | ||
493 | 43 | |||
494 | 44 | Keys.onLeftPressed: listView.selectPrevious() | ||
495 | 45 | Keys.onRightPressed: listView.selectNext() | ||
496 | 46 | Keys.onEscapePressed: { | ||
497 | 47 | focus = false; | ||
498 | 48 | if (focusWindow !== undefined) { | ||
499 | 49 | focusWindow.forceActiveFocus(); | ||
500 | 50 | } | ||
501 | 51 | } | ||
502 | 52 | |||
503 | 53 | onFocusChanged: { | ||
504 | 54 | if (!focus && root.openItem) { | ||
505 | 55 | root.close(); | ||
506 | 56 | } | ||
507 | 57 | } | ||
508 | 58 | |||
509 | 59 | InverseMouseArea { | ||
510 | 60 | enabled: root.openItem !== undefined | ||
511 | 61 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton | ||
512 | 62 | anchors.fill: parent | ||
513 | 63 | |||
514 | 64 | onPressed: { | ||
515 | 65 | // stop the inverse mouse area stealing events from mouse areas under. | ||
516 | 66 | mouse.accepted = false; | ||
517 | 67 | root.close(); | ||
518 | 68 | } | ||
519 | 69 | } | ||
520 | 70 | |||
521 | 71 | MenuItemDelegateBase { | ||
522 | 72 | id: rootDelegate | ||
523 | 73 | focusWindow: root.focusWindow | ||
524 | 74 | } | ||
525 | 75 | |||
526 | 76 | Row { | ||
527 | 77 | id: listView | ||
528 | 78 | anchors.left: parent.left | ||
529 | 79 | height: parent.height | ||
530 | 80 | spacing: units.gu(2) | ||
531 | 81 | |||
532 | 82 | property var selectedItem: undefined | ||
533 | 83 | |||
534 | 84 | function selectNext() { | ||
535 | 85 | var delegate; | ||
536 | 86 | var newIndex = 0; | ||
537 | 87 | if (listView.selectedItem === undefined && repeater.count > 0) { | ||
538 | 88 | while (repeater.count > newIndex) { | ||
539 | 89 | delegate = repeater.itemAt(newIndex++); | ||
540 | 90 | if (delegate.enabled) { | ||
541 | 91 | delegate.selected = true; | ||
542 | 92 | break; | ||
543 | 93 | } | ||
544 | 94 | } | ||
545 | 95 | } else if (listView.selectedItem !== undefined && repeater.count > 1) { | ||
546 | 96 | var startIndex = (listView.selectedItem.ownIndex + 1) % repeater.count; | ||
547 | 97 | newIndex = startIndex; | ||
548 | 98 | do { | ||
549 | 99 | delegate = repeater.itemAt(newIndex); | ||
550 | 100 | if (delegate.enabled) { | ||
551 | 101 | delegate.selected = true; | ||
552 | 102 | break; | ||
553 | 103 | } | ||
554 | 104 | newIndex = (newIndex + 1) % repeater.count; | ||
555 | 105 | } while (newIndex !== startIndex) | ||
556 | 106 | } | ||
557 | 107 | } | ||
558 | 108 | |||
559 | 109 | function selectPrevious() { | ||
560 | 110 | var delegate; | ||
561 | 111 | var newIndex = repeater.count-1; | ||
562 | 112 | if (listView.selectedItem === undefined && repeater.count > 0) { | ||
563 | 113 | while (repeater.count > newIndex) { | ||
564 | 114 | delegate = repeater.itemAt(newIndex--); | ||
565 | 115 | if (delegate.enabled) { | ||
566 | 116 | delegate.selected = true; | ||
567 | 117 | break; | ||
568 | 118 | } | ||
569 | 119 | } | ||
570 | 120 | } else if (listView.selectedItem !== undefined && repeater.count > 1) { | ||
571 | 121 | var startIndex = listView.selectedItem.ownIndex - 1; | ||
572 | 122 | newIndex = startIndex; | ||
573 | 123 | do { | ||
574 | 124 | if (newIndex < 0) newIndex = repeater.count - 1; | ||
575 | 125 | delegate = repeater.itemAt(newIndex--); | ||
576 | 126 | if (delegate.enabled) { | ||
577 | 127 | delegate.selected = true; | ||
578 | 128 | break; | ||
579 | 129 | } | ||
580 | 130 | } while (newIndex !== startIndex) | ||
581 | 131 | } | ||
582 | 132 | } | ||
583 | 133 | |||
584 | 134 | Repeater { | ||
585 | 135 | id: repeater | ||
586 | 136 | model: rootDelegate.submenuItems | ||
587 | 137 | |||
588 | 138 | MenuBarItem { | ||
589 | 139 | id: repeaterItem | ||
590 | 140 | height: listView.height | ||
591 | 141 | |||
592 | 142 | enableMnemonic: root.enableMnemonic | ||
593 | 143 | menuItemDelegate: model.delegate | ||
594 | 144 | |||
595 | 145 | property int modelIndex: index | ||
596 | 146 | property bool selected: false | ||
597 | 147 | enabled: model.delegate.sensitive && !model.delegate.isSeparator | ||
598 | 148 | |||
599 | 149 | Rectangle { | ||
600 | 150 | anchors { | ||
601 | 151 | left: parent.left | ||
602 | 152 | right: parent.right | ||
603 | 153 | bottom: parent.bottom | ||
604 | 154 | leftMargin: -units.gu(1) | ||
605 | 155 | rightMargin: -units.gu(1) | ||
606 | 156 | } | ||
607 | 157 | height: units.dp(4) | ||
608 | 158 | color: "#E95420" | ||
609 | 159 | visible: root.openItem == menuItem | ||
610 | 160 | } | ||
611 | 161 | |||
612 | 162 | MenuItemBase { | ||
613 | 163 | id: menuItem | ||
614 | 164 | objectName: root.objectName + "-menu" + index | ||
615 | 165 | property int ownIndex: index | ||
616 | 166 | |||
617 | 167 | anchors.fill: parent | ||
618 | 168 | delegate: model.delegate | ||
619 | 169 | |||
620 | 170 | mnemonicAction { | ||
621 | 171 | property string action: model.delegate.label.actionKeyFromMenuLabel() | ||
622 | 172 | enabled: enableMnemonic && repeaterItem.enabled | ||
623 | 173 | shortcut: action !== "" ? "Alt+" + action : "" | ||
624 | 174 | |||
625 | 175 | onTriggered: { | ||
626 | 176 | if (model.delegate.hasSubmenu) { | ||
627 | 177 | root.open(menuItem, true); | ||
628 | 178 | } | ||
629 | 179 | else { | ||
630 | 180 | model.delegate.activate(); | ||
631 | 181 | } | ||
632 | 182 | } | ||
633 | 183 | } | ||
634 | 184 | } | ||
635 | 185 | |||
636 | 186 | MouseArea { | ||
637 | 187 | id: titleMouseArea | ||
638 | 188 | anchors.fill: parent | ||
639 | 189 | hoverEnabled: listView.selectedItem !== undefined | ||
640 | 190 | |||
641 | 191 | onEntered: { | ||
642 | 192 | if (listView.selectedItem !== undefined && !repeaterItem.selected) { | ||
643 | 193 | repeaterItem.selected = true; | ||
644 | 194 | } | ||
645 | 195 | } | ||
646 | 196 | onClicked: { | ||
647 | 197 | if (model.delegate.hasSubmenu) { | ||
648 | 198 | root.open(menuItem, true); | ||
649 | 199 | } | ||
650 | 200 | else if (root.enabled) { | ||
651 | 201 | model.delegate.activate() | ||
652 | 202 | } | ||
653 | 203 | } | ||
654 | 204 | } | ||
655 | 205 | |||
656 | 206 | onSelectedChanged: { | ||
657 | 207 | if (selected) { | ||
658 | 208 | listView.selectedItem = menuItem; | ||
659 | 209 | if (model.delegate.hasSubmenu && root.openItem !== menuItem) { | ||
660 | 210 | root.open(menuItem, true); | ||
661 | 211 | } | ||
662 | 212 | } | ||
663 | 213 | else if (listView.selectedItem === menuItem) { | ||
664 | 214 | listView.selectedItem = undefined; | ||
665 | 215 | if (root.openItem == menuItem) { | ||
666 | 216 | root.closePopup(); | ||
667 | 217 | } | ||
668 | 218 | } | ||
669 | 219 | } | ||
670 | 220 | |||
671 | 221 | Connections { | ||
672 | 222 | target: listView | ||
673 | 223 | onSelectedItemChanged: { | ||
674 | 224 | if (repeaterItem.selected && (listView.selectedItem === undefined || listView.selectedItem !== menuItem)) { | ||
675 | 225 | repeaterItem.selected = false; | ||
676 | 226 | if (root.openItem == menuItem) { | ||
677 | 227 | root.closePopup(); | ||
678 | 228 | } | ||
679 | 229 | } | ||
680 | 230 | } | ||
681 | 231 | } | ||
682 | 232 | |||
683 | 233 | Connections { | ||
684 | 234 | target: root | ||
685 | 235 | onOpenItemChanged: { | ||
686 | 236 | if (root.openItem == menuItem) { | ||
687 | 237 | repeaterItem.selected = true; | ||
688 | 238 | } | ||
689 | 239 | } | ||
690 | 240 | } | ||
691 | 241 | } | ||
692 | 242 | } | ||
693 | 243 | } | ||
694 | 244 | } | ||
695 | 245 | } | ||
696 | 0 | 246 | ||
697 | === added file 'qml/ApplicationMenus/MenuBarItem.qml' | |||
698 | --- qml/ApplicationMenus/MenuBarItem.qml 1970-01-01 00:00:00 +0000 | |||
699 | +++ qml/ApplicationMenus/MenuBarItem.qml 2016-01-15 13:11:04 +0000 | |||
700 | @@ -0,0 +1,56 @@ | |||
701 | 1 | /* | ||
702 | 2 | * Copyright 2015 Canonical Ltd. | ||
703 | 3 | * | ||
704 | 4 | * This program is free software; you can redistribute it and/or modify | ||
705 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
706 | 6 | * the Free Software Foundation; version 3. | ||
707 | 7 | * | ||
708 | 8 | * This program is distributed in the hope that it will be useful, | ||
709 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
710 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
711 | 11 | * GNU Lesser General Public License for more details. | ||
712 | 12 | * | ||
713 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
714 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
715 | 15 | */ | ||
716 | 16 | |||
717 | 17 | import QtQuick 2.4 | ||
718 | 18 | import Ubuntu.Settings.Menus 0.1 as Menus | ||
719 | 19 | import Ubuntu.Components.ListItems 1.3 as ListItems | ||
720 | 20 | import Ubuntu.Components 1.3 | ||
721 | 21 | import QtQuick.Layouts 1.1 | ||
722 | 22 | |||
723 | 23 | import "AppMenuUtils.js" as AppMenuUtils | ||
724 | 24 | |||
725 | 25 | Item { | ||
726 | 26 | id: root | ||
727 | 27 | property var menuItemDelegate: undefined | ||
728 | 28 | property bool enableMnemonic: false | ||
729 | 29 | |||
730 | 30 | implicitWidth: column.implicitWidth | ||
731 | 31 | implicitHeight: column.height | ||
732 | 32 | |||
733 | 33 | RowLayout { | ||
734 | 34 | id: column | ||
735 | 35 | spacing: units.gu(1) | ||
736 | 36 | anchors { | ||
737 | 37 | centerIn: parent | ||
738 | 38 | } | ||
739 | 39 | |||
740 | 40 | Icon { | ||
741 | 41 | Layout.preferredWidth: units.gu(2) | ||
742 | 42 | Layout.preferredHeight: units.gu(2) | ||
743 | 43 | Layout.alignment: Qt.AlignVCenter | ||
744 | 44 | |||
745 | 45 | visible: menuItemDelegate && menuItemDelegate.icon | ||
746 | 46 | source: menuItemDelegate && menuItemDelegate.icon || "" | ||
747 | 47 | } | ||
748 | 48 | |||
749 | 49 | Label { | ||
750 | 50 | id: _title | ||
751 | 51 | text: menuItemDelegate.label.htmlLabelFromMenuLabel(enableMnemonic) || "" | ||
752 | 52 | horizontalAlignment: Text.AlignLeft | ||
753 | 53 | color: enabled ? "white" : "#5d5d5d" | ||
754 | 54 | } | ||
755 | 55 | } | ||
756 | 56 | } | ||
757 | 0 | 57 | ||
758 | === added file 'qml/ApplicationMenus/MenuBase.qml' | |||
759 | --- qml/ApplicationMenus/MenuBase.qml 1970-01-01 00:00:00 +0000 | |||
760 | +++ qml/ApplicationMenus/MenuBase.qml 2016-01-15 13:11:04 +0000 | |||
761 | @@ -0,0 +1,116 @@ | |||
762 | 1 | /* | ||
763 | 2 | * Copyright 2015 Canonical Ltd. | ||
764 | 3 | * | ||
765 | 4 | * This program is free software; you can redistribute it and/or modify | ||
766 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
767 | 6 | * the Free Software Foundation; version 3. | ||
768 | 7 | * | ||
769 | 8 | * This program is distributed in the hope that it will be useful, | ||
770 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
771 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
772 | 11 | * GNU Lesser General Public License for more details. | ||
773 | 12 | * | ||
774 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
775 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
776 | 15 | */ | ||
777 | 16 | |||
778 | 17 | import QtQuick 2.4 | ||
779 | 18 | import Utils 0.1 | ||
780 | 19 | |||
781 | 20 | Item { | ||
782 | 21 | id: root | ||
783 | 22 | |||
784 | 23 | property bool enableMnemonic: false | ||
785 | 24 | property bool opensVertically: true | ||
786 | 25 | readonly property alias openItem: d._openItem | ||
787 | 26 | property real submenuOffset: 0 | ||
788 | 27 | |||
789 | 28 | function open(menuItem, focus, focusIndex) { | ||
790 | 29 | openDelayTimer.stop(); | ||
791 | 30 | |||
792 | 31 | if (d._openItem !== menuItem && menuItem.delegate.hasSubmenu) { | ||
793 | 32 | d.closePopup(); | ||
794 | 33 | |||
795 | 34 | var menuPageComponent = Qt.createComponent("MenuPage.qml"); | ||
796 | 35 | |||
797 | 36 | if (menuPageComponent.status === Component.Ready) { | ||
798 | 37 | d._requestedOpenItem = menuItem; | ||
799 | 38 | d.popup = menuPageComponent.createObject(menuItem, | ||
800 | 39 | { | ||
801 | 40 | "objectName": root.objectName + "-subMenu" + menuItem.delegate.index, | ||
802 | 41 | "vertical": true, | ||
803 | 42 | "x": opensVertically ? submenuOffset : menuItem.width, | ||
804 | 43 | "y": opensVertically ? menuItem.height : submenuOffset, | ||
805 | 44 | "delegateModel": menuItem.delegate.submenuItems | ||
806 | 45 | }); | ||
807 | 46 | } else if (menuPageComponent.status === Component.Error) { | ||
808 | 47 | console.log(menuPageComponent.errorString()); | ||
809 | 48 | } | ||
810 | 49 | } | ||
811 | 50 | if (focus && d.popup) d.popup.forceActiveFocus(); | ||
812 | 51 | if (focusIndex !== undefined && d.popup) d.popup.setSelectedItem(focusIndex); | ||
813 | 52 | } | ||
814 | 53 | |||
815 | 54 | function openWithDelay(menuItem, focus, index) { | ||
816 | 55 | openDelayTimer.stop(); | ||
817 | 56 | if (d._openItem === menuItem) { | ||
818 | 57 | open(menuItem, focus, index); | ||
819 | 58 | } else { | ||
820 | 59 | d._requestedOpenItem = menuItem; | ||
821 | 60 | openDelayTimer.openFocus = focus; | ||
822 | 61 | openDelayTimer.openIndex = index; | ||
823 | 62 | openDelayTimer.restart(); | ||
824 | 63 | } | ||
825 | 64 | } | ||
826 | 65 | |||
827 | 66 | function closePopup(focus) { | ||
828 | 67 | openDelayTimer.stop(); | ||
829 | 68 | if (openItem !== undefined) { | ||
830 | 69 | d.closePopup(); | ||
831 | 70 | } | ||
832 | 71 | if (focus) { | ||
833 | 72 | forceActiveFocus(); | ||
834 | 73 | } | ||
835 | 74 | } | ||
836 | 75 | |||
837 | 76 | Timer { | ||
838 | 77 | id: openDelayTimer | ||
839 | 78 | |||
840 | 79 | property var openFocus | ||
841 | 80 | property var openIndex | ||
842 | 81 | |||
843 | 82 | interval: Constants.menuHoverOpenInterval | ||
844 | 83 | onTriggered: { | ||
845 | 84 | open(d._requestedOpenItem, openDelayTimer.openFocus, openDelayTimer.openIndex); | ||
846 | 85 | } | ||
847 | 86 | } | ||
848 | 87 | |||
849 | 88 | QtObject { | ||
850 | 89 | id: d | ||
851 | 90 | property var _requestedOpenItem: undefined | ||
852 | 91 | property var _openItem: undefined | ||
853 | 92 | |||
854 | 93 | property QtObject popup: null | ||
855 | 94 | onPopupChanged: { | ||
856 | 95 | d._openItem = popup !== null ? _requestedOpenItem : undefined | ||
857 | 96 | } | ||
858 | 97 | |||
859 | 98 | signal closePopup | ||
860 | 99 | } | ||
861 | 100 | |||
862 | 101 | Connections { | ||
863 | 102 | target: d | ||
864 | 103 | onClosePopup: { | ||
865 | 104 | if (d.popup) { | ||
866 | 105 | // recusive close to preserve focusing | ||
867 | 106 | d.popup.closePopup(false); | ||
868 | 107 | d.popup.visible = false; | ||
869 | 108 | d.popup.destroy(); | ||
870 | 109 | d.popup = null; | ||
871 | 110 | |||
872 | 111 | d._openItem = undefined; | ||
873 | 112 | d._requestedOpenItem = undefined; | ||
874 | 113 | } | ||
875 | 114 | } | ||
876 | 115 | } | ||
877 | 116 | } | ||
878 | 0 | 117 | ||
879 | === added file 'qml/ApplicationMenus/MenuItemBase.qml' | |||
880 | --- qml/ApplicationMenus/MenuItemBase.qml 1970-01-01 00:00:00 +0000 | |||
881 | +++ qml/ApplicationMenus/MenuItemBase.qml 2016-01-15 13:11:04 +0000 | |||
882 | @@ -0,0 +1,32 @@ | |||
883 | 1 | /* | ||
884 | 2 | * Copyright 2015 Canonical Ltd. | ||
885 | 3 | * | ||
886 | 4 | * This program is free software; you can redistribute it and/or modify | ||
887 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
888 | 6 | * the Free Software Foundation; version 3. | ||
889 | 7 | * | ||
890 | 8 | * This program is distributed in the hope that it will be useful, | ||
891 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
892 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
893 | 11 | * GNU Lesser General Public License for more details. | ||
894 | 12 | * | ||
895 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
896 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
897 | 15 | */ | ||
898 | 16 | |||
899 | 17 | import QtQuick 2.4 | ||
900 | 18 | import QtQuick.Controls 1.3 as Controls | ||
901 | 19 | |||
902 | 20 | // Item which represents visual location of a menu item | ||
903 | 21 | // Also contains common convenience properties. | ||
904 | 22 | Item { | ||
905 | 23 | id: root | ||
906 | 24 | |||
907 | 25 | property var delegate: undefined | ||
908 | 26 | property alias mnemonicAction: mnemonic | ||
909 | 27 | |||
910 | 28 | /* Quick action. eg "F" from "_File" in the label. Only available while bar/popup is opened */ | ||
911 | 29 | Controls.Action { | ||
912 | 30 | id: mnemonic | ||
913 | 31 | } | ||
914 | 32 | } | ||
915 | 0 | 33 | ||
916 | === added file 'qml/ApplicationMenus/MenuItemDelegate.qml' | |||
917 | --- qml/ApplicationMenus/MenuItemDelegate.qml 1970-01-01 00:00:00 +0000 | |||
918 | +++ qml/ApplicationMenus/MenuItemDelegate.qml 2016-01-15 13:11:04 +0000 | |||
919 | @@ -0,0 +1,49 @@ | |||
920 | 1 | /* | ||
921 | 2 | * Copyright 2015 Canonical Ltd. | ||
922 | 3 | * | ||
923 | 4 | * This program is free software; you can redistribute it and/or modify | ||
924 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
925 | 6 | * the Free Software Foundation; version 3. | ||
926 | 7 | * | ||
927 | 8 | * This program is distributed in the hope that it will be useful, | ||
928 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
929 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
930 | 11 | * GNU Lesser General Public License for more details. | ||
931 | 12 | * | ||
932 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
933 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
934 | 15 | */ | ||
935 | 16 | |||
936 | 17 | import QtQuick 2.4 | ||
937 | 18 | import QtQuick.Controls 1.3 as Controls | ||
938 | 19 | import Utils 0.1 as UnityUtils | ||
939 | 20 | |||
940 | 21 | MenuItemDelegateBase { | ||
941 | 22 | id: root | ||
942 | 23 | property var index: undefined | ||
943 | 24 | property var menuData: undefined | ||
944 | 25 | |||
945 | 26 | readonly property string label: menuData ? menuData.label : "" | ||
946 | 27 | readonly property string action: menuData ? menuData.action : "" | ||
947 | 28 | readonly property string icon: menuData ? menuData.icon : "" | ||
948 | 29 | readonly property var shortcut: menuData ? menuData.shortcut : undefined | ||
949 | 30 | readonly property bool sensitive: menuData ? menuData.sensitive : false | ||
950 | 31 | readonly property bool hasSubmenu: menuData ? menuData.hasSubmenu : false | ||
951 | 32 | readonly property bool isSeparator: menuData ? menuData.isSeparator : false | ||
952 | 33 | readonly property bool isCheck: menuData ? menuData.isCheck : false | ||
953 | 34 | readonly property bool isRadio: menuData ? menuData.isRadio : false | ||
954 | 35 | readonly property bool isToggled: menuData ? menuData.isToggled : false | ||
955 | 36 | |||
956 | 37 | signal activate() | ||
957 | 38 | |||
958 | 39 | UnityUtils.ShortcutAction { | ||
959 | 40 | shortcut: root.shortcut | ||
960 | 41 | target: focusWindow ? focusWindow : null | ||
961 | 42 | |||
962 | 43 | onTriggered: { | ||
963 | 44 | if (root.enabled) { | ||
964 | 45 | activate(); | ||
965 | 46 | } | ||
966 | 47 | } | ||
967 | 48 | } | ||
968 | 49 | } | ||
969 | 0 | 50 | ||
970 | === added file 'qml/ApplicationMenus/MenuItemDelegateBase.qml' | |||
971 | --- qml/ApplicationMenus/MenuItemDelegateBase.qml 1970-01-01 00:00:00 +0000 | |||
972 | +++ qml/ApplicationMenus/MenuItemDelegateBase.qml 2016-01-15 13:11:04 +0000 | |||
973 | @@ -0,0 +1,82 @@ | |||
974 | 1 | /* | ||
975 | 2 | * Copyright 2015 Canonical Ltd. | ||
976 | 3 | * | ||
977 | 4 | * This program is free software; you can redistribute it and/or modify | ||
978 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
979 | 6 | * the Free Software Foundation; version 3. | ||
980 | 7 | * | ||
981 | 8 | * This program is distributed in the hope that it will be useful, | ||
982 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
983 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
984 | 11 | * GNU Lesser General Public License for more details. | ||
985 | 12 | * | ||
986 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
987 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
988 | 15 | */ | ||
989 | 16 | |||
990 | 17 | import QtQuick 2.4 | ||
991 | 18 | import Utils 0.1 | ||
992 | 19 | |||
993 | 20 | Item { | ||
994 | 21 | id: root | ||
995 | 22 | property alias menuModel: subMenuRepeater.model | ||
996 | 23 | readonly property alias submenuItems: submenuDelegates | ||
997 | 24 | property var focusWindow: undefined | ||
998 | 25 | |||
999 | 26 | ListModel { | ||
1000 | 27 | id: submenuDelegates | ||
1001 | 28 | } | ||
1002 | 29 | |||
1003 | 30 | Repeater { | ||
1004 | 31 | id: subMenuRepeater | ||
1005 | 32 | |||
1006 | 33 | onItemAdded: { | ||
1007 | 34 | submenuDelegates.insert(index, { delegate: item.item }); | ||
1008 | 35 | } | ||
1009 | 36 | onItemRemoved: { | ||
1010 | 37 | for (var i = 0; i < submenuDelegates.count; i++) { | ||
1011 | 38 | if (item.item === submenuDelegates.get(i).delegate) { | ||
1012 | 39 | submenuDelegates.remove(i, 1); | ||
1013 | 40 | return; | ||
1014 | 41 | } | ||
1015 | 42 | } | ||
1016 | 43 | } | ||
1017 | 44 | onCountChanged: { | ||
1018 | 45 | if (count == 0) { | ||
1019 | 46 | submenuDelegates.clear(); | ||
1020 | 47 | } | ||
1021 | 48 | } | ||
1022 | 49 | |||
1023 | 50 | delegate: Loader { | ||
1024 | 51 | id: loader | ||
1025 | 52 | source: "MenuItemDelegate.qml" | ||
1026 | 53 | |||
1027 | 54 | property int modelIndex: index | ||
1028 | 55 | |||
1029 | 56 | Binding { | ||
1030 | 57 | target: loader.item | ||
1031 | 58 | property: "index" | ||
1032 | 59 | value: loader.modelIndex | ||
1033 | 60 | } | ||
1034 | 61 | Binding { | ||
1035 | 62 | target: loader.item | ||
1036 | 63 | property: "menuModel" | ||
1037 | 64 | value: model.hasSubmenu ? menuModel.submenu(loader.modelIndex) : undefined | ||
1038 | 65 | } | ||
1039 | 66 | Binding { | ||
1040 | 67 | target: loader.item | ||
1041 | 68 | property: "menuData" | ||
1042 | 69 | value: model | ||
1043 | 70 | } | ||
1044 | 71 | Binding { | ||
1045 | 72 | target: loader.item | ||
1046 | 73 | property: "focusWindow" | ||
1047 | 74 | value: focusWindow | ||
1048 | 75 | } | ||
1049 | 76 | Connections { | ||
1050 | 77 | target: loader.item | ||
1051 | 78 | onActivate: menuModel.activate(loader.modelIndex) | ||
1052 | 79 | } | ||
1053 | 80 | } | ||
1054 | 81 | } | ||
1055 | 82 | } | ||
1056 | 0 | 83 | ||
1057 | === added file 'qml/ApplicationMenus/MenuItemFactory.qml' | |||
1058 | --- qml/ApplicationMenus/MenuItemFactory.qml 1970-01-01 00:00:00 +0000 | |||
1059 | +++ qml/ApplicationMenus/MenuItemFactory.qml 2016-01-15 13:11:04 +0000 | |||
1060 | @@ -0,0 +1,240 @@ | |||
1061 | 1 | /* | ||
1062 | 2 | * Copyright 2015 Canonical Ltd. | ||
1063 | 3 | * | ||
1064 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1065 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1066 | 6 | * the Free Software Foundation; version 3. | ||
1067 | 7 | * | ||
1068 | 8 | * This program is distributed in the hope that it will be useful, | ||
1069 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1070 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1071 | 11 | * GNU Lesser General Public License for more details. | ||
1072 | 12 | * | ||
1073 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1074 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1075 | 15 | */ | ||
1076 | 16 | |||
1077 | 17 | import QtQuick 2.4 | ||
1078 | 18 | import Ubuntu.Settings.Menus 0.1 as Menus | ||
1079 | 19 | import Ubuntu.Components.ListItems 1.3 as ListItems | ||
1080 | 20 | import Ubuntu.Components 1.3 | ||
1081 | 21 | import QtQuick.Layouts 1.1 | ||
1082 | 22 | |||
1083 | 23 | import "AppMenuUtils.js" as AppMenuUtils | ||
1084 | 24 | |||
1085 | 25 | Loader { | ||
1086 | 26 | id: root | ||
1087 | 27 | |||
1088 | 28 | property bool showShortcut: true | ||
1089 | 29 | property var menuItemDelegate: undefined | ||
1090 | 30 | |||
1091 | 31 | property string text: menuItemDelegate && menuItemDelegate.label || "" | ||
1092 | 32 | |||
1093 | 33 | sourceComponent: { | ||
1094 | 34 | if (menuItemDelegate.isSeparator) { | ||
1095 | 35 | return separatorMenu; | ||
1096 | 36 | } | ||
1097 | 37 | if (menuItemDelegate.hasSubmenu) { | ||
1098 | 38 | return subMenu; | ||
1099 | 39 | } | ||
1100 | 40 | if (menuItemDelegate.isCheck || menuItemDelegate.isRadio) { | ||
1101 | 41 | return checkableMenu; | ||
1102 | 42 | } | ||
1103 | 43 | return standardMenu; | ||
1104 | 44 | } | ||
1105 | 45 | |||
1106 | 46 | Component { | ||
1107 | 47 | id: separatorMenu | ||
1108 | 48 | |||
1109 | 49 | Item { | ||
1110 | 50 | implicitHeight: units.dp(6) | ||
1111 | 51 | anchors { | ||
1112 | 52 | left: parent.left | ||
1113 | 53 | right: parent.right | ||
1114 | 54 | } | ||
1115 | 55 | |||
1116 | 56 | Rectangle { | ||
1117 | 57 | height: units.dp(2) | ||
1118 | 58 | color: "#5D5D5D" | ||
1119 | 59 | anchors { | ||
1120 | 60 | left: parent.left | ||
1121 | 61 | right: parent.right | ||
1122 | 62 | verticalCenter: parent.verticalCenter | ||
1123 | 63 | } | ||
1124 | 64 | } | ||
1125 | 65 | } | ||
1126 | 66 | } | ||
1127 | 67 | |||
1128 | 68 | Component { | ||
1129 | 69 | id: standardMenu | ||
1130 | 70 | |||
1131 | 71 | Item { | ||
1132 | 72 | implicitWidth: column.implicitWidth + units.gu(2) | ||
1133 | 73 | implicitHeight: column.implicitHeight + units.gu(2) | ||
1134 | 74 | |||
1135 | 75 | RowLayout { | ||
1136 | 76 | id: column | ||
1137 | 77 | spacing: units.gu(0.5) | ||
1138 | 78 | anchors { | ||
1139 | 79 | left: parent.left | ||
1140 | 80 | right: parent.right | ||
1141 | 81 | top: parent.top | ||
1142 | 82 | margins: units.gu(1) | ||
1143 | 83 | } | ||
1144 | 84 | |||
1145 | 85 | Item { | ||
1146 | 86 | Layout.preferredWidth: units.gu(1.5) | ||
1147 | 87 | Layout.preferredHeight: units.gu(1.5) | ||
1148 | 88 | } | ||
1149 | 89 | |||
1150 | 90 | Icon { | ||
1151 | 91 | Layout.preferredWidth: units.gu(2) | ||
1152 | 92 | Layout.preferredHeight: units.gu(2) | ||
1153 | 93 | Layout.alignment: Qt.AlignVCenter | ||
1154 | 94 | |||
1155 | 95 | visible: menuItemDelegate && menuItemDelegate.icon || false | ||
1156 | 96 | source: menuItemDelegate && menuItemDelegate.icon || "" | ||
1157 | 97 | } | ||
1158 | 98 | |||
1159 | 99 | RowLayout { | ||
1160 | 100 | Layout.fillWidth: true | ||
1161 | 101 | spacing: units.gu(5) | ||
1162 | 102 | |||
1163 | 103 | Label { | ||
1164 | 104 | text: menuItemDelegate ? menuItemDelegate.label.htmlLabelFromMenuLabel(showShortcut) : "" | ||
1165 | 105 | Layout.fillWidth: true | ||
1166 | 106 | horizontalAlignment: Text.AlignLeft | ||
1167 | 107 | color: enabled ? "#FFFFFF" : "#888888" | ||
1168 | 108 | textFormat: Text.StyledText | ||
1169 | 109 | fontSize: "small" | ||
1170 | 110 | } | ||
1171 | 111 | |||
1172 | 112 | Label { | ||
1173 | 113 | text: menuItemDelegate && menuItemDelegate.shortcut !== undefined ? menuItemDelegate.shortcut : "" | ||
1174 | 114 | Layout.alignment: Qt.AlignRight | ||
1175 | 115 | color: "#5D5D5D" | ||
1176 | 116 | fontSize: "small" | ||
1177 | 117 | } | ||
1178 | 118 | } | ||
1179 | 119 | } | ||
1180 | 120 | } | ||
1181 | 121 | } | ||
1182 | 122 | |||
1183 | 123 | Component { | ||
1184 | 124 | id: subMenu | ||
1185 | 125 | |||
1186 | 126 | Item { | ||
1187 | 127 | implicitWidth: column.implicitWidth + units.gu(2) | ||
1188 | 128 | implicitHeight: column.implicitHeight + units.gu(2) | ||
1189 | 129 | |||
1190 | 130 | RowLayout { | ||
1191 | 131 | id: column | ||
1192 | 132 | spacing: units.gu(0.5) | ||
1193 | 133 | anchors { | ||
1194 | 134 | left: parent.left | ||
1195 | 135 | right: parent.right | ||
1196 | 136 | top: parent.top | ||
1197 | 137 | margins: units.gu(1) | ||
1198 | 138 | } | ||
1199 | 139 | |||
1200 | 140 | Item { | ||
1201 | 141 | Layout.preferredWidth: units.gu(1.5) | ||
1202 | 142 | Layout.preferredHeight: units.gu(1.5) | ||
1203 | 143 | } | ||
1204 | 144 | |||
1205 | 145 | Icon { | ||
1206 | 146 | Layout.preferredWidth: units.gu(2) | ||
1207 | 147 | Layout.preferredHeight: units.gu(2) | ||
1208 | 148 | Layout.alignment: Qt.AlignVCenter | ||
1209 | 149 | |||
1210 | 150 | visible: menuItemDelegate && menuItemDelegate.icon || false | ||
1211 | 151 | source: menuItemDelegate && menuItemDelegate.icon || "" | ||
1212 | 152 | } | ||
1213 | 153 | |||
1214 | 154 | Label { | ||
1215 | 155 | id: _title | ||
1216 | 156 | text: menuItemDelegate && menuItemDelegate.label.htmlLabelFromMenuLabel(showShortcut) || "" | ||
1217 | 157 | Layout.fillWidth: true | ||
1218 | 158 | horizontalAlignment: Text.AlignLeft | ||
1219 | 159 | color: enabled ? "#FFFFFF" : "#5D5D5D" | ||
1220 | 160 | textFormat: Text.StyledText | ||
1221 | 161 | fontSize: "small" | ||
1222 | 162 | } | ||
1223 | 163 | |||
1224 | 164 | Icon { | ||
1225 | 165 | id: chevron | ||
1226 | 166 | visible: menuItemDelegate.hasSubmenu | ||
1227 | 167 | |||
1228 | 168 | Layout.preferredHeight: units.gu(1.5) | ||
1229 | 169 | Layout.alignment: Qt.AlignVCenter | ||
1230 | 170 | name: "chevron" | ||
1231 | 171 | color: enabled ? "#FFFFFF" : "#5D5D5D" | ||
1232 | 172 | } | ||
1233 | 173 | } | ||
1234 | 174 | } | ||
1235 | 175 | } | ||
1236 | 176 | |||
1237 | 177 | |||
1238 | 178 | Component { | ||
1239 | 179 | id: checkableMenu | ||
1240 | 180 | |||
1241 | 181 | Item { | ||
1242 | 182 | implicitWidth: column.implicitWidth + units.gu(2) | ||
1243 | 183 | implicitHeight: column.height + units.gu(2) | ||
1244 | 184 | |||
1245 | 185 | RowLayout { | ||
1246 | 186 | id: column | ||
1247 | 187 | spacing: units.gu(0.5) | ||
1248 | 188 | anchors { | ||
1249 | 189 | left: parent.left | ||
1250 | 190 | right: parent.right | ||
1251 | 191 | top: parent.top | ||
1252 | 192 | margins: units.gu(1) | ||
1253 | 193 | } | ||
1254 | 194 | |||
1255 | 195 | Item { | ||
1256 | 196 | Layout.preferredWidth: units.gu(1.5) | ||
1257 | 197 | Layout.preferredHeight: units.gu(1.5) | ||
1258 | 198 | Layout.alignment: Qt.AlignVCenter | ||
1259 | 199 | |||
1260 | 200 | Icon { | ||
1261 | 201 | anchors.fill: parent | ||
1262 | 202 | visible: menuItemDelegate && menuItemDelegate.isToggled | ||
1263 | 203 | name: "tick" | ||
1264 | 204 | color: enabled ? "#FFFFFF" : "#5D5D5D" | ||
1265 | 205 | } | ||
1266 | 206 | } | ||
1267 | 207 | |||
1268 | 208 | Icon { | ||
1269 | 209 | Layout.preferredWidth: units.gu(2) | ||
1270 | 210 | Layout.preferredHeight: units.gu(2) | ||
1271 | 211 | Layout.alignment: Qt.AlignVCenter | ||
1272 | 212 | |||
1273 | 213 | visible: menuItemDelegate && menuItemDelegate.icon | ||
1274 | 214 | source: menuItemDelegate && menuItemDelegate.icon || "" | ||
1275 | 215 | } | ||
1276 | 216 | |||
1277 | 217 | RowLayout { | ||
1278 | 218 | Layout.fillWidth: true | ||
1279 | 219 | spacing: units.gu(5) | ||
1280 | 220 | |||
1281 | 221 | Label { | ||
1282 | 222 | text: menuItemDelegate ? menuItemDelegate.label.htmlLabelFromMenuLabel(showShortcut) : "" | ||
1283 | 223 | Layout.fillWidth: true | ||
1284 | 224 | horizontalAlignment: Text.AlignLeft | ||
1285 | 225 | color: enabled ? "#FFFFFF" : "#888888" | ||
1286 | 226 | textFormat: Text.StyledText | ||
1287 | 227 | fontSize: "small" | ||
1288 | 228 | } | ||
1289 | 229 | |||
1290 | 230 | Label { | ||
1291 | 231 | text: menuItemDelegate && menuItemDelegate.shortcut !== undefined ? menuItemDelegate.shortcut : "" | ||
1292 | 232 | Layout.alignment: Qt.AlignRight | ||
1293 | 233 | color: "#5D5D5D" | ||
1294 | 234 | fontSize: "small" | ||
1295 | 235 | } | ||
1296 | 236 | } | ||
1297 | 237 | } | ||
1298 | 238 | } | ||
1299 | 239 | } | ||
1300 | 240 | } | ||
1301 | 0 | 241 | ||
1302 | === added file 'qml/ApplicationMenus/MenuPage.qml' | |||
1303 | --- qml/ApplicationMenus/MenuPage.qml 1970-01-01 00:00:00 +0000 | |||
1304 | +++ qml/ApplicationMenus/MenuPage.qml 2016-01-15 13:11:04 +0000 | |||
1305 | @@ -0,0 +1,277 @@ | |||
1306 | 1 | /* | ||
1307 | 2 | * Copyright 2015 Canonical Ltd. | ||
1308 | 3 | * | ||
1309 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1310 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1311 | 6 | * the Free Software Foundation; version 3. | ||
1312 | 7 | * | ||
1313 | 8 | * This program is distributed in the hope that it will be useful, | ||
1314 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1315 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1316 | 11 | * GNU Lesser General Public License for more details. | ||
1317 | 12 | * | ||
1318 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1319 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1320 | 15 | */ | ||
1321 | 16 | |||
1322 | 17 | import QtQuick 2.4 | ||
1323 | 18 | import QtQuick.Layouts 1.1 | ||
1324 | 19 | import Ubuntu.Components 1.3 | ||
1325 | 20 | |||
1326 | 21 | MenuBase { | ||
1327 | 22 | id: root | ||
1328 | 23 | objectName: "menuPage" | ||
1329 | 24 | |||
1330 | 25 | property bool vertical: false | ||
1331 | 26 | property alias delegateModel: repeater.model | ||
1332 | 27 | |||
1333 | 28 | width: listView.width | ||
1334 | 29 | height: listView.height | ||
1335 | 30 | opensVertically: false | ||
1336 | 31 | enableMnemonic: focus | ||
1337 | 32 | |||
1338 | 33 | Keys.onDownPressed: { | ||
1339 | 34 | listView.selectNext(); | ||
1340 | 35 | event.accepted = true; | ||
1341 | 36 | } | ||
1342 | 37 | Keys.onUpPressed: { | ||
1343 | 38 | listView.selectPrevious(); | ||
1344 | 39 | event.accepted = true; | ||
1345 | 40 | } | ||
1346 | 41 | |||
1347 | 42 | Keys.onLeftPressed: { | ||
1348 | 43 | if (root.openItem !== undefined) { | ||
1349 | 44 | if (!focus) { | ||
1350 | 45 | // If we don't have the focus, then a child must. | ||
1351 | 46 | // Close the child and let our parent handle the left press | ||
1352 | 47 | root.closePopup(true); | ||
1353 | 48 | event.accepted = true; | ||
1354 | 49 | return; | ||
1355 | 50 | } | ||
1356 | 51 | } | ||
1357 | 52 | event.accepted = false; | ||
1358 | 53 | } | ||
1359 | 54 | Keys.onRightPressed: { | ||
1360 | 55 | if (listView.selectedItem) { | ||
1361 | 56 | if (listView.selectedItem.delegate.hasSubmenu) { | ||
1362 | 57 | root.open(listView.selectedItem, true, 0); | ||
1363 | 58 | event.accepted = true; | ||
1364 | 59 | return; | ||
1365 | 60 | } | ||
1366 | 61 | } | ||
1367 | 62 | event.accepted = false; | ||
1368 | 63 | } | ||
1369 | 64 | Keys.onReturnPressed: { | ||
1370 | 65 | if (listView.selectedItem) { | ||
1371 | 66 | if (listView.selectedItem.delegate.hasSubmenu) { | ||
1372 | 67 | root.open(listView.selectedItem, true, 0); | ||
1373 | 68 | event.accepted = true; | ||
1374 | 69 | return; | ||
1375 | 70 | } else { | ||
1376 | 71 | listView.selectedItem.delegate.activate(); | ||
1377 | 72 | event.accepted = true; | ||
1378 | 73 | } | ||
1379 | 74 | } | ||
1380 | 75 | } | ||
1381 | 76 | |||
1382 | 77 | function setSelectedItem(index) { | ||
1383 | 78 | if (repeater.count <= index) return; | ||
1384 | 79 | var item = repeater.itemAt(index); | ||
1385 | 80 | item.selected = true; | ||
1386 | 81 | } | ||
1387 | 82 | |||
1388 | 83 | BorderImage { | ||
1389 | 84 | anchors { | ||
1390 | 85 | fill: root | ||
1391 | 86 | margins: -units.gu(1) | ||
1392 | 87 | } | ||
1393 | 88 | source: "../Stages/graphics/dropshadow2gu.sci" | ||
1394 | 89 | opacity: 0.3 | ||
1395 | 90 | } | ||
1396 | 91 | |||
1397 | 92 | Rectangle { | ||
1398 | 93 | anchors.fill: parent | ||
1399 | 94 | color: "#292929" | ||
1400 | 95 | } | ||
1401 | 96 | |||
1402 | 97 | ColumnLayout { | ||
1403 | 98 | id: listView | ||
1404 | 99 | objectName: root.objectName+"-ListView" | ||
1405 | 100 | spacing: 0 | ||
1406 | 101 | |||
1407 | 102 | property var selectedItem: undefined | ||
1408 | 103 | |||
1409 | 104 | function selectNext() { | ||
1410 | 105 | var delegate; | ||
1411 | 106 | var newIndex = 0; | ||
1412 | 107 | if (listView.selectedItem === undefined && repeater.count > 0) { | ||
1413 | 108 | while (repeater.count > newIndex) { | ||
1414 | 109 | delegate = repeater.itemAt(newIndex++); | ||
1415 | 110 | if (delegate.enabled) { | ||
1416 | 111 | delegate.selected = true; | ||
1417 | 112 | break; | ||
1418 | 113 | } | ||
1419 | 114 | } | ||
1420 | 115 | } else if (listView.selectedItem !== undefined && repeater.count > 1) { | ||
1421 | 116 | var startIndex = (listView.selectedItem.ownIndex + 1) % repeater.count; | ||
1422 | 117 | newIndex = startIndex; | ||
1423 | 118 | do { | ||
1424 | 119 | delegate = repeater.itemAt(newIndex); | ||
1425 | 120 | if (delegate.enabled) { | ||
1426 | 121 | delegate.selected = true; | ||
1427 | 122 | break; | ||
1428 | 123 | } | ||
1429 | 124 | newIndex = (newIndex + 1) % repeater.count; | ||
1430 | 125 | } while (newIndex !== startIndex) | ||
1431 | 126 | } | ||
1432 | 127 | } | ||
1433 | 128 | |||
1434 | 129 | function selectPrevious() { | ||
1435 | 130 | var delegate; | ||
1436 | 131 | var newIndex = repeater.count-1; | ||
1437 | 132 | if (listView.selectedItem === undefined && repeater.count > 0) { | ||
1438 | 133 | while (repeater.count > newIndex) { | ||
1439 | 134 | delegate = repeater.itemAt(newIndex--); | ||
1440 | 135 | if (delegate.enabled) { | ||
1441 | 136 | delegate.selected = true; | ||
1442 | 137 | break; | ||
1443 | 138 | } | ||
1444 | 139 | } | ||
1445 | 140 | } else if (listView.selectedItem !== undefined && repeater.count > 1) { | ||
1446 | 141 | var startIndex = listView.selectedItem.ownIndex - 1; | ||
1447 | 142 | newIndex = startIndex; | ||
1448 | 143 | do { | ||
1449 | 144 | if (newIndex < 0) newIndex = repeater.count - 1; | ||
1450 | 145 | delegate = repeater.itemAt(newIndex--); | ||
1451 | 146 | if (delegate.enabled) { | ||
1452 | 147 | delegate.selected = true; | ||
1453 | 148 | break; | ||
1454 | 149 | } | ||
1455 | 150 | } while (newIndex !== startIndex) | ||
1456 | 151 | } | ||
1457 | 152 | } | ||
1458 | 153 | |||
1459 | 154 | Repeater { | ||
1460 | 155 | id: repeater | ||
1461 | 156 | |||
1462 | 157 | // This fixes the ordering issues with using repeater in Layouts. | ||
1463 | 158 | onCountChanged: { | ||
1464 | 159 | var i = 0; | ||
1465 | 160 | for (; i < repeater.count; i++) { | ||
1466 | 161 | var item = repeater.itemAt(i) | ||
1467 | 162 | item.parent = null; | ||
1468 | 163 | item.parent = listView; | ||
1469 | 164 | } | ||
1470 | 165 | } | ||
1471 | 166 | onItemRemoved: { | ||
1472 | 167 | if (item.menuItem === listView.selectedItem) { | ||
1473 | 168 | if (root.openItem == item.menuItem) { | ||
1474 | 169 | root.closePopup(true); | ||
1475 | 170 | } | ||
1476 | 171 | listView.selectedItem = undefined; | ||
1477 | 172 | } | ||
1478 | 173 | } | ||
1479 | 174 | |||
1480 | 175 | delegate: MenuItemFactory { | ||
1481 | 176 | id: repeaterItem | ||
1482 | 177 | property bool selected: false | ||
1483 | 178 | enabled: model.delegate.sensitive && !model.delegate.isSeparator | ||
1484 | 179 | |||
1485 | 180 | menuItemDelegate: model.delegate | ||
1486 | 181 | showShortcut: enableMnemonic | ||
1487 | 182 | |||
1488 | 183 | Layout.fillWidth: true | ||
1489 | 184 | Layout.preferredHeight: repeaterItem.implicitHeight | ||
1490 | 185 | |||
1491 | 186 | Rectangle { | ||
1492 | 187 | visible: repeaterItem.selected | ||
1493 | 188 | anchors.fill: parent | ||
1494 | 189 | gradient: UbuntuColors.orangeGradient | ||
1495 | 190 | } | ||
1496 | 191 | |||
1497 | 192 | property alias menuItem: _menuItem | ||
1498 | 193 | |||
1499 | 194 | MenuItemBase { | ||
1500 | 195 | id: _menuItem | ||
1501 | 196 | objectName: root.objectName + "-menu" + index | ||
1502 | 197 | property int ownIndex: index | ||
1503 | 198 | |||
1504 | 199 | anchors.fill: parent | ||
1505 | 200 | delegate: model.delegate | ||
1506 | 201 | |||
1507 | 202 | mnemonicAction { | ||
1508 | 203 | property string action: model.delegate.label.actionKeyFromMenuLabel() | ||
1509 | 204 | enabled: enableMnemonic && repeaterItem.enabled | ||
1510 | 205 | shortcut: action !== "" ? action : "" | ||
1511 | 206 | |||
1512 | 207 | onTriggered: { | ||
1513 | 208 | if (model.delegate.hasSubmenu) { | ||
1514 | 209 | root.open(menuItem, true, 0); | ||
1515 | 210 | } | ||
1516 | 211 | else { | ||
1517 | 212 | model.delegate.activate(); | ||
1518 | 213 | } | ||
1519 | 214 | } | ||
1520 | 215 | } | ||
1521 | 216 | } | ||
1522 | 217 | |||
1523 | 218 | MouseArea { | ||
1524 | 219 | anchors.fill: parent | ||
1525 | 220 | hoverEnabled: true | ||
1526 | 221 | z: 100 | ||
1527 | 222 | |||
1528 | 223 | onEntered: { | ||
1529 | 224 | repeaterItem.selected = true; | ||
1530 | 225 | } | ||
1531 | 226 | onClicked: { | ||
1532 | 227 | if (model.delegate.hasSubmenu) { | ||
1533 | 228 | root.open(menuItem, true); | ||
1534 | 229 | } | ||
1535 | 230 | else if (root.enabled) { | ||
1536 | 231 | model.delegate.activate() | ||
1537 | 232 | } | ||
1538 | 233 | } | ||
1539 | 234 | } | ||
1540 | 235 | |||
1541 | 236 | onSelectedChanged: { | ||
1542 | 237 | if (selected) { | ||
1543 | 238 | listView.selectedItem = menuItem; | ||
1544 | 239 | if (root.openItem !== menuItem) { | ||
1545 | 240 | root.closePopup(true); | ||
1546 | 241 | if (model.delegate.hasSubmenu) { | ||
1547 | 242 | root.openWithDelay(menuItem, false); | ||
1548 | 243 | } | ||
1549 | 244 | } | ||
1550 | 245 | } | ||
1551 | 246 | else if (listView.selectedItem === menuItem) { | ||
1552 | 247 | listView.selectedItem = undefined; | ||
1553 | 248 | if (root.openItem == menuItem) { | ||
1554 | 249 | root.closePopup(true); | ||
1555 | 250 | } | ||
1556 | 251 | } | ||
1557 | 252 | } | ||
1558 | 253 | |||
1559 | 254 | Connections { | ||
1560 | 255 | target: listView | ||
1561 | 256 | onSelectedItemChanged: { | ||
1562 | 257 | if (repeaterItem.selected && (listView.selectedItem === undefined || listView.selectedItem !== menuItem)) { | ||
1563 | 258 | repeaterItem.selected = false; | ||
1564 | 259 | if (root.openItem == menuItem) { | ||
1565 | 260 | root.closePopup(true); | ||
1566 | 261 | } | ||
1567 | 262 | } | ||
1568 | 263 | } | ||
1569 | 264 | } | ||
1570 | 265 | |||
1571 | 266 | Connections { | ||
1572 | 267 | target: root | ||
1573 | 268 | onOpenItemChanged: { | ||
1574 | 269 | if (root.openItem == menuItem) { | ||
1575 | 270 | repeaterItem.selected = true; | ||
1576 | 271 | } | ||
1577 | 272 | } | ||
1578 | 273 | } | ||
1579 | 274 | } | ||
1580 | 275 | } | ||
1581 | 276 | } | ||
1582 | 277 | } | ||
1583 | 0 | 278 | ||
1584 | === modified file 'qml/CMakeLists.txt' | |||
1585 | --- qml/CMakeLists.txt 2015-03-06 04:44:11 +0000 | |||
1586 | +++ qml/CMakeLists.txt 2016-01-15 13:11:04 +0000 | |||
1587 | @@ -5,6 +5,7 @@ | |||
1588 | 5 | ) | 5 | ) |
1589 | 6 | 6 | ||
1590 | 7 | set(QML_DIRS | 7 | set(QML_DIRS |
1591 | 8 | ApplicationMenus | ||
1592 | 8 | Components | 9 | Components |
1593 | 9 | Dash | 10 | Dash |
1594 | 10 | graphics | 11 | graphics |
1595 | 11 | 12 | ||
1596 | === modified file 'qml/Components/PanelState/PanelState.qml' | |||
1597 | --- qml/Components/PanelState/PanelState.qml 2015-11-20 13:06:14 +0000 | |||
1598 | +++ qml/Components/PanelState/PanelState.qml 2016-01-15 13:11:04 +0000 | |||
1599 | @@ -21,9 +21,10 @@ | |||
1600 | 21 | id: root | 21 | id: root |
1601 | 22 | 22 | ||
1602 | 23 | property string title: "" | 23 | property string title: "" |
1604 | 24 | property bool buttonsVisible: false | 24 | property bool decorationsVisible: false |
1605 | 25 | property bool dropShadow: false | 25 | property bool dropShadow: false |
1606 | 26 | property int panelHeight: units.gu(3) | 26 | property int panelHeight: units.gu(3) |
1607 | 27 | property string maximizedApplication: "" | ||
1608 | 27 | 28 | ||
1609 | 28 | signal close() | 29 | signal close() |
1610 | 29 | signal minimize() | 30 | signal minimize() |
1611 | 30 | 31 | ||
1612 | === modified file 'qml/Panel/Panel.qml' | |||
1613 | --- qml/Panel/Panel.qml 2015-11-25 13:57:34 +0000 | |||
1614 | +++ qml/Panel/Panel.qml 2016-01-15 13:11:04 +0000 | |||
1615 | @@ -17,6 +17,9 @@ | |||
1616 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1617 | 18 | import Ubuntu.Components 1.3 | 18 | import Ubuntu.Components 1.3 |
1618 | 19 | import Unity.Application 0.1 | 19 | import Unity.Application 0.1 |
1619 | 20 | import Unity.Indicators 0.1 | ||
1620 | 21 | import Utils 0.1 | ||
1621 | 22 | import "../ApplicationMenus" | ||
1622 | 20 | import "../Components" | 23 | import "../Components" |
1623 | 21 | import "../Components/PanelState" | 24 | import "../Components/PanelState" |
1624 | 22 | import ".." | 25 | import ".." |
1625 | @@ -101,13 +104,14 @@ | |||
1626 | 101 | } | 104 | } |
1627 | 102 | 105 | ||
1628 | 103 | MouseArea { | 106 | MouseArea { |
1629 | 107 | id: decorationMouseArea | ||
1630 | 104 | anchors { | 108 | anchors { |
1631 | 105 | top: parent.top | 109 | top: parent.top |
1632 | 106 | left: parent.left | 110 | left: parent.left |
1633 | 107 | right: indicators.left | 111 | right: indicators.left |
1634 | 108 | } | 112 | } |
1635 | 109 | height: indicators.minimizedPanelHeight | 113 | height: indicators.minimizedPanelHeight |
1637 | 110 | hoverEnabled: true | 114 | hoverEnabled: !indicators.shown |
1638 | 111 | onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp() | 115 | onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp() |
1639 | 112 | onDoubleClicked: PanelState.maximize() | 116 | onDoubleClicked: PanelState.maximize() |
1640 | 113 | 117 | ||
1641 | @@ -124,12 +128,80 @@ | |||
1642 | 124 | bottomMargin: units.gu(0.5) | 128 | bottomMargin: units.gu(0.5) |
1643 | 125 | } | 129 | } |
1644 | 126 | height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin | 130 | height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin |
1647 | 127 | visible: PanelState.buttonsVisible && parent.containsMouse && !root.locked && !callHint.visible | 131 | visible: d.showDecorations |
1648 | 128 | active: PanelState.buttonsVisible | 132 | active: PanelState.decorationsVisible |
1649 | 129 | onClose: PanelState.close() | 133 | onClose: PanelState.close() |
1650 | 130 | onMinimize: PanelState.minimize() | 134 | onMinimize: PanelState.minimize() |
1651 | 131 | onMaximize: PanelState.maximize() | 135 | onMaximize: PanelState.maximize() |
1652 | 132 | } | 136 | } |
1653 | 137 | |||
1654 | 138 | WindowKeysFilter { | ||
1655 | 139 | id: altFilter | ||
1656 | 140 | property bool altPressed: false | ||
1657 | 141 | property bool longAltPressed: false | ||
1658 | 142 | enabled: d.enableMenus | ||
1659 | 143 | Keys.onPressed: { | ||
1660 | 144 | if (event.key === Qt.Key_Alt && !event.isAutoRepeat) { | ||
1661 | 145 | altPressed = true; | ||
1662 | 146 | longAltPressed = false; | ||
1663 | 147 | menuBarShortcutTimer.start(); | ||
1664 | 148 | return; | ||
1665 | 149 | } | ||
1666 | 150 | event.accepted = false; | ||
1667 | 151 | } | ||
1668 | 152 | Keys.onReleased: { | ||
1669 | 153 | if (event.key === Qt.Key_Alt) { | ||
1670 | 154 | menuBarShortcutTimer.stop(); | ||
1671 | 155 | altPressed = false; | ||
1672 | 156 | longAltPressed = false; | ||
1673 | 157 | return; | ||
1674 | 158 | } | ||
1675 | 159 | event.accepted = false | ||
1676 | 160 | } | ||
1677 | 161 | |||
1678 | 162 | Timer { | ||
1679 | 163 | id: menuBarShortcutTimer | ||
1680 | 164 | interval: 200 | ||
1681 | 165 | repeat: false | ||
1682 | 166 | onTriggered: { | ||
1683 | 167 | altFilter.longAltPressed = true; | ||
1684 | 168 | } | ||
1685 | 169 | } | ||
1686 | 170 | } | ||
1687 | 171 | |||
1688 | 172 | Loader { | ||
1689 | 173 | id: menuBarLoader | ||
1690 | 174 | anchors { | ||
1691 | 175 | left: windowControlButtons.right | ||
1692 | 176 | leftMargin: units.gu(3) | ||
1693 | 177 | top: parent.top | ||
1694 | 178 | } | ||
1695 | 179 | height: parent.height | ||
1696 | 180 | visible: d.showDecorations | ||
1697 | 181 | |||
1698 | 182 | sourceComponent: PanelState.maximizedApplication ? menuBarComponent : undefined | ||
1699 | 183 | Component { | ||
1700 | 184 | id: menuBarComponent | ||
1701 | 185 | MenuBar { | ||
1702 | 186 | id: menuBar | ||
1703 | 187 | height: menuBarLoader.height | ||
1704 | 188 | enableMnemonic: altFilter.altPressed | ||
1705 | 189 | enabled: d.enableMenus | ||
1706 | 190 | menuModel: sharedAppModel.model | ||
1707 | 191 | |||
1708 | 192 | SharedUnityMenuModel { | ||
1709 | 193 | id: sharedAppModel | ||
1710 | 194 | |||
1711 | 195 | property var application: ApplicationManager.findApplication(PanelState.maximizedApplication) | ||
1712 | 196 | property var surface: application ? application.session ? application.session.lastSurface : null : null | ||
1713 | 197 | |||
1714 | 198 | busName: surface ? surface.dbusMenuName : "" | ||
1715 | 199 | menuObjectPath: surface ? surface.dbusMenuObjectPath : "" | ||
1716 | 200 | actions: surface && surface.dbusMenuObjectPath ? { "unity": surface.dbusMenuObjectPath } : {} | ||
1717 | 201 | } | ||
1718 | 202 | } | ||
1719 | 203 | } | ||
1720 | 204 | } | ||
1721 | 133 | } | 205 | } |
1722 | 134 | 206 | ||
1723 | 135 | IndicatorsMenu { | 207 | IndicatorsMenu { |
1724 | @@ -162,6 +234,9 @@ | |||
1725 | 162 | callHint.showLiveCall(); | 234 | callHint.showLiveCall(); |
1726 | 163 | } | 235 | } |
1727 | 164 | } | 236 | } |
1728 | 237 | onShownChanged: { | ||
1729 | 238 | if (d.menuBar) d.menuBar.close(); | ||
1730 | 239 | } | ||
1731 | 165 | } | 240 | } |
1732 | 166 | 241 | ||
1733 | 167 | Label { | 242 | Label { |
1734 | @@ -174,17 +249,15 @@ | |||
1735 | 174 | topMargin: units.gu(0.5) | 249 | topMargin: units.gu(0.5) |
1736 | 175 | bottomMargin: units.gu(0.5) | 250 | bottomMargin: units.gu(0.5) |
1737 | 176 | } | 251 | } |
1739 | 177 | color: PanelState.buttonsVisible ? "#ffffff" : "#5d5d5d" | 252 | color: PanelState.decorationsVisible ? "#ffffff" : "#5d5d5d" |
1740 | 178 | height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin | 253 | height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin |
1742 | 179 | visible: !windowControlButtons.visible && !root.locked && !callHint.visible | 254 | visible: !d.showDecorations |
1743 | 180 | verticalAlignment: Text.AlignVCenter | 255 | verticalAlignment: Text.AlignVCenter |
1744 | 181 | fontSize: "medium" | 256 | fontSize: "medium" |
1745 | 182 | font.weight: Font.Normal | 257 | font.weight: Font.Normal |
1746 | 183 | text: PanelState.title | 258 | text: PanelState.title |
1747 | 184 | } | 259 | } |
1748 | 185 | 260 | ||
1749 | 186 | // TODO here would the Locally integrated menus come | ||
1750 | 187 | |||
1751 | 188 | ActiveCallHint { | 261 | ActiveCallHint { |
1752 | 189 | id: __callHint | 262 | id: __callHint |
1753 | 190 | anchors { | 263 | anchors { |
1754 | @@ -200,6 +273,17 @@ | |||
1755 | 200 | id: d | 273 | id: d |
1756 | 201 | objectName: "panelPriv" | 274 | objectName: "panelPriv" |
1757 | 202 | readonly property real indicatorHeight: indicators.minimizedPanelHeight | 275 | readonly property real indicatorHeight: indicators.minimizedPanelHeight |
1758 | 276 | |||
1759 | 277 | property var menuBar: menuBarLoader.item | ||
1760 | 278 | |||
1761 | 279 | property bool enableMenus: PanelState.decorationsVisible && !root.locked && !callHint.visible && | ||
1762 | 280 | menuBar && | ||
1763 | 281 | menuBar.hasChildren | ||
1764 | 282 | |||
1765 | 283 | property bool showDecorations : PanelState.decorationsVisible && !root.locked && !callHint.visible && | ||
1766 | 284 | (altFilter.longAltPressed || | ||
1767 | 285 | (decorationMouseArea.hoverEnabled && decorationMouseArea.containsMouse) || | ||
1768 | 286 | (menuBar && menuBar.openItem !== undefined)) | ||
1769 | 203 | } | 287 | } |
1770 | 204 | 288 | ||
1771 | 205 | states: [ | 289 | states: [ |
1772 | 206 | 290 | ||
1773 | === modified file 'qml/Stages/DecoratedWindow.qml' | |||
1774 | --- qml/Stages/DecoratedWindow.qml 2015-11-23 15:09:45 +0000 | |||
1775 | +++ qml/Stages/DecoratedWindow.qml 2016-01-15 13:11:04 +0000 | |||
1776 | @@ -19,6 +19,11 @@ | |||
1777 | 19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
1778 | 20 | import Ubuntu.Components 1.3 | 20 | import Ubuntu.Components 1.3 |
1779 | 21 | import Unity.Application 0.1 | 21 | import Unity.Application 0.1 |
1780 | 22 | import Unity.Indicators 0.1 as Indicators | ||
1781 | 23 | import GlobalShortcut 1.0 | ||
1782 | 24 | import "../Components/PanelState" | ||
1783 | 25 | |||
1784 | 26 | import QMenuModel 0.1 as MenuModel | ||
1785 | 22 | 27 | ||
1786 | 23 | FocusScope { | 28 | FocusScope { |
1787 | 24 | id: root | 29 | id: root |
1788 | @@ -69,22 +74,6 @@ | |||
1789 | 69 | enabled: !fullscreen | 74 | enabled: !fullscreen |
1790 | 70 | } | 75 | } |
1791 | 71 | 76 | ||
1792 | 72 | WindowDecoration { | ||
1793 | 73 | id: decoration | ||
1794 | 74 | target: root.parent | ||
1795 | 75 | objectName: application ? "appWindowDecoration_" + application.appId : "appWindowDecoration_null" | ||
1796 | 76 | anchors { left: parent.left; top: parent.top; right: parent.right } | ||
1797 | 77 | height: units.gu(3) | ||
1798 | 78 | width: root.width | ||
1799 | 79 | title: window.title | ||
1800 | 80 | visible: root.decorationShown | ||
1801 | 81 | |||
1802 | 82 | onClose: root.close(); | ||
1803 | 83 | onMaximize: { root.decorationPressed(); root.maximize(); } | ||
1804 | 84 | onMinimize: root.minimize(); | ||
1805 | 85 | onPressed: root.decorationPressed(); | ||
1806 | 86 | } | ||
1807 | 87 | |||
1808 | 88 | ApplicationWindow { | 77 | ApplicationWindow { |
1809 | 89 | id: applicationWindow | 78 | id: applicationWindow |
1810 | 90 | objectName: application ? "appWindow_" + application.appId : "appWindow_null" | 79 | objectName: application ? "appWindow_" + application.appId : "appWindow_null" |
1811 | @@ -95,4 +84,49 @@ | |||
1812 | 95 | interactive: true | 84 | interactive: true |
1813 | 96 | focus: true | 85 | focus: true |
1814 | 97 | } | 86 | } |
1815 | 87 | |||
1816 | 88 | MouseArea { | ||
1817 | 89 | anchors { left: parent.left; top: parent.top; right: parent.right } | ||
1818 | 90 | height: units.gu(3) | ||
1819 | 91 | |||
1820 | 92 | drag.target: root.parent | ||
1821 | 93 | drag.filterChildren: true | ||
1822 | 94 | drag.threshold: 0 | ||
1823 | 95 | drag.minimumY: PanelState.panelHeight | ||
1824 | 96 | drag.onActiveChanged: { | ||
1825 | 97 | Mir.cursorName = active ? "grabbing" : "" | ||
1826 | 98 | } | ||
1827 | 99 | |||
1828 | 100 | // Parent is handling drag, this handles clicks. | ||
1829 | 101 | MouseArea { | ||
1830 | 102 | anchors.fill: parent | ||
1831 | 103 | onPressed: root.decorationPressed() | ||
1832 | 104 | onDoubleClicked: root.maximize() | ||
1833 | 105 | } | ||
1834 | 106 | |||
1835 | 107 | WindowDecoration { | ||
1836 | 108 | id: decoration | ||
1837 | 109 | objectName: application ? "appWindowDecoration_" + application.appId : "appWindowDecoration_null" | ||
1838 | 110 | anchors.fill: parent | ||
1839 | 111 | appId: application ? application.appId : "" | ||
1840 | 112 | title: window.title | ||
1841 | 113 | visible: root.decorationShown | ||
1842 | 114 | |||
1843 | 115 | onClose: root.close(); | ||
1844 | 116 | onMaximize: { root.decorationPressed(); root.maximize(); } | ||
1845 | 117 | onMinimize: root.minimize(); | ||
1846 | 118 | |||
1847 | 119 | menu: sharedAppModel.model | ||
1848 | 120 | target: applicationWindow | ||
1849 | 121 | |||
1850 | 122 | Indicators.SharedUnityMenuModel { | ||
1851 | 123 | id: sharedAppModel | ||
1852 | 124 | property var surface: application ? application.session ? application.session.lastSurface : null : null | ||
1853 | 125 | |||
1854 | 126 | busName: surface ? surface.dbusMenuName : "" | ||
1855 | 127 | menuObjectPath: surface ? surface.dbusMenuObjectPath : "" | ||
1856 | 128 | actions: surface && surface.dbusMenuObjectPath ? { "unity": surface.dbusMenuObjectPath } : {} | ||
1857 | 129 | } | ||
1858 | 130 | } | ||
1859 | 131 | } | ||
1860 | 98 | } | 132 | } |
1861 | 99 | 133 | ||
1862 | === modified file 'qml/Stages/DesktopStage.qml' | |||
1863 | --- qml/Stages/DesktopStage.qml 2016-01-08 13:29:03 +0000 | |||
1864 | +++ qml/Stages/DesktopStage.qml 2016-01-15 13:11:04 +0000 | |||
1865 | @@ -187,13 +187,20 @@ | |||
1866 | 187 | 187 | ||
1867 | 188 | Binding { | 188 | Binding { |
1868 | 189 | target: PanelState | 189 | target: PanelState |
1871 | 190 | property: "buttonsVisible" | 190 | property: "decorationsVisible" |
1872 | 191 | value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus | 191 | value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized |
1873 | 192 | && spread.state == "" | 192 | && spread.state == "" |
1874 | 193 | } | 193 | } |
1875 | 194 | 194 | ||
1876 | 195 | Binding { | 195 | Binding { |
1877 | 196 | target: PanelState | 196 | target: PanelState |
1878 | 197 | property: "maximizedApplication" | ||
1879 | 198 | value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized | ||
1880 | 199 | && spread.state == "" ? priv.focusedAppId : "" | ||
1881 | 200 | } | ||
1882 | 201 | |||
1883 | 202 | Binding { | ||
1884 | 203 | target: PanelState | ||
1885 | 197 | property: "title" | 204 | property: "title" |
1886 | 198 | value: { | 205 | value: { |
1887 | 199 | if (priv.focusedAppDelegate !== null && spread.state == "") { | 206 | if (priv.focusedAppDelegate !== null && spread.state == "") { |
1888 | @@ -215,7 +222,7 @@ | |||
1889 | 215 | 222 | ||
1890 | 216 | Component.onDestruction: { | 223 | Component.onDestruction: { |
1891 | 217 | PanelState.title = ""; | 224 | PanelState.title = ""; |
1893 | 218 | PanelState.buttonsVisible = false; | 225 | PanelState.decorationsVisible = false; |
1894 | 219 | PanelState.dropShadow = false; | 226 | PanelState.dropShadow = false; |
1895 | 220 | } | 227 | } |
1896 | 221 | 228 | ||
1897 | 222 | 229 | ||
1898 | === modified file 'qml/Stages/WindowDecoration.qml' | |||
1899 | --- qml/Stages/WindowDecoration.qml 2015-11-25 13:57:34 +0000 | |||
1900 | +++ qml/Stages/WindowDecoration.qml 2016-01-15 13:11:04 +0000 | |||
1901 | @@ -15,90 +15,162 @@ | |||
1902 | 15 | */ | 15 | */ |
1903 | 16 | 16 | ||
1904 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
1905 | 18 | import QtQuick.Layouts 1.1 | ||
1906 | 18 | import Unity.Application 0.1 // For Mir singleton | 19 | import Unity.Application 0.1 // For Mir singleton |
1907 | 19 | import Ubuntu.Components 1.3 | 20 | import Ubuntu.Components 1.3 |
1908 | 21 | import Utils 0.1 | ||
1909 | 20 | import "../Components" | 22 | import "../Components" |
1910 | 21 | import "../Components/PanelState" | 23 | import "../Components/PanelState" |
1911 | 24 | import "../ApplicationMenus" | ||
1912 | 22 | 25 | ||
1914 | 23 | MouseArea { | 26 | Item { |
1915 | 24 | id: root | 27 | id: root |
1916 | 25 | clip: true | ||
1917 | 26 | 28 | ||
1918 | 27 | property Item target | 29 | property Item target |
1919 | 30 | property string appId | ||
1920 | 28 | property alias title: titleLabel.text | 31 | property alias title: titleLabel.text |
1921 | 29 | property bool active: false | 32 | property bool active: false |
1923 | 30 | hoverEnabled: true | 33 | property var menu: undefined |
1924 | 31 | 34 | ||
1925 | 32 | signal close() | 35 | signal close() |
1926 | 33 | signal minimize() | 36 | signal minimize() |
1927 | 34 | signal maximize() | 37 | signal maximize() |
1928 | 35 | 38 | ||
1929 | 36 | onDoubleClicked: root.maximize() | ||
1930 | 37 | |||
1931 | 38 | QtObject { | 39 | QtObject { |
1932 | 39 | id: priv | 40 | id: priv |
1933 | 40 | property real distanceX | 41 | property real distanceX |
1934 | 41 | property real distanceY | 42 | property real distanceY |
1935 | 42 | property bool dragging | 43 | property bool dragging |
1962 | 43 | } | 44 | |
1963 | 44 | 45 | property var menuBar: menuBarLoader.item | |
1964 | 45 | onPressedChanged: { | 46 | |
1965 | 46 | if (pressed) { | 47 | property bool enableMenus: root.active && |
1966 | 47 | var pos = mapToItem(root.target, mouseX, mouseY); | 48 | (!PanelState.decorationsVisible || PanelState.maximizedApplication !== appId) && |
1967 | 48 | priv.distanceX = pos.x; | 49 | menuBar && |
1968 | 49 | priv.distanceY = pos.y; | 50 | menuBar.hasChildren |
1969 | 50 | priv.dragging = true; | 51 | |
1970 | 51 | } else { | 52 | property bool shouldShowMenus : enableMenus && |
1971 | 52 | priv.dragging = false; | 53 | (altFilter.longAltPressed || menuBarHover.containsMouse || menuBar.openItem !== undefined) |
1972 | 53 | Mir.cursorName = ""; | 54 | } |
1973 | 54 | } | 55 | |
1974 | 55 | } | 56 | WindowKeysFilter { |
1975 | 56 | 57 | id: altFilter | |
1976 | 57 | onPositionChanged: { | 58 | property bool altPressed: false |
1977 | 58 | if (priv.dragging) { | 59 | property bool longAltPressed: false |
1978 | 59 | Mir.cursorName = "grabbing"; | 60 | enabled: priv.enableMenus |
1979 | 60 | var pos = mapToItem(root.target.parent, mouseX, mouseY); | 61 | Keys.onPressed: { |
1980 | 61 | root.target.x = pos.x - priv.distanceX; | 62 | if (event.key === Qt.Key_Alt && !event.isAutoRepeat) { |
1981 | 62 | root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight); | 63 | altPressed = true; |
1982 | 63 | } | 64 | longAltPressed = false; |
1983 | 64 | } | 65 | menuBarShortcutTimer.start(); |
1984 | 65 | 66 | return; | |
1985 | 66 | Rectangle { | 67 | } |
1986 | 67 | anchors.fill: parent | 68 | event.accepted = false; |
1987 | 68 | anchors.bottomMargin: -radius | 69 | } |
1988 | 70 | Keys.onReleased: { | ||
1989 | 71 | if (event.key === Qt.Key_Alt) { | ||
1990 | 72 | menuBarShortcutTimer.stop(); | ||
1991 | 73 | altPressed = false; | ||
1992 | 74 | longAltPressed = false; | ||
1993 | 75 | return; | ||
1994 | 76 | } | ||
1995 | 77 | event.accepted = false | ||
1996 | 78 | } | ||
1997 | 79 | |||
1998 | 80 | Timer { | ||
1999 | 81 | id: menuBarShortcutTimer | ||
2000 | 82 | interval: 200 | ||
2001 | 83 | repeat: false | ||
2002 | 84 | onTriggered: { | ||
2003 | 85 | altFilter.longAltPressed = true; | ||
2004 | 86 | } | ||
2005 | 87 | } | ||
2006 | 88 | } | ||
2007 | 89 | |||
2008 | 90 | // non rounded for bottom of decoration | ||
2009 | 91 | Rectangle { | ||
2010 | 92 | anchors.fill: parent | ||
2011 | 93 | anchors.topMargin: units.gu(.5) | ||
2012 | 94 | color: "#292929" | ||
2013 | 95 | } | ||
2014 | 96 | |||
2015 | 97 | // rounded for top of decoration | ||
2016 | 98 | Rectangle { | ||
2017 | 99 | anchors.fill: parent | ||
2018 | 69 | radius: units.gu(.5) | 100 | radius: units.gu(.5) |
2019 | 70 | color: "#292929" | 101 | color: "#292929" |
2020 | 71 | } | 102 | } |
2021 | 72 | 103 | ||
2023 | 73 | Row { | 104 | RowLayout { |
2024 | 74 | anchors { | 105 | anchors { |
2025 | 75 | fill: parent | 106 | fill: parent |
2026 | 76 | leftMargin: units.gu(1) | 107 | leftMargin: units.gu(1) |
2027 | 77 | rightMargin: units.gu(1) | 108 | rightMargin: units.gu(1) |
2028 | 78 | topMargin: units.gu(0.5) | ||
2029 | 79 | bottomMargin: units.gu(0.5) | ||
2030 | 80 | } | 109 | } |
2031 | 81 | spacing: units.gu(3) | 110 | spacing: units.gu(3) |
2032 | 82 | 111 | ||
2033 | 83 | WindowControlButtons { | 112 | WindowControlButtons { |
2034 | 84 | id: buttons | 113 | id: buttons |
2036 | 85 | height: parent.height | 114 | anchors { |
2037 | 115 | top: parent.top | ||
2038 | 116 | bottom: parent.bottom | ||
2039 | 117 | topMargin: units.gu(0.5) | ||
2040 | 118 | bottomMargin: units.gu(0.5) | ||
2041 | 119 | } | ||
2042 | 86 | active: root.active | 120 | active: root.active |
2043 | 87 | onClose: root.close(); | 121 | onClose: root.close(); |
2044 | 88 | onMinimize: root.minimize(); | 122 | onMinimize: root.minimize(); |
2045 | 89 | onMaximize: root.maximize(); | 123 | onMaximize: root.maximize(); |
2046 | 90 | } | 124 | } |
2047 | 91 | 125 | ||
2058 | 92 | Label { | 126 | Item { |
2059 | 93 | id: titleLabel | 127 | Layout.preferredHeight: parent.height |
2060 | 94 | objectName: "windowDecorationTitle" | 128 | Layout.fillWidth: true |
2061 | 95 | color: root.active ? "white" : "#5d5d5d" | 129 | |
2062 | 96 | height: parent.height | 130 | MouseArea { |
2063 | 97 | width: parent.width - buttons.width - parent.anchors.rightMargin - parent.anchors.leftMargin | 131 | id: menuBarHover |
2064 | 98 | verticalAlignment: Text.AlignVCenter | 132 | hoverEnabled: true |
2065 | 99 | fontSize: "medium" | 133 | anchors.fill: parent |
2066 | 100 | font.weight: root.active ? Font.Light : Font.Normal | 134 | onPressed: { mouse.accepted = false; } // just monitoring |
2067 | 101 | elide: Text.ElideRight | 135 | } |
2068 | 136 | |||
2069 | 137 | Label { | ||
2070 | 138 | id: titleLabel | ||
2071 | 139 | objectName: "windowDecorationTitle" | ||
2072 | 140 | color: root.active ? "white" : "#5d5d5d" | ||
2073 | 141 | height: parent.height | ||
2074 | 142 | width: parent.width | ||
2075 | 143 | verticalAlignment: Text.AlignVCenter | ||
2076 | 144 | fontSize: "medium" | ||
2077 | 145 | font.weight: root.active ? Font.Light : Font.Normal | ||
2078 | 146 | elide: Text.ElideRight | ||
2079 | 147 | |||
2080 | 148 | opacity: priv.shouldShowMenus ? 0 : 1 | ||
2081 | 149 | Behavior on opacity { UbuntuNumberAnimation { } } | ||
2082 | 150 | } | ||
2083 | 151 | |||
2084 | 152 | Loader { | ||
2085 | 153 | id: menuBarLoader | ||
2086 | 154 | objectName: "windowDecorationMenuBarLoader" | ||
2087 | 155 | anchors.bottom: parent.bottom | ||
2088 | 156 | height: parent.height | ||
2089 | 157 | width: parent.width | ||
2090 | 158 | sourceComponent: root.menu ? menuBarComponent : undefined | ||
2091 | 159 | Component { | ||
2092 | 160 | id: menuBarComponent | ||
2093 | 161 | MenuBar { | ||
2094 | 162 | id: menuBar | ||
2095 | 163 | height: menuBarLoader.height | ||
2096 | 164 | focusWindow: root.target | ||
2097 | 165 | menuModel: root.menu | ||
2098 | 166 | enableMnemonic: altFilter.altPressed | ||
2099 | 167 | enabled: priv.enableMenus | ||
2100 | 168 | } | ||
2101 | 169 | } | ||
2102 | 170 | |||
2103 | 171 | opacity: priv.shouldShowMenus ? 1 : 0 | ||
2104 | 172 | Behavior on opacity { UbuntuNumberAnimation { } } | ||
2105 | 173 | } | ||
2106 | 102 | } | 174 | } |
2107 | 103 | } | 175 | } |
2108 | 104 | } | 176 | } |
2109 | 105 | 177 | ||
2110 | === modified file 'tests/imports/check_imports.py' | |||
2111 | --- tests/imports/check_imports.py 2015-07-15 15:13:18 +0000 | |||
2112 | +++ tests/imports/check_imports.py 2016-01-15 13:11:04 +0000 | |||
2113 | @@ -53,6 +53,7 @@ | |||
2114 | 53 | quick_good_pat = re.compile(r'.*import QtQuick 2\.4.*$') | 53 | quick_good_pat = re.compile(r'.*import QtQuick 2\.4.*$') |
2115 | 54 | quick_layouts_good_pat = re.compile(r'.*import QtQuick.Layouts 1\.1.*$') | 54 | quick_layouts_good_pat = re.compile(r'.*import QtQuick.Layouts 1\.1.*$') |
2116 | 55 | quick_window_good_pat = re.compile(r'.*import QtQuick.Window 2\.2.*$') | 55 | quick_window_good_pat = re.compile(r'.*import QtQuick.Window 2\.2.*$') |
2117 | 56 | quick_controls_good_pat = re.compile(r'.*import QtQuick.Controls 1\.4.*$') | ||
2118 | 56 | 57 | ||
2119 | 57 | # Ubuntu Components patterns | 58 | # Ubuntu Components patterns |
2120 | 58 | ubuntu_components_pat = re.compile(r'.*import Ubuntu.Components.*') | 59 | ubuntu_components_pat = re.compile(r'.*import Ubuntu.Components.*') |
2121 | @@ -111,7 +112,7 @@ | |||
2122 | 111 | for file in files: | 112 | for file in files: |
2123 | 112 | path = os.path.join(root, file) | 113 | path = os.path.join(root, file) |
2124 | 113 | if not (ignore and path.startswith(ignore)) and pat.match(file): | 114 | if not (ignore and path.startswith(ignore)) and pat.match(file): |
2126 | 114 | quick_good_pats = [quick_good_pat, quick_layouts_good_pat, quick_window_good_pat] | 115 | quick_good_pats = [quick_good_pat, quick_layouts_good_pat, quick_window_good_pat, quick_controls_good_pat] |
2127 | 115 | if scan_for_bad_import(path, quick_pat, quick_good_pats): | 116 | if scan_for_bad_import(path, quick_pat, quick_good_pats): |
2128 | 116 | found_bad_import = True | 117 | found_bad_import = True |
2129 | 117 | if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]): | 118 | if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]): |
2130 | 118 | 119 | ||
2131 | === modified file 'tests/mocks/QMenuModel/QMenuModel.qmltypes' | |||
2132 | --- tests/mocks/QMenuModel/QMenuModel.qmltypes 2015-02-13 09:01:16 +0000 | |||
2133 | +++ tests/mocks/QMenuModel/QMenuModel.qmltypes 2016-01-15 13:11:04 +0000 | |||
2134 | @@ -1,4 +1,4 @@ | |||
2136 | 1 | import QtQuick.tooling 1.1 | 1 | import QtQuick.tooling 1.2 |
2137 | 2 | 2 | ||
2138 | 3 | // This file describes the plugin-supplied types contained in the library. | 3 | // This file describes the plugin-supplied types contained in the library. |
2139 | 4 | // It is used for QML tooling purposes only. | 4 | // It is used for QML tooling purposes only. |
2140 | @@ -57,6 +57,10 @@ | |||
2141 | 57 | Property { name: "actionStateParser"; type: "ActionStateParser"; isPointer: true } | 57 | Property { name: "actionStateParser"; type: "ActionStateParser"; isPointer: true } |
2142 | 58 | Property { name: "nameOwner"; type: "string"; isReadonly: true } | 58 | Property { name: "nameOwner"; type: "string"; isReadonly: true } |
2143 | 59 | Property { name: "modelData"; type: "QVariant" } | 59 | Property { name: "modelData"; type: "QVariant" } |
2144 | 60 | Signal { | ||
2145 | 61 | name: "activated" | ||
2146 | 62 | Parameter { name: "action"; type: "string" } | ||
2147 | 63 | } | ||
2148 | 60 | Method { | 64 | Method { |
2149 | 61 | name: "insertRow" | 65 | name: "insertRow" |
2150 | 62 | Parameter { name: "row"; type: "int" } | 66 | Parameter { name: "row"; type: "int" } |
2151 | 63 | 67 | ||
2152 | === modified file 'tests/mocks/QMenuModel/unitymenumodel.cpp' | |||
2153 | --- tests/mocks/QMenuModel/unitymenumodel.cpp 2014-10-07 10:28:59 +0000 | |||
2154 | +++ tests/mocks/QMenuModel/unitymenumodel.cpp 2016-01-15 13:11:04 +0000 | |||
2155 | @@ -18,6 +18,8 @@ | |||
2156 | 18 | 18 | ||
2157 | 19 | #include "unitymenumodel.h" | 19 | #include "unitymenumodel.h" |
2158 | 20 | 20 | ||
2159 | 21 | #include <QDebug> | ||
2160 | 22 | |||
2161 | 21 | enum MenuRoles { | 23 | enum MenuRoles { |
2162 | 22 | LabelRole = Qt::DisplayRole + 1, | 24 | LabelRole = Qt::DisplayRole + 1, |
2163 | 23 | SensitiveRole, | 25 | SensitiveRole, |
2164 | @@ -29,7 +31,9 @@ | |||
2165 | 29 | ActionStateRole, | 31 | ActionStateRole, |
2166 | 30 | IsCheckRole, | 32 | IsCheckRole, |
2167 | 31 | IsRadioRole, | 33 | IsRadioRole, |
2169 | 32 | IsToggledRole | 34 | IsToggledRole, |
2170 | 35 | ShortcutRole, | ||
2171 | 36 | HasSubmenuRole | ||
2172 | 33 | }; | 37 | }; |
2173 | 34 | 38 | ||
2174 | 35 | UnityMenuModel::UnityMenuModel(QObject *parent) | 39 | UnityMenuModel::UnityMenuModel(QObject *parent) |
2175 | @@ -149,7 +153,10 @@ | |||
2176 | 149 | if (m_modelData.count() <= row) { | 153 | if (m_modelData.count() <= row) { |
2177 | 150 | return QVariantMap(); | 154 | return QVariantMap(); |
2178 | 151 | } | 155 | } |
2180 | 152 | return m_modelData[row].toMap()["rowData"].toMap(); | 156 | QVariantMap vRow = m_modelData[row].toMap(); |
2181 | 157 | QVariantMap map = vRow["rowData"].toMap(); | ||
2182 | 158 | map["hasSubmenu"] = vRow.contains("submenu"); | ||
2183 | 159 | return map; | ||
2184 | 153 | } | 160 | } |
2185 | 154 | 161 | ||
2186 | 155 | QVariant UnityMenuModel::subMenuData(int row) const | 162 | QVariant UnityMenuModel::subMenuData(int row) const |
2187 | @@ -182,6 +189,8 @@ | |||
2188 | 182 | names[IsCheckRole] = "isCheck"; | 189 | names[IsCheckRole] = "isCheck"; |
2189 | 183 | names[IsRadioRole] = "isRadio"; | 190 | names[IsRadioRole] = "isRadio"; |
2190 | 184 | names[IsToggledRole] = "isToggled"; | 191 | names[IsToggledRole] = "isToggled"; |
2191 | 192 | names[ShortcutRole] = "shortcut"; | ||
2192 | 193 | names[HasSubmenuRole] = "hasSubmenu"; | ||
2193 | 185 | 194 | ||
2194 | 186 | return names; | 195 | return names; |
2195 | 187 | } | 196 | } |
2196 | @@ -201,6 +210,7 @@ | |||
2197 | 201 | UnityMenuModel*& model = submenus[position]; | 210 | UnityMenuModel*& model = submenus[position]; |
2198 | 202 | if (!model) { | 211 | if (!model) { |
2199 | 203 | model = new UnityMenuModel(this); | 212 | model = new UnityMenuModel(this); |
2200 | 213 | connect(model, &UnityMenuModel::activated, this, &UnityMenuModel::activated); | ||
2201 | 204 | } | 214 | } |
2202 | 205 | if (model->modelData() != submenuData) { | 215 | if (model->modelData() != submenuData) { |
2203 | 206 | model->setModelData(submenuData); | 216 | model->setModelData(submenuData); |
2204 | @@ -228,8 +238,20 @@ | |||
2205 | 228 | return this->data(this->index(row, 0), roles[role]); | 238 | return this->data(this->index(row, 0), roles[role]); |
2206 | 229 | } | 239 | } |
2207 | 230 | 240 | ||
2209 | 231 | void UnityMenuModel::activate(int, const QVariant&) | 241 | void UnityMenuModel::activate(int row, const QVariant&) |
2210 | 232 | { | 242 | { |
2211 | 243 | QVariantMap vModelData = m_modelData[row].toMap(); | ||
2212 | 244 | QVariantMap rd = vModelData["rowData"].toMap(); | ||
2213 | 245 | |||
2214 | 246 | bool isCheckable = rd[roleNames()[IsCheckRole]].toBool() || rd[roleNames()[IsRadioRole]].toBool(); | ||
2215 | 247 | if (isCheckable) { | ||
2216 | 248 | rd[roleNames()[IsToggledRole]] = !rd[roleNames()[IsToggledRole]].toBool(); | ||
2217 | 249 | vModelData["rowData"] = rd; | ||
2218 | 250 | m_modelData[row] = vModelData; | ||
2219 | 251 | |||
2220 | 252 | dataChanged(index(row, 0), index(row, 0), QVector<int>() << IsToggledRole); | ||
2221 | 253 | } | ||
2222 | 254 | Q_EMIT activated(rd[roleNames()[ActionRole]].toString()); | ||
2223 | 233 | } | 255 | } |
2224 | 234 | 256 | ||
2225 | 235 | void UnityMenuModel::changeState(int, const QVariant&) | 257 | void UnityMenuModel::changeState(int, const QVariant&) |
2226 | 236 | 258 | ||
2227 | === modified file 'tests/mocks/QMenuModel/unitymenumodel.h' | |||
2228 | --- tests/mocks/QMenuModel/unitymenumodel.h 2015-04-30 09:31:51 +0000 | |||
2229 | +++ tests/mocks/QMenuModel/unitymenumodel.h 2016-01-15 13:11:04 +0000 | |||
2230 | @@ -88,6 +88,8 @@ | |||
2231 | 88 | // Internal mock usage | 88 | // Internal mock usage |
2232 | 89 | void modelDataChanged(); | 89 | void modelDataChanged(); |
2233 | 90 | 90 | ||
2234 | 91 | void activated(const QString& action); | ||
2235 | 92 | |||
2236 | 91 | private: | 93 | private: |
2237 | 92 | QVariantMap rowData(int row) const; | 94 | QVariantMap rowData(int row) const; |
2238 | 93 | QVariant subMenuData(int row) const; | 95 | QVariant subMenuData(int row) const; |
2239 | 94 | 96 | ||
2240 | === modified file 'tests/mocks/Unity/Application/MirSurface.cpp' | |||
2241 | --- tests/mocks/Unity/Application/MirSurface.cpp 2015-11-06 15:52:24 +0000 | |||
2242 | +++ tests/mocks/Unity/Application/MirSurface.cpp 2016-01-15 13:11:04 +0000 | |||
2243 | @@ -129,6 +129,16 @@ | |||
2244 | 129 | Q_EMIT orientationAngleChanged(angle); | 129 | Q_EMIT orientationAngleChanged(angle); |
2245 | 130 | } | 130 | } |
2246 | 131 | 131 | ||
2247 | 132 | QString MirSurface::dbusMenuName() const | ||
2248 | 133 | { | ||
2249 | 134 | return name(); | ||
2250 | 135 | } | ||
2251 | 136 | |||
2252 | 137 | QString MirSurface::dbusMenuObjectPath() const | ||
2253 | 138 | { | ||
2254 | 139 | return QString("/%1").arg(name()); | ||
2255 | 140 | } | ||
2256 | 141 | |||
2257 | 132 | 142 | ||
2258 | 133 | 143 | ||
2259 | 134 | void MirSurface::registerView(qintptr viewId) | 144 | void MirSurface::registerView(qintptr viewId) |
2260 | 135 | 145 | ||
2261 | === modified file 'tests/mocks/Unity/Application/MirSurface.h' | |||
2262 | --- tests/mocks/Unity/Application/MirSurface.h 2015-11-06 15:52:24 +0000 | |||
2263 | +++ tests/mocks/Unity/Application/MirSurface.h 2016-01-15 13:11:04 +0000 | |||
2264 | @@ -66,6 +66,9 @@ | |||
2265 | 66 | Mir::OrientationAngle orientationAngle() const override; | 66 | Mir::OrientationAngle orientationAngle() const override; |
2266 | 67 | void setOrientationAngle(Mir::OrientationAngle) override; | 67 | void setOrientationAngle(Mir::OrientationAngle) override; |
2267 | 68 | 68 | ||
2268 | 69 | QString dbusMenuName() const override; | ||
2269 | 70 | QString dbusMenuObjectPath() const override; | ||
2270 | 71 | |||
2271 | 69 | //// | 72 | //// |
2272 | 70 | // API for tests | 73 | // API for tests |
2273 | 71 | 74 | ||
2274 | 72 | 75 | ||
2275 | === modified file 'tests/mocks/Utils/CMakeLists.txt' | |||
2276 | --- tests/mocks/Utils/CMakeLists.txt 2015-10-28 10:32:47 +0000 | |||
2277 | +++ tests/mocks/Utils/CMakeLists.txt 2016-01-15 13:11:04 +0000 | |||
2278 | @@ -19,6 +19,7 @@ | |||
2279 | 19 | ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp | 19 | ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp |
2280 | 20 | ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp | 20 | ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp |
2281 | 21 | ${CMAKE_SOURCE_DIR}/plugins/Utils/applicationsfiltermodel.cpp | 21 | ${CMAKE_SOURCE_DIR}/plugins/Utils/applicationsfiltermodel.cpp |
2282 | 22 | ${CMAKE_SOURCE_DIR}/plugins/Utils/shortcutaction.cpp | ||
2283 | 22 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h | 23 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h |
2284 | 23 | constants.cpp | 24 | constants.cpp |
2285 | 24 | plugin.cpp | 25 | plugin.cpp |
2286 | 25 | 26 | ||
2287 | === modified file 'tests/mocks/Utils/constants.cpp' | |||
2288 | --- tests/mocks/Utils/constants.cpp 2015-04-15 14:52:01 +0000 | |||
2289 | +++ tests/mocks/Utils/constants.cpp 2016-01-15 13:11:04 +0000 | |||
2290 | @@ -20,4 +20,11 @@ | |||
2291 | 20 | : QObject(parent) | 20 | : QObject(parent) |
2292 | 21 | { | 21 | { |
2293 | 22 | m_indicatorValueTimeout = 5000; | 22 | m_indicatorValueTimeout = 5000; |
2294 | 23 | m_menuHoverOpenInterval = 250; | ||
2295 | 24 | } | ||
2296 | 25 | |||
2297 | 26 | void Constants::setMenuHoverOpenInterval(int menuHoverOpenInterval) | ||
2298 | 27 | { | ||
2299 | 28 | m_menuHoverOpenInterval = menuHoverOpenInterval; | ||
2300 | 29 | Q_EMIT menuHoverOpenIntervalChanged(); | ||
2301 | 23 | } | 30 | } |
2302 | 24 | 31 | ||
2303 | === modified file 'tests/mocks/Utils/constants.h' | |||
2304 | --- tests/mocks/Utils/constants.h 2015-04-15 14:52:01 +0000 | |||
2305 | +++ tests/mocks/Utils/constants.h 2016-01-15 13:11:04 +0000 | |||
2306 | @@ -30,14 +30,21 @@ | |||
2307 | 30 | { | 30 | { |
2308 | 31 | Q_OBJECT | 31 | Q_OBJECT |
2309 | 32 | Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT) | 32 | Q_PROPERTY(int indicatorValueTimeout READ indicatorValueTimeout CONSTANT) |
2310 | 33 | Q_PROPERTY(int menuHoverOpenInterval READ menuHoverOpenInterval WRITE setMenuHoverOpenInterval NOTIFY menuHoverOpenIntervalChanged) | ||
2311 | 33 | 34 | ||
2312 | 34 | public: | 35 | public: |
2313 | 35 | Constants(QObject *parent = 0); | 36 | Constants(QObject *parent = 0); |
2314 | 36 | 37 | ||
2315 | 37 | int indicatorValueTimeout() const { return m_indicatorValueTimeout; } | 38 | int indicatorValueTimeout() const { return m_indicatorValueTimeout; } |
2316 | 39 | int menuHoverOpenInterval() const { return m_menuHoverOpenInterval; } | ||
2317 | 40 | void setMenuHoverOpenInterval(int menuHoverOpenInterval); | ||
2318 | 41 | |||
2319 | 42 | Q_SIGNALS: | ||
2320 | 43 | void menuHoverOpenIntervalChanged(); | ||
2321 | 38 | 44 | ||
2322 | 39 | private: | 45 | private: |
2323 | 40 | int m_indicatorValueTimeout; | 46 | int m_indicatorValueTimeout; |
2324 | 47 | int m_menuHoverOpenInterval; | ||
2325 | 41 | }; | 48 | }; |
2326 | 42 | 49 | ||
2327 | 43 | #endif | 50 | #endif |
2328 | 44 | 51 | ||
2329 | === modified file 'tests/mocks/Utils/plugin.cpp' | |||
2330 | --- tests/mocks/Utils/plugin.cpp 2015-10-28 10:32:47 +0000 | |||
2331 | +++ tests/mocks/Utils/plugin.cpp 2016-01-15 13:11:04 +0000 | |||
2332 | @@ -36,6 +36,7 @@ | |||
2333 | 36 | #include <windowscreenshotprovider.h> | 36 | #include <windowscreenshotprovider.h> |
2334 | 37 | #include <easingcurve.h> | 37 | #include <easingcurve.h> |
2335 | 38 | #include <applicationsfiltermodel.h> | 38 | #include <applicationsfiltermodel.h> |
2336 | 39 | #include <shortcutaction.h> | ||
2337 | 39 | 40 | ||
2338 | 40 | static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine) | 41 | static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine) |
2339 | 41 | { | 42 | { |
2340 | @@ -65,6 +66,7 @@ | |||
2341 | 65 | qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants); | 66 | qmlRegisterSingletonType<Constants>(uri, 0, 1, "Constants", createConstants); |
2342 | 66 | qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger"); | 67 | qmlRegisterType<ActiveFocusLogger>(uri, 0, 1, "ActiveFocusLogger"); |
2343 | 67 | qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel"); | 68 | qmlRegisterType<ApplicationsFilterModel>(uri, 0, 1, "ApplicationsFilterModel"); |
2344 | 69 | qmlRegisterType<ShortcutAction>(uri, 0, 1, "ShortcutAction"); | ||
2345 | 68 | } | 70 | } |
2346 | 69 | 71 | ||
2347 | 70 | void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 72 | void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
2348 | 71 | 73 | ||
2349 | === added directory 'tests/qmltests/ApplicationMenus' | |||
2350 | === added file 'tests/qmltests/ApplicationMenus/tst_MenuBar.qml' | |||
2351 | --- tests/qmltests/ApplicationMenus/tst_MenuBar.qml 1970-01-01 00:00:00 +0000 | |||
2352 | +++ tests/qmltests/ApplicationMenus/tst_MenuBar.qml 2016-01-15 13:11:04 +0000 | |||
2353 | @@ -0,0 +1,132 @@ | |||
2354 | 1 | /* | ||
2355 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
2356 | 3 | * | ||
2357 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2358 | 5 | * it under the terms of the GNU General Public License as published by | ||
2359 | 6 | * the Free Software Foundation; version 3. | ||
2360 | 7 | * | ||
2361 | 8 | * This program is distributed in the hope that it will be useful, | ||
2362 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2363 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2364 | 11 | * GNU General Public License for more details. | ||
2365 | 12 | * | ||
2366 | 13 | * You should have received a copy of the GNU General Public License | ||
2367 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2368 | 15 | */ | ||
2369 | 16 | |||
2370 | 17 | import QtQuick 2.4 | ||
2371 | 18 | import QtTest 1.0 | ||
2372 | 19 | import Ubuntu.Components 1.3 | ||
2373 | 20 | import Ubuntu.Components.ListItems 1.3 | ||
2374 | 21 | import Unity.Application 0.1 | ||
2375 | 22 | import QMenuModel 0.1 | ||
2376 | 23 | import Unity.Test 0.1 | ||
2377 | 24 | import Utils 0.1 | ||
2378 | 25 | |||
2379 | 26 | import "../../../qml/ApplicationMenus" | ||
2380 | 27 | import "../Stages" | ||
2381 | 28 | |||
2382 | 29 | Item { | ||
2383 | 30 | id: root | ||
2384 | 31 | width: units.gu(100) | ||
2385 | 32 | height: units.gu(50) | ||
2386 | 33 | |||
2387 | 34 | Component.onCompleted: { | ||
2388 | 35 | Constants.menuHoverOpenInterval = 1; | ||
2389 | 36 | } | ||
2390 | 37 | |||
2391 | 38 | DesktopMenuData { id: desktopMenuData } | ||
2392 | 39 | |||
2393 | 40 | Rectangle { | ||
2394 | 41 | anchors { | ||
2395 | 42 | left: parent.left | ||
2396 | 43 | right: parent.right | ||
2397 | 44 | top: parent.top | ||
2398 | 45 | margins: units.gu(1) | ||
2399 | 46 | } | ||
2400 | 47 | height: units.gu(3) | ||
2401 | 48 | color: "grey" | ||
2402 | 49 | |||
2403 | 50 | MenuBar { | ||
2404 | 51 | id: menuBar | ||
2405 | 52 | anchors.fill: parent | ||
2406 | 53 | |||
2407 | 54 | focusWindow: root | ||
2408 | 55 | enableMnemonic: true | ||
2409 | 56 | menuModel: UnityMenuModel { | ||
2410 | 57 | id: menuBackend | ||
2411 | 58 | modelData: desktopMenuData.testData | ||
2412 | 59 | } | ||
2413 | 60 | } | ||
2414 | 61 | } | ||
2415 | 62 | |||
2416 | 63 | SignalSpy { | ||
2417 | 64 | id: activatedSpy | ||
2418 | 65 | target: menuBackend | ||
2419 | 66 | signalName: "activated" | ||
2420 | 67 | } | ||
2421 | 68 | |||
2422 | 69 | UnityTestCase { | ||
2423 | 70 | id: testCase | ||
2424 | 71 | name: "MenuPage" | ||
2425 | 72 | when: windowShown | ||
2426 | 73 | |||
2427 | 74 | property bool clickNavigate: true | ||
2428 | 75 | |||
2429 | 76 | function init() { | ||
2430 | 77 | menuBar.closePopup(); | ||
2431 | 78 | menuBackend.modelData = desktopMenuData.generateTestData(3, 2, 0); | ||
2432 | 79 | activatedSpy.clear(); | ||
2433 | 80 | } | ||
2434 | 81 | |||
2435 | 82 | function test_mnemonics_data() { | ||
2436 | 83 | return [ | ||
2437 | 84 | { tag: "a" }, | ||
2438 | 85 | { tag: "b" }, | ||
2439 | 86 | ] | ||
2440 | 87 | } | ||
2441 | 88 | |||
2442 | 89 | function test_mnemonics(data) { | ||
2443 | 90 | menuBackend.modelData = desktopMenuData.generateTestData(3, 2, 0); | ||
2444 | 91 | |||
2445 | 92 | keyPress(data.tag, Qt.AltModifier, 100); | ||
2446 | 93 | tryCompareFunction(function() { return menuBar.openItem !== undefined; }, true); | ||
2447 | 94 | } | ||
2448 | 95 | |||
2449 | 96 | function test_navigateRight(data) { | ||
2450 | 97 | var menuItem0 = findChild(menuBar, "menuBar-menu0"); verify(menuItem0); | ||
2451 | 98 | var menuItem1 = findChild(menuBar, "menuBar-menu1"); verify(menuItem1); | ||
2452 | 99 | var menuItem2 = findChild(menuBar, "menuBar-menu2"); verify(menuItem2); | ||
2453 | 100 | |||
2454 | 101 | menuBar.open(menuItem0, true); | ||
2455 | 102 | compare(menuBar.openItem, menuItem0); | ||
2456 | 103 | |||
2457 | 104 | keyClick(Qt.Key_Right, Qt.NoModifier); | ||
2458 | 105 | compare(menuBar.openItem, menuItem1); | ||
2459 | 106 | |||
2460 | 107 | keyClick(Qt.Key_Right, Qt.NoModifier); | ||
2461 | 108 | compare(menuBar.openItem, menuItem2); | ||
2462 | 109 | |||
2463 | 110 | keyClick(Qt.Key_Right, Qt.NoModifier); | ||
2464 | 111 | compare(menuBar.openItem, menuItem0); | ||
2465 | 112 | } | ||
2466 | 113 | |||
2467 | 114 | function test_navigateLeft(data) { | ||
2468 | 115 | var menuItem0 = findChild(menuBar, "menuBar-menu0"); verify(menuItem0); | ||
2469 | 116 | var menuItem1 = findChild(menuBar, "menuBar-menu1"); verify(menuItem1); | ||
2470 | 117 | var menuItem2 = findChild(menuBar, "menuBar-menu2"); verify(menuItem2); | ||
2471 | 118 | |||
2472 | 119 | menuBar.open(menuItem0, true); | ||
2473 | 120 | compare(menuBar.openItem, menuItem0); | ||
2474 | 121 | |||
2475 | 122 | keyClick(Qt.Key_Left, Qt.NoModifier); | ||
2476 | 123 | compare(menuBar.openItem, menuItem2); | ||
2477 | 124 | |||
2478 | 125 | keyClick(Qt.Key_Left, Qt.NoModifier); | ||
2479 | 126 | compare(menuBar.openItem, menuItem1); | ||
2480 | 127 | |||
2481 | 128 | keyClick(Qt.Key_Left, Qt.NoModifier); | ||
2482 | 129 | compare(menuBar.openItem, menuItem0); | ||
2483 | 130 | } | ||
2484 | 131 | } | ||
2485 | 132 | } | ||
2486 | 0 | 133 | ||
2487 | === added file 'tests/qmltests/ApplicationMenus/tst_MenuPage.qml' | |||
2488 | --- tests/qmltests/ApplicationMenus/tst_MenuPage.qml 1970-01-01 00:00:00 +0000 | |||
2489 | +++ tests/qmltests/ApplicationMenus/tst_MenuPage.qml 2016-01-15 13:11:04 +0000 | |||
2490 | @@ -0,0 +1,256 @@ | |||
2491 | 1 | /* | ||
2492 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
2493 | 3 | * | ||
2494 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2495 | 5 | * it under the terms of the GNU General Public License as published by | ||
2496 | 6 | * the Free Software Foundation; version 3. | ||
2497 | 7 | * | ||
2498 | 8 | * This program is distributed in the hope that it will be useful, | ||
2499 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2500 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2501 | 11 | * GNU General Public License for more details. | ||
2502 | 12 | * | ||
2503 | 13 | * You should have received a copy of the GNU General Public License | ||
2504 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2505 | 15 | */ | ||
2506 | 16 | |||
2507 | 17 | import QtQuick 2.4 | ||
2508 | 18 | import QtTest 1.0 | ||
2509 | 19 | import Ubuntu.Components 1.3 | ||
2510 | 20 | import Ubuntu.Components.ListItems 1.3 | ||
2511 | 21 | import Unity.Application 0.1 | ||
2512 | 22 | import QMenuModel 0.1 | ||
2513 | 23 | import Unity.Test 0.1 | ||
2514 | 24 | import Utils 0.1 | ||
2515 | 25 | |||
2516 | 26 | import "../../../qml/ApplicationMenus" | ||
2517 | 27 | import "../Stages" | ||
2518 | 28 | |||
2519 | 29 | Item { | ||
2520 | 30 | id: root | ||
2521 | 31 | width: Math.max(units.gu(100), page.width + units.gu(6)) | ||
2522 | 32 | height: Math.max(units.gu(50), page.height + units.gu(6)) | ||
2523 | 33 | |||
2524 | 34 | Component.onCompleted: { | ||
2525 | 35 | Constants.menuHoverOpenInterval = 1; | ||
2526 | 36 | } | ||
2527 | 37 | |||
2528 | 38 | DesktopMenuData { id: desktopMenuData } | ||
2529 | 39 | |||
2530 | 40 | Keys.onEscapePressed: { | ||
2531 | 41 | page.closePopup(true); | ||
2532 | 42 | } | ||
2533 | 43 | |||
2534 | 44 | MenuPage { | ||
2535 | 45 | id: page | ||
2536 | 46 | focus: true | ||
2537 | 47 | |||
2538 | 48 | anchors { | ||
2539 | 49 | left: parent.left | ||
2540 | 50 | top: parent.top | ||
2541 | 51 | leftMargin: units.gu(3) | ||
2542 | 52 | topMargin: units.gu(3) | ||
2543 | 53 | } | ||
2544 | 54 | |||
2545 | 55 | delegateModel: rootDelegate.submenuItems | ||
2546 | 56 | MenuItemDelegateBase { | ||
2547 | 57 | id: rootDelegate | ||
2548 | 58 | menuModel: UnityMenuModel { | ||
2549 | 59 | id: menuBackend | ||
2550 | 60 | modelData: desktopMenuData.generateTestData(3, 3, 0); | ||
2551 | 61 | } | ||
2552 | 62 | } | ||
2553 | 63 | } | ||
2554 | 64 | |||
2555 | 65 | SignalSpy { | ||
2556 | 66 | id: activatedSpy | ||
2557 | 67 | target: menuBackend | ||
2558 | 68 | signalName: "activated" | ||
2559 | 69 | } | ||
2560 | 70 | |||
2561 | 71 | UnityTestCase { | ||
2562 | 72 | id: testCase | ||
2563 | 73 | name: "MenuPage" | ||
2564 | 74 | when: windowShown | ||
2565 | 75 | |||
2566 | 76 | property bool clickNavigate: true | ||
2567 | 77 | |||
2568 | 78 | function init() { | ||
2569 | 79 | page.closePopup(true); | ||
2570 | 80 | menuBackend.modelData = desktopMenuData.generateTestData(3, 3, 0); | ||
2571 | 81 | activatedSpy.clear(); | ||
2572 | 82 | } | ||
2573 | 83 | |||
2574 | 84 | // visit and verify that all the backend menus have been created | ||
2575 | 85 | function recurseMenuConstruction(rows, menuPageName) { | ||
2576 | 86 | for (var i = 0; i < rows.length; ++i) { | ||
2577 | 87 | var rowData = rows[i]["rowData"]; | ||
2578 | 88 | |||
2579 | 89 | var menuPage = findChild(page, menuPageName); | ||
2580 | 90 | verify(menuPage); | ||
2581 | 91 | var menuItem = findChild(menuPage, menuPageName+"-menu"+i); | ||
2582 | 92 | verify(menuItem); | ||
2583 | 93 | |||
2584 | 94 | // recurse into submenu | ||
2585 | 95 | var submenu = rows[i]["submenu"]; | ||
2586 | 96 | if (submenu) { | ||
2587 | 97 | if (clickNavigate) { | ||
2588 | 98 | mouseClick(menuItem, menuItem.width/2, menuItem.height/2); | ||
2589 | 99 | } else { | ||
2590 | 100 | mouseMove(menuItem, menuItem.width/2, menuItem.height/2); | ||
2591 | 101 | } | ||
2592 | 102 | tryCompare(menuPage, "openItem", menuItem); | ||
2593 | 103 | recurseMenuConstruction(submenu, menuPageName+"-subMenu"+i); | ||
2594 | 104 | } | ||
2595 | 105 | } | ||
2596 | 106 | } | ||
2597 | 107 | |||
2598 | 108 | function test_hoverNavigation_data() { | ||
2599 | 109 | return [ | ||
2600 | 110 | { tag: "long", testData: desktopMenuData.generateTestData(4, 2, 0) }, | ||
2601 | 111 | { tag: "deep", testData: desktopMenuData.generateTestData(2, 4, 0) } | ||
2602 | 112 | ] | ||
2603 | 113 | } | ||
2604 | 114 | |||
2605 | 115 | function test_hoverNavigation(data) { | ||
2606 | 116 | clickNavigate = false; | ||
2607 | 117 | menuBackend.modelData = data.testData; | ||
2608 | 118 | |||
2609 | 119 | recurseMenuConstruction(data.testData, "menuPage"); | ||
2610 | 120 | } | ||
2611 | 121 | |||
2612 | 122 | function test_clickNavigation_data() { | ||
2613 | 123 | return [ | ||
2614 | 124 | { tag: "long", testData: desktopMenuData.generateTestData(4, 2, 0) }, | ||
2615 | 125 | { tag: "deep", testData: desktopMenuData.generateTestData(2, 4, 0) } | ||
2616 | 126 | ] | ||
2617 | 127 | } | ||
2618 | 128 | |||
2619 | 129 | function test_clickNavigation(data) { | ||
2620 | 130 | clickNavigate = true; | ||
2621 | 131 | menuBackend.modelData = data.testData; | ||
2622 | 132 | |||
2623 | 133 | recurseMenuConstruction(data.testData, "menuPage"); | ||
2624 | 134 | } | ||
2625 | 135 | |||
2626 | 136 | function test_checkableMenuTogglesOnClick() { | ||
2627 | 137 | menuBackend.modelData = desktopMenuData.singleCheckable; | ||
2628 | 138 | |||
2629 | 139 | var menuItem = findChild(page, "menuPage-menu0"); | ||
2630 | 140 | verify(menuItem); | ||
2631 | 141 | verify(menuItem.delegate.isCheck); | ||
2632 | 142 | verify(menuItem.delegate.isToggled === false); | ||
2633 | 143 | |||
2634 | 144 | mouseClick(menuItem, menuItem.width/2, menuItem.height/2); | ||
2635 | 145 | |||
2636 | 146 | compare(menuItem.delegate.isToggled, true, "Checkable menu should have toggled"); | ||
2637 | 147 | } | ||
2638 | 148 | |||
2639 | 149 | function test_keyboardNavigation_DownKeySelectsAndOpensNextMenuItemAndRotates() { | ||
2640 | 150 | menuBackend.modelData = desktopMenuData.generateTestData(4, 2, 3); | ||
2641 | 151 | var listView = findChild(page, "menuPage-ListView"); | ||
2642 | 152 | verify(listView); | ||
2643 | 153 | |||
2644 | 154 | var menuItem0 = findChild(page, "menuPage-menu0"); verify(menuItem0); | ||
2645 | 155 | var menuItem1 = findChild(page, "menuPage-menu1"); verify(menuItem1); | ||
2646 | 156 | var menuItem2 = findChild(page, "menuPage-menu2"); verify(menuItem2); | ||
2647 | 157 | verify(menuItem2.delegate.isSeparator); | ||
2648 | 158 | var menuItem3 = findChild(page, "menuPage-menu3"); verify(menuItem3); | ||
2649 | 159 | |||
2650 | 160 | keyClick(Qt.Key_Down, Qt.NoModifier, 100); | ||
2651 | 161 | compare(listView.selectedItem, menuItem0); | ||
2652 | 162 | tryCompare(page, "openItem", menuItem0); | ||
2653 | 163 | |||
2654 | 164 | keyClick(Qt.Key_Down, Qt.NoModifier, 100); | ||
2655 | 165 | compare(listView.selectedItem, menuItem1); | ||
2656 | 166 | tryCompare(page, "openItem", menuItem1); | ||
2657 | 167 | |||
2658 | 168 | // Skip separator | ||
2659 | 169 | |||
2660 | 170 | keyClick(Qt.Key_Down, Qt.NoModifier, 100); | ||
2661 | 171 | compare(listView.selectedItem, menuItem3); | ||
2662 | 172 | tryCompare(page, "openItem", menuItem3); | ||
2663 | 173 | |||
2664 | 174 | keyClick(Qt.Key_Down, Qt.NoModifier, 100); | ||
2665 | 175 | compare(listView.selectedItem, menuItem0); | ||
2666 | 176 | tryCompare(page, "openItem", menuItem0); | ||
2667 | 177 | } | ||
2668 | 178 | |||
2669 | 179 | function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() { | ||
2670 | 180 | menuBackend.modelData = desktopMenuData.generateTestData(4, 2, 3); | ||
2671 | 181 | var listView = findChild(page, "menuPage-ListView"); | ||
2672 | 182 | verify(listView); | ||
2673 | 183 | |||
2674 | 184 | var menuItem0 = findChild(page, "menuPage-menu0"); verify(menuItem0); | ||
2675 | 185 | var menuItem1 = findChild(page, "menuPage-menu1"); verify(menuItem1); | ||
2676 | 186 | var menuItem2 = findChild(page, "menuPage-menu2"); verify(menuItem2); | ||
2677 | 187 | verify(menuItem2.delegate.isSeparator); | ||
2678 | 188 | var menuItem3 = findChild(page, "menuPage-menu3"); verify(menuItem3); | ||
2679 | 189 | |||
2680 | 190 | keyClick(Qt.Key_Up, Qt.NoModifier, 100); | ||
2681 | 191 | compare(listView.selectedItem, menuItem3); | ||
2682 | 192 | tryCompare(page, "openItem", menuItem3); | ||
2683 | 193 | |||
2684 | 194 | // Skip separator | ||
2685 | 195 | |||
2686 | 196 | keyClick(Qt.Key_Up, Qt.NoModifier, 100); | ||
2687 | 197 | compare(listView.selectedItem, menuItem1); | ||
2688 | 198 | tryCompare(page, "openItem", menuItem1); | ||
2689 | 199 | |||
2690 | 200 | keyClick(Qt.Key_Up, Qt.NoModifier, 100); | ||
2691 | 201 | compare(listView.selectedItem, menuItem0); | ||
2692 | 202 | tryCompare(page, "openItem", menuItem0); | ||
2693 | 203 | |||
2694 | 204 | keyClick(Qt.Key_Up, Qt.NoModifier, 100); | ||
2695 | 205 | compare(listView.selectedItem, menuItem3); | ||
2696 | 206 | tryCompare(page, "openItem", menuItem3); | ||
2697 | 207 | } | ||
2698 | 208 | |||
2699 | 209 | function test_keyboardNavigation_RightKeyEntersSubMenu() { | ||
2700 | 210 | menuBackend.modelData = desktopMenuData.generateTestData(2, 2, 0); | ||
2701 | 211 | |||
2702 | 212 | var menuItem = findChild(page, "menuPage-menu0"); | ||
2703 | 213 | verify(menuItem); | ||
2704 | 214 | page.open(menuItem, true); | ||
2705 | 215 | compare(page.openItem, menuItem); | ||
2706 | 216 | |||
2707 | 217 | var submenu = findChild(page, "menuPage-subMenu0"); | ||
2708 | 218 | verify(submenu); | ||
2709 | 219 | var listView = findChild(page, "menuPage-subMenu0-ListView"); | ||
2710 | 220 | verify(listView); | ||
2711 | 221 | menuItem = findChild(page, "menuPage-subMenu0-menu0"); | ||
2712 | 222 | verify(menuItem); | ||
2713 | 223 | |||
2714 | 224 | keyClick(Qt.Key_Right, Qt.NoModifier); | ||
2715 | 225 | compare(listView.selectedItem, menuItem); | ||
2716 | 226 | } | ||
2717 | 227 | |||
2718 | 228 | function test_keyboardNavigation_LeftKeyClosesSubMenu() { | ||
2719 | 229 | menuBackend.modelData = desktopMenuData.generateTestData(2, 2, 0); | ||
2720 | 230 | |||
2721 | 231 | var menuItem = findChild(page, "menuPage-menu0"); | ||
2722 | 232 | verify(menuItem); | ||
2723 | 233 | page.open(menuItem, true, 0); // quick open & select item 0 | ||
2724 | 234 | |||
2725 | 235 | compare(page.openItem, menuItem); | ||
2726 | 236 | keyClick(Qt.Key_Left, Qt.NoModifier); | ||
2727 | 237 | compare(page.openItem, undefined); | ||
2728 | 238 | } | ||
2729 | 239 | |||
2730 | 240 | function test_mnemonics() { | ||
2731 | 241 | var menuItem0 = findChild(page, "menuPage-menu0"); verify(menuItem0); | ||
2732 | 242 | |||
2733 | 243 | keyClick(Qt.Key_A, Qt.NoModifier); | ||
2734 | 244 | tryCompare(page, "openItem", menuItem0); | ||
2735 | 245 | |||
2736 | 246 | var submenu0 = findChild(menuItem0, "menuPage-subMenu0"); verify(submenu0); | ||
2737 | 247 | var submenu0_menuItem1 = findChild(submenu0, "menuPage-subMenu0-menu1"); verify(submenu0_menuItem1); | ||
2738 | 248 | |||
2739 | 249 | keyClick(Qt.Key_B, Qt.NoModifier); | ||
2740 | 250 | tryCompare(submenu0, "openItem", submenu0_menuItem1); | ||
2741 | 251 | |||
2742 | 252 | keyClick(Qt.Key_B, Qt.NoModifier); | ||
2743 | 253 | compare(activatedSpy.signalArguments, [{ "0": "menuA.B.B" }], "Activate should have been emmited once"); | ||
2744 | 254 | } | ||
2745 | 255 | } | ||
2746 | 256 | } | ||
2747 | 0 | 257 | ||
2748 | === modified file 'tests/qmltests/CMakeLists.txt' | |||
2749 | --- tests/qmltests/CMakeLists.txt 2016-01-11 17:37:50 +0000 | |||
2750 | +++ tests/qmltests/CMakeLists.txt 2016-01-15 13:11:04 +0000 | |||
2751 | @@ -5,6 +5,8 @@ | |||
2752 | 5 | add_unity8_qmltest(. DisabledScreenNotice) | 5 | add_unity8_qmltest(. DisabledScreenNotice) |
2753 | 6 | add_unity8_qmltest(. Shell LIGHTDM) | 6 | add_unity8_qmltest(. Shell LIGHTDM) |
2754 | 7 | add_unity8_qmltest(. ShellWithPin LIGHTDM) | 7 | add_unity8_qmltest(. ShellWithPin LIGHTDM) |
2755 | 8 | add_unity8_qmltest(ApplicationMenus MenuBar) | ||
2756 | 9 | add_unity8_qmltest(ApplicationMenus MenuPage) | ||
2757 | 8 | add_unity8_qmltest(Components Background) | 10 | add_unity8_qmltest(Components Background) |
2758 | 9 | add_unity8_qmltest(Components Carousel) | 11 | add_unity8_qmltest(Components Carousel) |
2759 | 10 | add_unity8_qmltest(Components Dialogs LIGHTDM) | 12 | add_unity8_qmltest(Components Dialogs LIGHTDM) |
2760 | @@ -85,6 +87,7 @@ | |||
2761 | 85 | add_unity8_qmltest(Stages SessionContainer) | 87 | add_unity8_qmltest(Stages SessionContainer) |
2762 | 86 | add_unity8_qmltest(Stages TabletStage) | 88 | add_unity8_qmltest(Stages TabletStage) |
2763 | 87 | add_unity8_qmltest(Stages WindowResizeArea) | 89 | add_unity8_qmltest(Stages WindowResizeArea) |
2764 | 90 | add_unity8_qmltest(Stages WindowDecoration) | ||
2765 | 88 | add_unity8_qmltest(Stages Splash) | 91 | add_unity8_qmltest(Stages Splash) |
2766 | 89 | add_unity8_qmltest(Tutorial Tutorial LIGHTDM) | 92 | add_unity8_qmltest(Tutorial Tutorial LIGHTDM) |
2767 | 90 | add_unity8_qmltest(Wizard Wizard ENVIRONMENT "OXIDE_NO_SANDBOX=1") | 93 | add_unity8_qmltest(Wizard Wizard ENVIRONMENT "OXIDE_NO_SANDBOX=1") |
2768 | 91 | 94 | ||
2769 | === modified file 'tests/qmltests/Panel/tst_Panel.qml' | |||
2770 | --- tests/qmltests/Panel/tst_Panel.qml 2015-11-18 15:12:56 +0000 | |||
2771 | +++ tests/qmltests/Panel/tst_Panel.qml 2016-01-15 13:11:04 +0000 | |||
2772 | @@ -24,10 +24,11 @@ | |||
2773 | 24 | import Ubuntu.Telephony 0.1 as Telephony | 24 | import Ubuntu.Telephony 0.1 as Telephony |
2774 | 25 | import "../../../qml/Panel" | 25 | import "../../../qml/Panel" |
2775 | 26 | import "../../../qml/Components/PanelState" | 26 | import "../../../qml/Components/PanelState" |
2776 | 27 | import "../Stages" | ||
2777 | 27 | 28 | ||
2778 | 28 | IndicatorTest { | 29 | IndicatorTest { |
2779 | 29 | id: root | 30 | id: root |
2781 | 30 | width: units.gu(100) | 31 | width: units.gu(120) |
2782 | 31 | height: units.gu(71) | 32 | height: units.gu(71) |
2783 | 32 | color: "white" | 33 | color: "white" |
2784 | 33 | 34 | ||
2785 | @@ -37,6 +38,17 @@ | |||
2786 | 37 | value: !windowControlsCB.checked | 38 | value: !windowControlsCB.checked |
2787 | 38 | } | 39 | } |
2788 | 39 | 40 | ||
2789 | 41 | DesktopMenuData { id: appMenuData } | ||
2790 | 42 | |||
2791 | 43 | Component.onCompleted: { | ||
2792 | 44 | Indicators.UnityMenuModelCache.setCachedModelData("/dialer-app", appMenuData.dialerData); | ||
2793 | 45 | } | ||
2794 | 46 | |||
2795 | 47 | Rectangle { | ||
2796 | 48 | anchors.fill: parent | ||
2797 | 49 | color: "darkgrey" | ||
2798 | 50 | } | ||
2799 | 51 | |||
2800 | 40 | RowLayout { | 52 | RowLayout { |
2801 | 41 | anchors.fill: parent | 53 | anchors.fill: parent |
2802 | 42 | anchors.margins: units.gu(1) | 54 | anchors.margins: units.gu(1) |
2803 | @@ -105,10 +117,11 @@ | |||
2804 | 105 | Layout.fillWidth: true | 117 | Layout.fillWidth: true |
2805 | 106 | CheckBox { | 118 | CheckBox { |
2806 | 107 | id: windowControlsCB | 119 | id: windowControlsCB |
2808 | 108 | onClicked: PanelState.buttonsVisible = checked | 120 | onClicked: PanelState.decorationsVisible = checked |
2809 | 109 | } | 121 | } |
2810 | 110 | Label { | 122 | Label { |
2812 | 111 | text: "Show window controls" | 123 | text: "Show window decorations" |
2813 | 124 | color: "white" | ||
2814 | 112 | } | 125 | } |
2815 | 113 | } | 126 | } |
2816 | 114 | 127 | ||
2817 | @@ -124,6 +137,7 @@ | |||
2818 | 124 | } | 137 | } |
2819 | 125 | Label { | 138 | Label { |
2820 | 126 | text: "Show fake window title" | 139 | text: "Show fake window title" |
2821 | 140 | color: "white" | ||
2822 | 127 | } | 141 | } |
2823 | 128 | } | 142 | } |
2824 | 129 | 143 | ||
2825 | @@ -133,6 +147,19 @@ | |||
2826 | 133 | color: "black" | 147 | color: "black" |
2827 | 134 | } | 148 | } |
2828 | 135 | 149 | ||
2829 | 150 | ApplicationCheckBox { | ||
2830 | 151 | id: applicationCheckBox | ||
2831 | 152 | Layout.fillWidth: true | ||
2832 | 153 | appId: "dialer-app" | ||
2833 | 154 | onTriggered: PanelState.maximizedApplication = checked ? "dialer-app" : ""; | ||
2834 | 155 | } | ||
2835 | 156 | |||
2836 | 157 | Rectangle { | ||
2837 | 158 | Layout.preferredHeight: units.dp(1); | ||
2838 | 159 | Layout.fillWidth: true; | ||
2839 | 160 | color: "black" | ||
2840 | 161 | } | ||
2841 | 162 | |||
2842 | 136 | Repeater { | 163 | Repeater { |
2843 | 137 | model: root.originalModelData | 164 | model: root.originalModelData |
2844 | 138 | RowLayout { | 165 | RowLayout { |
2845 | @@ -143,6 +170,7 @@ | |||
2846 | 143 | Label { | 170 | Label { |
2847 | 144 | Layout.fillWidth: true | 171 | Layout.fillWidth: true |
2848 | 145 | text: modelData["identifier"] | 172 | text: modelData["identifier"] |
2849 | 173 | color: "white" | ||
2850 | 146 | } | 174 | } |
2851 | 147 | 175 | ||
2852 | 148 | CheckBox { | 176 | CheckBox { |
2853 | @@ -151,6 +179,7 @@ | |||
2854 | 151 | } | 179 | } |
2855 | 152 | Label { | 180 | Label { |
2856 | 153 | text: "visible" | 181 | text: "visible" |
2857 | 182 | color: "white" | ||
2858 | 154 | } | 183 | } |
2859 | 155 | } | 184 | } |
2860 | 156 | } | 185 | } |
2861 | @@ -161,7 +190,10 @@ | |||
2862 | 161 | color: "black" | 190 | color: "black" |
2863 | 162 | } | 191 | } |
2864 | 163 | 192 | ||
2866 | 164 | MouseTouchEmulationCheckbox { id: mouseEmulation } | 193 | MouseTouchEmulationCheckbox { |
2867 | 194 | id: mouseEmulation | ||
2868 | 195 | color: "white" | ||
2869 | 196 | } | ||
2870 | 165 | } | 197 | } |
2871 | 166 | } | 198 | } |
2872 | 167 | 199 | ||
2873 | @@ -492,5 +524,25 @@ | |||
2874 | 492 | compare(panel.indicators.shown, false); | 524 | compare(panel.indicators.shown, false); |
2875 | 493 | tryCompare(panel.indicators, "fullyClosed", true); | 525 | tryCompare(panel.indicators, "fullyClosed", true); |
2876 | 494 | } | 526 | } |
2877 | 527 | |||
2878 | 528 | function test_showsDecorations() { | ||
2879 | 529 | compare(panel.indicators.shown, false); | ||
2880 | 530 | verify(panel.indicators.fullyClosed); | ||
2881 | 531 | |||
2882 | 532 | mouseClick(panel.indicators, | ||
2883 | 533 | panel.indicators.width / 2, | ||
2884 | 534 | panel.indicators.minimizedPanelHeight / 2); | ||
2885 | 535 | |||
2886 | 536 | compare(panel.indicators.shown, true); | ||
2887 | 537 | tryCompare(panel.indicators, "fullyOpened", true); | ||
2888 | 538 | |||
2889 | 539 | var handle = findChild(panel.indicators, "handle"); | ||
2890 | 540 | verify(handle); | ||
2891 | 541 | |||
2892 | 542 | mouseClick(handle); | ||
2893 | 543 | |||
2894 | 544 | compare(panel.indicators.shown, false); | ||
2895 | 545 | tryCompare(panel.indicators, "fullyClosed", true); | ||
2896 | 546 | } | ||
2897 | 495 | } | 547 | } |
2898 | 496 | } | 548 | } |
2899 | 497 | 549 | ||
2900 | === modified file 'tests/qmltests/Stages/ApplicationCheckBox.qml' | |||
2901 | --- tests/qmltests/Stages/ApplicationCheckBox.qml 2015-08-11 11:41:08 +0000 | |||
2902 | +++ tests/qmltests/Stages/ApplicationCheckBox.qml 2016-01-15 13:11:04 +0000 | |||
2903 | @@ -24,6 +24,8 @@ | |||
2904 | 24 | property string appId | 24 | property string appId |
2905 | 25 | property bool checked: false | 25 | property bool checked: false |
2906 | 26 | 26 | ||
2907 | 27 | signal triggered | ||
2908 | 28 | |||
2909 | 27 | enabled: appId !== "unity8-dash" | 29 | enabled: appId !== "unity8-dash" |
2910 | 28 | 30 | ||
2911 | 29 | onCheckedChanged: { | 31 | onCheckedChanged: { |
2912 | @@ -35,6 +37,7 @@ | |||
2913 | 35 | } else { | 37 | } else { |
2914 | 36 | ApplicationManager.stopApplication(root.appId); | 38 | ApplicationManager.stopApplication(root.appId); |
2915 | 37 | } | 39 | } |
2916 | 40 | root.triggered(); | ||
2917 | 38 | d.bindGuard = false; | 41 | d.bindGuard = false; |
2918 | 39 | } | 42 | } |
2919 | 40 | 43 | ||
2920 | @@ -69,6 +72,7 @@ | |||
2921 | 69 | } else { | 72 | } else { |
2922 | 70 | ApplicationManager.stopApplication(root.appId); | 73 | ApplicationManager.stopApplication(root.appId); |
2923 | 71 | } | 74 | } |
2924 | 75 | root.triggered(); | ||
2925 | 72 | d.bindGuard = false; | 76 | d.bindGuard = false; |
2926 | 73 | } | 77 | } |
2927 | 74 | onCheckedChanged: { | 78 | onCheckedChanged: { |
2928 | 75 | 79 | ||
2929 | === added file 'tests/qmltests/Stages/DesktopMenuData.qml' | |||
2930 | --- tests/qmltests/Stages/DesktopMenuData.qml 1970-01-01 00:00:00 +0000 | |||
2931 | +++ tests/qmltests/Stages/DesktopMenuData.qml 2016-01-15 13:11:04 +0000 | |||
2932 | @@ -0,0 +1,702 @@ | |||
2933 | 1 | import QtQuick 2.4 | ||
2934 | 2 | |||
2935 | 3 | QtObject { | ||
2936 | 4 | |||
2937 | 5 | property var dialerData: [{ | ||
2938 | 6 | "rowData": { // 1.1 | ||
2939 | 7 | "label": "_dialer1", | ||
2940 | 8 | "sensitive": true, | ||
2941 | 9 | "isSeparator": false, | ||
2942 | 10 | "icon": "", | ||
2943 | 11 | "type": "com.canonical.indicator.test", | ||
2944 | 12 | "ext": {}, | ||
2945 | 13 | "action": "dialer1", | ||
2946 | 14 | "actionState": {}, | ||
2947 | 15 | "isCheck": false, | ||
2948 | 16 | "isRadio": false, | ||
2949 | 17 | "isToggled": false, | ||
2950 | 18 | "shortcut": "Alt+F" | ||
2951 | 19 | }, | ||
2952 | 20 | "submenu": [{ | ||
2953 | 21 | "rowData": { // 1.1 | ||
2954 | 22 | "label": "menu1.1", | ||
2955 | 23 | "sensitive": true, | ||
2956 | 24 | "isSeparator": false, | ||
2957 | 25 | "icon": "", | ||
2958 | 26 | "type": "com.canonical.indicator.test", | ||
2959 | 27 | "ext": {}, | ||
2960 | 28 | "action": "menu1.1", | ||
2961 | 29 | "actionState": {}, | ||
2962 | 30 | "isCheck": false, | ||
2963 | 31 | "isRadio": false, | ||
2964 | 32 | "isToggled": false, | ||
2965 | 33 | "shortcut": "Alt+0" | ||
2966 | 34 | }}, { | ||
2967 | 35 | "rowData": { // 1.2 | ||
2968 | 36 | "label": "menu1.2", | ||
2969 | 37 | "sensitive": true, | ||
2970 | 38 | "isSeparator": false, | ||
2971 | 39 | "icon": "", | ||
2972 | 40 | "type": "com.canonical.indicator.test", | ||
2973 | 41 | "ext": {}, | ||
2974 | 42 | "action": "menu1.2", | ||
2975 | 43 | "actionState": {}, | ||
2976 | 44 | "isCheck": false, | ||
2977 | 45 | "isRadio": false, | ||
2978 | 46 | "isToggled": false, | ||
2979 | 47 | "shortcut": "Alt+1" | ||
2980 | 48 | }, | ||
2981 | 49 | "submenu": [{ | ||
2982 | 50 | "rowData": { // 1.2.1 | ||
2983 | 51 | "label": "menu1.2.1", | ||
2984 | 52 | "sensitive": true, | ||
2985 | 53 | "isSeparator": false, | ||
2986 | 54 | "icon": "", | ||
2987 | 55 | "type": "com.canonical.indicator.test", | ||
2988 | 56 | "ext": {}, | ||
2989 | 57 | "action": "menu1.2.1", | ||
2990 | 58 | "actionState": {}, | ||
2991 | 59 | "isCheck": false, | ||
2992 | 60 | "isRadio": false, | ||
2993 | 61 | "isToggled": false, | ||
2994 | 62 | "shortcut": "" | ||
2995 | 63 | }}, { | ||
2996 | 64 | "rowData": { // 1.2.2 | ||
2997 | 65 | "label": "menu1.2.2", | ||
2998 | 66 | "sensitive": true, | ||
2999 | 67 | "isSeparator": false, | ||
3000 | 68 | "icon": "", | ||
3001 | 69 | "type": "com.canonical.indicator.test", | ||
3002 | 70 | "ext": {}, | ||
3003 | 71 | "action": "menu1.2.2", | ||
3004 | 72 | "actionState": {}, | ||
3005 | 73 | "isCheck": false, | ||
3006 | 74 | "isRadio": false, | ||
3007 | 75 | "isToggled": false, | ||
3008 | 76 | "shortcut": "" | ||
3009 | 77 | }}, { | ||
3010 | 78 | "rowData": { // 1.2.3 | ||
3011 | 79 | "label": "", | ||
3012 | 80 | "sensitive": false, | ||
3013 | 81 | "isSeparator": true, | ||
3014 | 82 | "icon": "", | ||
3015 | 83 | "type": "", | ||
3016 | 84 | "ext": {}, | ||
3017 | 85 | "action": "", | ||
3018 | 86 | "actionState": {}, | ||
3019 | 87 | "isCheck": false, | ||
3020 | 88 | "isRadio": false, | ||
3021 | 89 | "isToggled": false, | ||
3022 | 90 | "shortcut": "" | ||
3023 | 91 | }}, { | ||
3024 | 92 | "rowData": { // row 1.2.4 | ||
3025 | 93 | "label": "menu1.2.4", | ||
3026 | 94 | "sensitive": true, | ||
3027 | 95 | "isSeparator": false, | ||
3028 | 96 | "icon": "", | ||
3029 | 97 | "type": "com.canonical.indicator.test", | ||
3030 | 98 | "ext": {}, | ||
3031 | 99 | "action": "menu1.2.4", | ||
3032 | 100 | "actionState": {}, | ||
3033 | 101 | "isCheck": false, | ||
3034 | 102 | "isRadio": false, | ||
3035 | 103 | "isToggled": true, | ||
3036 | 104 | "shortcut": "" | ||
3037 | 105 | }} | ||
3038 | 106 | ]}, { | ||
3039 | 107 | "rowData": { // 1.3 | ||
3040 | 108 | "label": "", | ||
3041 | 109 | "sensitive": false, | ||
3042 | 110 | "isSeparator": true, | ||
3043 | 111 | "icon": "", | ||
3044 | 112 | "type": "", | ||
3045 | 113 | "ext": {}, | ||
3046 | 114 | "action": "", | ||
3047 | 115 | "actionState": {}, | ||
3048 | 116 | "isCheck": false, | ||
3049 | 117 | "isRadio": false, | ||
3050 | 118 | "isToggled": false, | ||
3051 | 119 | "shortcut": "" | ||
3052 | 120 | }}, { | ||
3053 | 121 | "rowData": { // row 1.4 | ||
3054 | 122 | "label": "menu1.4", | ||
3055 | 123 | "sensitive": true, | ||
3056 | 124 | "isSeparator": false, | ||
3057 | 125 | "icon": "", | ||
3058 | 126 | "type": "com.canonical.indicator.test", | ||
3059 | 127 | "ext": {}, | ||
3060 | 128 | "action": "menu1.4", | ||
3061 | 129 | "actionState": {}, | ||
3062 | 130 | "isCheck": true, | ||
3063 | 131 | "isRadio": false, | ||
3064 | 132 | "isToggled": true, | ||
3065 | 133 | "shortcut": "Alt+2" | ||
3066 | 134 | }} | ||
3067 | 135 | ]}, { | ||
3068 | 136 | "rowData": { // 2 | ||
3069 | 137 | "label": "d_ialer2", | ||
3070 | 138 | "sensitive": true, | ||
3071 | 139 | "isSeparator": false, | ||
3072 | 140 | "icon": "", | ||
3073 | 141 | "type": "com.canonical.indicator.test", | ||
3074 | 142 | "ext": {}, | ||
3075 | 143 | "action": "dialer2", | ||
3076 | 144 | "actionState": {}, | ||
3077 | 145 | "isCheck": false, | ||
3078 | 146 | "isRadio": false, | ||
3079 | 147 | "isToggled": false, | ||
3080 | 148 | "shortcut": "Alt+E" | ||
3081 | 149 | }, | ||
3082 | 150 | "submenu": [{ | ||
3083 | 151 | "rowData": { // 2.1 | ||
3084 | 152 | "label": "menu2.1", | ||
3085 | 153 | "sensitive": true, | ||
3086 | 154 | "isSeparator": false, | ||
3087 | 155 | "icon": "", | ||
3088 | 156 | "type": "com.canonical.indicator.test", | ||
3089 | 157 | "ext": {}, | ||
3090 | 158 | "action": "menu2.1", | ||
3091 | 159 | "actionState": {}, | ||
3092 | 160 | "isCheck": false, | ||
3093 | 161 | "isRadio": false, | ||
3094 | 162 | "isToggled": false, | ||
3095 | 163 | "shortcut": "" | ||
3096 | 164 | }} | ||
3097 | 165 | ]}, { | ||
3098 | 166 | "rowData": { // row 3 | ||
3099 | 167 | "label": "di_aler3", | ||
3100 | 168 | "sensitive": true, | ||
3101 | 169 | "isSeparator": false, | ||
3102 | 170 | "icon": "", | ||
3103 | 171 | "type": "com.canonical.indicator.test", | ||
3104 | 172 | "ext": {}, | ||
3105 | 173 | "action": "dialer3", | ||
3106 | 174 | "actionState": {}, | ||
3107 | 175 | "isCheck": false, | ||
3108 | 176 | "isRadio": false, | ||
3109 | 177 | "isToggled": false, | ||
3110 | 178 | "shortcut": "" | ||
3111 | 179 | }, | ||
3112 | 180 | "submenu": [{ | ||
3113 | 181 | "rowData": { // 3.1 | ||
3114 | 182 | "label": "menu3.1", | ||
3115 | 183 | "sensitive": true, | ||
3116 | 184 | "isSeparator": false, | ||
3117 | 185 | "icon": "", | ||
3118 | 186 | "type": "com.canonical.indicator.test", | ||
3119 | 187 | "ext": {}, | ||
3120 | 188 | "action": "menu3.1", | ||
3121 | 189 | "actionState": {}, | ||
3122 | 190 | "isCheck": false, | ||
3123 | 191 | "isRadio": false, | ||
3124 | 192 | "isToggled": false, | ||
3125 | 193 | "shortcut": "" | ||
3126 | 194 | }} | ||
3127 | 195 | ]} | ||
3128 | 196 | ] | ||
3129 | 197 | |||
3130 | 198 | property var cameraData: [{ | ||
3131 | 199 | "rowData": { // 1.1 | ||
3132 | 200 | "label": "camera1", | ||
3133 | 201 | "sensitive": true, | ||
3134 | 202 | "isSeparator": false, | ||
3135 | 203 | "icon": "", | ||
3136 | 204 | "type": "com.canonical.indicator.test", | ||
3137 | 205 | "ext": {}, | ||
3138 | 206 | "action": "camera1", | ||
3139 | 207 | "actionState": {}, | ||
3140 | 208 | "isCheck": false, | ||
3141 | 209 | "isRadio": false, | ||
3142 | 210 | "isToggled": false, | ||
3143 | 211 | "shortcut": "" | ||
3144 | 212 | }, | ||
3145 | 213 | "submenu": [{ | ||
3146 | 214 | "rowData": { // 1.1 | ||
3147 | 215 | "label": "menu1.1", | ||
3148 | 216 | "sensitive": true, | ||
3149 | 217 | "isSeparator": false, | ||
3150 | 218 | "icon": "", | ||
3151 | 219 | "type": "com.canonical.indicator.test", | ||
3152 | 220 | "ext": {}, | ||
3153 | 221 | "action": "menu1.1", | ||
3154 | 222 | "actionState": {}, | ||
3155 | 223 | "isCheck": false, | ||
3156 | 224 | "isRadio": false, | ||
3157 | 225 | "isToggled": false, | ||
3158 | 226 | "shortcut": "" | ||
3159 | 227 | }}, { | ||
3160 | 228 | "rowData": { // 1.2 | ||
3161 | 229 | "label": "menu1.2", | ||
3162 | 230 | "sensitive": true, | ||
3163 | 231 | "isSeparator": false, | ||
3164 | 232 | "icon": "", | ||
3165 | 233 | "type": "com.canonical.indicator.test", | ||
3166 | 234 | "ext": {}, | ||
3167 | 235 | "action": "menu1.2", | ||
3168 | 236 | "actionState": {}, | ||
3169 | 237 | "isCheck": false, | ||
3170 | 238 | "isRadio": false, | ||
3171 | 239 | "isToggled": false, | ||
3172 | 240 | "shortcut": "" | ||
3173 | 241 | }}, { | ||
3174 | 242 | "rowData": { // row 1.2 | ||
3175 | 243 | "label": "menu1.2", | ||
3176 | 244 | "sensitive": true, | ||
3177 | 245 | "isSeparator": false, | ||
3178 | 246 | "icon": "", | ||
3179 | 247 | "type": "com.canonical.indicator.test", | ||
3180 | 248 | "ext": {}, | ||
3181 | 249 | "action": "menu1.2", | ||
3182 | 250 | "actionState": {}, | ||
3183 | 251 | "isCheck": false, | ||
3184 | 252 | "isRadio": false, | ||
3185 | 253 | "isToggled": false, | ||
3186 | 254 | "shortcut": "" | ||
3187 | 255 | }} | ||
3188 | 256 | ]}, { | ||
3189 | 257 | "rowData": { // 2 | ||
3190 | 258 | "label": "camera2", | ||
3191 | 259 | "sensitive": true, | ||
3192 | 260 | "isSeparator": false, | ||
3193 | 261 | "icon": "", | ||
3194 | 262 | "type": "com.canonical.indicator.test", | ||
3195 | 263 | "ext": {}, | ||
3196 | 264 | "action": "camera2", | ||
3197 | 265 | "actionState": {}, | ||
3198 | 266 | "isCheck": false, | ||
3199 | 267 | "isRadio": false, | ||
3200 | 268 | "isToggled": false, | ||
3201 | 269 | "shortcut": "" | ||
3202 | 270 | }} | ||
3203 | 271 | ] | ||
3204 | 272 | |||
3205 | 273 | property var galleryData: [{ | ||
3206 | 274 | "rowData": { // 1.1 | ||
3207 | 275 | "label": "gallery1", | ||
3208 | 276 | "sensitive": true, | ||
3209 | 277 | "isSeparator": false, | ||
3210 | 278 | "icon": "", | ||
3211 | 279 | "type": "com.canonical.indicator.test", | ||
3212 | 280 | "ext": {}, | ||
3213 | 281 | "action": "gallery1", | ||
3214 | 282 | "actionState": {}, | ||
3215 | 283 | "isCheck": false, | ||
3216 | 284 | "isRadio": false, | ||
3217 | 285 | "isToggled": false, | ||
3218 | 286 | "shortcut": "" | ||
3219 | 287 | }, | ||
3220 | 288 | "submenu": [{ | ||
3221 | 289 | "rowData": { // 1.1 | ||
3222 | 290 | "label": "menu0", | ||
3223 | 291 | "sensitive": true, | ||
3224 | 292 | "isSeparator": false, | ||
3225 | 293 | "icon": "", | ||
3226 | 294 | "type": "com.canonical.indicator.test", | ||
3227 | 295 | "ext": {}, | ||
3228 | 296 | "action": "menu0", | ||
3229 | 297 | "actionState": {}, | ||
3230 | 298 | "isCheck": false, | ||
3231 | 299 | "isRadio": false, | ||
3232 | 300 | "isToggled": false, | ||
3233 | 301 | "shortcut": "" | ||
3234 | 302 | }}, { | ||
3235 | 303 | "rowData": { // 1.2 | ||
3236 | 304 | "label": "menu1", | ||
3237 | 305 | "sensitive": true, | ||
3238 | 306 | "isSeparator": false, | ||
3239 | 307 | "icon": "", | ||
3240 | 308 | "type": "com.canonical.indicator.test", | ||
3241 | 309 | "ext": {}, | ||
3242 | 310 | "action": "menu1", | ||
3243 | 311 | "actionState": {}, | ||
3244 | 312 | "isCheck": false, | ||
3245 | 313 | "isRadio": false, | ||
3246 | 314 | "isToggled": false, | ||
3247 | 315 | "shortcut": "" | ||
3248 | 316 | }}, { | ||
3249 | 317 | "rowData": { // 1.2 | ||
3250 | 318 | "label": "", | ||
3251 | 319 | "sensitive": false, | ||
3252 | 320 | "isSeparator": true, | ||
3253 | 321 | "icon": "", | ||
3254 | 322 | "type": "", | ||
3255 | 323 | "ext": {}, | ||
3256 | 324 | "action": "", | ||
3257 | 325 | "actionState": {}, | ||
3258 | 326 | "isCheck": false, | ||
3259 | 327 | "isRadio": false, | ||
3260 | 328 | "isToggled": false, | ||
3261 | 329 | "shortcut": "" | ||
3262 | 330 | }}, { | ||
3263 | 331 | "rowData": { // row 1.2 | ||
3264 | 332 | "label": "menu2", | ||
3265 | 333 | "sensitive": true, | ||
3266 | 334 | "isSeparator": false, | ||
3267 | 335 | "icon": "", | ||
3268 | 336 | "type": "com.canonical.indicator.test", | ||
3269 | 337 | "ext": {}, | ||
3270 | 338 | "action": "menu2", | ||
3271 | 339 | "actionState": {}, | ||
3272 | 340 | "isCheck": false, | ||
3273 | 341 | "isRadio": false, | ||
3274 | 342 | "isToggled": false, | ||
3275 | 343 | "shortcut": "" | ||
3276 | 344 | }} | ||
3277 | 345 | ]}, { | ||
3278 | 346 | "rowData": { // 2 | ||
3279 | 347 | "label": "gallery2", | ||
3280 | 348 | "sensitive": true, | ||
3281 | 349 | "isSeparator": false, | ||
3282 | 350 | "icon": "", | ||
3283 | 351 | "type": "com.canonical.indicator.test", | ||
3284 | 352 | "ext": {}, | ||
3285 | 353 | "action": "gallery2", | ||
3286 | 354 | "actionState": {}, | ||
3287 | 355 | "isCheck": false, | ||
3288 | 356 | "isRadio": false, | ||
3289 | 357 | "isToggled": false, | ||
3290 | 358 | "shortcut": "" | ||
3291 | 359 | }}, { | ||
3292 | 360 | "rowData": { // row 2 | ||
3293 | 361 | "label": "gallery3", | ||
3294 | 362 | "sensitive": true, | ||
3295 | 363 | "isSeparator": false, | ||
3296 | 364 | "icon": "", | ||
3297 | 365 | "type": "com.canonical.indicator.test", | ||
3298 | 366 | "ext": {}, | ||
3299 | 367 | "action": "gallery3", | ||
3300 | 368 | "actionState": {}, | ||
3301 | 369 | "isCheck": false, | ||
3302 | 370 | "isRadio": false, | ||
3303 | 371 | "isToggled": false, | ||
3304 | 372 | "shortcut": "" | ||
3305 | 373 | }} | ||
3306 | 374 | ] | ||
3307 | 375 | |||
3308 | 376 | property var testData: [{ | ||
3309 | 377 | "rowData": { // 1 | ||
3310 | 378 | "label": "_menu1", | ||
3311 | 379 | "sensitive": true, | ||
3312 | 380 | "isSeparator": false, | ||
3313 | 381 | "icon": "", | ||
3314 | 382 | "type": "com.canonical.indicator.test", | ||
3315 | 383 | "ext": {}, | ||
3316 | 384 | "action": "menu1", | ||
3317 | 385 | "actionState": {}, | ||
3318 | 386 | "isCheck": false, | ||
3319 | 387 | "isRadio": false, | ||
3320 | 388 | "isToggled": false, | ||
3321 | 389 | "shortcut": "Alt+F" | ||
3322 | 390 | }, | ||
3323 | 391 | "submenu": [{ | ||
3324 | 392 | "rowData": { // 1.1 | ||
3325 | 393 | "label": "menu1.1", | ||
3326 | 394 | "sensitive": true, | ||
3327 | 395 | "isSeparator": false, | ||
3328 | 396 | "icon": "", | ||
3329 | 397 | "type": "com.canonical.indicator.test", | ||
3330 | 398 | "ext": {}, | ||
3331 | 399 | "action": "menu1.1", | ||
3332 | 400 | "actionState": {}, | ||
3333 | 401 | "isCheck": false, | ||
3334 | 402 | "isRadio": false, | ||
3335 | 403 | "isToggled": false, | ||
3336 | 404 | "shortcut": "Alt+0" | ||
3337 | 405 | }}, { | ||
3338 | 406 | "rowData": { // 1.2 | ||
3339 | 407 | "label": "m_enu1.2", | ||
3340 | 408 | "sensitive": true, | ||
3341 | 409 | "isSeparator": false, | ||
3342 | 410 | "icon": "", | ||
3343 | 411 | "type": "com.canonical.indicator.test", | ||
3344 | 412 | "ext": {}, | ||
3345 | 413 | "action": "menu1.2", | ||
3346 | 414 | "actionState": {}, | ||
3347 | 415 | "isCheck": false, | ||
3348 | 416 | "isRadio": false, | ||
3349 | 417 | "isToggled": false, | ||
3350 | 418 | "shortcut": "Alt+1" | ||
3351 | 419 | }, | ||
3352 | 420 | "submenu": [{ | ||
3353 | 421 | "rowData": { // 1.2.1 | ||
3354 | 422 | "label": "menu1.2.1", | ||
3355 | 423 | "sensitive": true, | ||
3356 | 424 | "isSeparator": false, | ||
3357 | 425 | "icon": "", | ||
3358 | 426 | "type": "com.canonical.indicator.test", | ||
3359 | 427 | "ext": {}, | ||
3360 | 428 | "action": "menu1.2.1", | ||
3361 | 429 | "actionState": {}, | ||
3362 | 430 | "isCheck": false, | ||
3363 | 431 | "isRadio": false, | ||
3364 | 432 | "isToggled": false, | ||
3365 | 433 | "shortcut": "" | ||
3366 | 434 | }}, { | ||
3367 | 435 | "rowData": { // 1.2.2 | ||
3368 | 436 | "label": "men_u1.2.2", | ||
3369 | 437 | "sensitive": true, | ||
3370 | 438 | "isSeparator": false, | ||
3371 | 439 | "icon": "", | ||
3372 | 440 | "type": "com.canonical.indicator.test", | ||
3373 | 441 | "ext": {}, | ||
3374 | 442 | "action": "menu1.2.2", | ||
3375 | 443 | "actionState": {}, | ||
3376 | 444 | "isCheck": false, | ||
3377 | 445 | "isRadio": false, | ||
3378 | 446 | "isToggled": false, | ||
3379 | 447 | "shortcut": "" | ||
3380 | 448 | }}, { | ||
3381 | 449 | "rowData": { // 1.2.3 | ||
3382 | 450 | "label": "", | ||
3383 | 451 | "sensitive": false, | ||
3384 | 452 | "isSeparator": true, | ||
3385 | 453 | "icon": "", | ||
3386 | 454 | "type": "", | ||
3387 | 455 | "ext": {}, | ||
3388 | 456 | "action": "", | ||
3389 | 457 | "actionState": {}, | ||
3390 | 458 | "isCheck": false, | ||
3391 | 459 | "isRadio": false, | ||
3392 | 460 | "isToggled": false, | ||
3393 | 461 | "shortcut": "" | ||
3394 | 462 | }}, { | ||
3395 | 463 | "rowData": { // row 1.2.4 | ||
3396 | 464 | "label": "menu1.2.4", | ||
3397 | 465 | "sensitive": true, | ||
3398 | 466 | "isSeparator": false, | ||
3399 | 467 | "icon": "", | ||
3400 | 468 | "type": "com.canonical.indicator.test", | ||
3401 | 469 | "ext": {}, | ||
3402 | 470 | "action": "menu1.2.4", | ||
3403 | 471 | "actionState": {}, | ||
3404 | 472 | "isCheck": false, | ||
3405 | 473 | "isRadio": false, | ||
3406 | 474 | "isToggled": true, | ||
3407 | 475 | "shortcut": "" | ||
3408 | 476 | }} | ||
3409 | 477 | ]}, { | ||
3410 | 478 | "rowData": { // 1.3 | ||
3411 | 479 | "label": "", | ||
3412 | 480 | "sensitive": false, | ||
3413 | 481 | "isSeparator": true, | ||
3414 | 482 | "icon": "", | ||
3415 | 483 | "type": "", | ||
3416 | 484 | "ext": {}, | ||
3417 | 485 | "action": "", | ||
3418 | 486 | "actionState": {}, | ||
3419 | 487 | "isCheck": false, | ||
3420 | 488 | "isRadio": false, | ||
3421 | 489 | "isToggled": false, | ||
3422 | 490 | "shortcut": "" | ||
3423 | 491 | }}, { | ||
3424 | 492 | "rowData": { // row 1.4 | ||
3425 | 493 | "label": "menu1.4", | ||
3426 | 494 | "sensitive": true, | ||
3427 | 495 | "isSeparator": false, | ||
3428 | 496 | "icon": "", | ||
3429 | 497 | "type": "com.canonical.indicator.test", | ||
3430 | 498 | "ext": {}, | ||
3431 | 499 | "action": "menu1.4", | ||
3432 | 500 | "actionState": {}, | ||
3433 | 501 | "isCheck": true, | ||
3434 | 502 | "isRadio": false, | ||
3435 | 503 | "isToggled": true, | ||
3436 | 504 | "shortcut": "Alt+2" | ||
3437 | 505 | }} | ||
3438 | 506 | ]}, { | ||
3439 | 507 | "rowData": { // 2 | ||
3440 | 508 | "label": "menu2", | ||
3441 | 509 | "sensitive": true, | ||
3442 | 510 | "isSeparator": false, | ||
3443 | 511 | "icon": "", | ||
3444 | 512 | "type": "com.canonical.indicator.test", | ||
3445 | 513 | "ext": {}, | ||
3446 | 514 | "action": "menu2", | ||
3447 | 515 | "actionState": {}, | ||
3448 | 516 | "isCheck": false, | ||
3449 | 517 | "isRadio": false, | ||
3450 | 518 | "isToggled": false, | ||
3451 | 519 | "shortcut": "Alt+E" | ||
3452 | 520 | }, | ||
3453 | 521 | "submenu": [{ | ||
3454 | 522 | "rowData": { // 2.1 | ||
3455 | 523 | "label": "menu2.1", | ||
3456 | 524 | "sensitive": true, | ||
3457 | 525 | "isSeparator": false, | ||
3458 | 526 | "icon": "", | ||
3459 | 527 | "type": "com.canonical.indicator.test", | ||
3460 | 528 | "ext": {}, | ||
3461 | 529 | "action": "menu2.1", | ||
3462 | 530 | "actionState": {}, | ||
3463 | 531 | "isCheck": false, | ||
3464 | 532 | "isRadio": false, | ||
3465 | 533 | "isToggled": false, | ||
3466 | 534 | "shortcut": "" | ||
3467 | 535 | }} | ||
3468 | 536 | ]}, { | ||
3469 | 537 | "rowData": { // row 3 | ||
3470 | 538 | "label": "me_nu3", | ||
3471 | 539 | "sensitive": true, | ||
3472 | 540 | "isSeparator": false, | ||
3473 | 541 | "icon": "", | ||
3474 | 542 | "type": "com.canonical.indicator.test", | ||
3475 | 543 | "ext": {}, | ||
3476 | 544 | "action": "dialer3", | ||
3477 | 545 | "actionState": {}, | ||
3478 | 546 | "isCheck": false, | ||
3479 | 547 | "isRadio": false, | ||
3480 | 548 | "isToggled": false, | ||
3481 | 549 | "shortcut": "" | ||
3482 | 550 | }, | ||
3483 | 551 | "submenu": [{ | ||
3484 | 552 | "rowData": { // 3.1 | ||
3485 | 553 | "label": "menu3.1", | ||
3486 | 554 | "sensitive": true, | ||
3487 | 555 | "isSeparator": false, | ||
3488 | 556 | "icon": "", | ||
3489 | 557 | "type": "com.canonical.indicator.test", | ||
3490 | 558 | "ext": {}, | ||
3491 | 559 | "action": "menu3.1", | ||
3492 | 560 | "actionState": {}, | ||
3493 | 561 | "isCheck": false, | ||
3494 | 562 | "isRadio": false, | ||
3495 | 563 | "isToggled": false, | ||
3496 | 564 | "shortcut": "" | ||
3497 | 565 | }} | ||
3498 | 566 | ]} | ||
3499 | 567 | ] | ||
3500 | 568 | |||
3501 | 569 | property var deepTestData: [{ | ||
3502 | 570 | "rowData": { // 1 | ||
3503 | 571 | "label": "_menu1", | ||
3504 | 572 | "sensitive": true, | ||
3505 | 573 | "isSeparator": false, | ||
3506 | 574 | "icon": "", | ||
3507 | 575 | "type": "com.canonical.indicator.test", | ||
3508 | 576 | "ext": {}, | ||
3509 | 577 | "action": "menu1", | ||
3510 | 578 | "actionState": {}, | ||
3511 | 579 | "isCheck": false, | ||
3512 | 580 | "isRadio": false, | ||
3513 | 581 | "isToggled": false, | ||
3514 | 582 | "shortcut": "Alt+F" | ||
3515 | 583 | }, | ||
3516 | 584 | "submenu": [{ | ||
3517 | 585 | "rowData": { // 1.1 | ||
3518 | 586 | "label": "menu1.1", | ||
3519 | 587 | "sensitive": true, | ||
3520 | 588 | "isSeparator": false, | ||
3521 | 589 | "icon": "", | ||
3522 | 590 | "type": "com.canonical.indicator.test", | ||
3523 | 591 | "ext": {}, | ||
3524 | 592 | "action": "menu1.1", | ||
3525 | 593 | "actionState": {}, | ||
3526 | 594 | "isCheck": false, | ||
3527 | 595 | "isRadio": false, | ||
3528 | 596 | "isToggled": false, | ||
3529 | 597 | "shortcut": "" | ||
3530 | 598 | }, | ||
3531 | 599 | "submenu": [{ | ||
3532 | 600 | "rowData": { // 1.1.1 | ||
3533 | 601 | "label": "menu1.1.1", | ||
3534 | 602 | "sensitive": true, | ||
3535 | 603 | "isSeparator": false, | ||
3536 | 604 | "icon": "", | ||
3537 | 605 | "type": "com.canonical.indicator.test", | ||
3538 | 606 | "ext": {}, | ||
3539 | 607 | "action": "menu1.1.1", | ||
3540 | 608 | "actionState": {}, | ||
3541 | 609 | "isCheck": false, | ||
3542 | 610 | "isRadio": false, | ||
3543 | 611 | "isToggled": false, | ||
3544 | 612 | "shortcut": "" | ||
3545 | 613 | }, | ||
3546 | 614 | "submenu": [{ | ||
3547 | 615 | "rowData": { // 1.1.1 | ||
3548 | 616 | "label": "menu1.1.1.1", | ||
3549 | 617 | "sensitive": true, | ||
3550 | 618 | "isSeparator": false, | ||
3551 | 619 | "icon": "", | ||
3552 | 620 | "type": "com.canonical.indicator.test", | ||
3553 | 621 | "ext": {}, | ||
3554 | 622 | "action": "menu1.1.1.1", | ||
3555 | 623 | "actionState": {}, | ||
3556 | 624 | "isCheck": false, | ||
3557 | 625 | "isRadio": false, | ||
3558 | 626 | "isToggled": false, | ||
3559 | 627 | "shortcut": "" | ||
3560 | 628 | }, | ||
3561 | 629 | "submenu": [{ | ||
3562 | 630 | "rowData": { // 1.1.1.1 | ||
3563 | 631 | "label": "menu1.1.1.1.1", | ||
3564 | 632 | "sensitive": true, | ||
3565 | 633 | "isSeparator": false, | ||
3566 | 634 | "icon": "", | ||
3567 | 635 | "type": "com.canonical.indicator.test", | ||
3568 | 636 | "ext": {}, | ||
3569 | 637 | "action": "menu1.1.1.1.1", | ||
3570 | 638 | "actionState": {}, | ||
3571 | 639 | "isCheck": false, | ||
3572 | 640 | "isRadio": false, | ||
3573 | 641 | "isToggled": false, | ||
3574 | 642 | "shortcut": "" | ||
3575 | 643 | }} | ||
3576 | 644 | ]} | ||
3577 | 645 | ]} | ||
3578 | 646 | ]} | ||
3579 | 647 | ]} | ||
3580 | 648 | ] | ||
3581 | 649 | |||
3582 | 650 | property var singleCheckable: [{ | ||
3583 | 651 | "rowData": { // 1 | ||
3584 | 652 | "label": "checkable1", | ||
3585 | 653 | "sensitive": true, | ||
3586 | 654 | "isSeparator": false, | ||
3587 | 655 | "icon": "", | ||
3588 | 656 | "type": "com.canonical.indicator.test", | ||
3589 | 657 | "ext": {}, | ||
3590 | 658 | "action": "checkable1", | ||
3591 | 659 | "actionState": {}, | ||
3592 | 660 | "isCheck": true, | ||
3593 | 661 | "isRadio": false, | ||
3594 | 662 | "isToggled": false, | ||
3595 | 663 | "shortcut": "Alt+F" | ||
3596 | 664 | } | ||
3597 | 665 | }] | ||
3598 | 666 | |||
3599 | 667 | function generateTestData(length, depth, separatorInterval, prefix) { | ||
3600 | 668 | var data = []; | ||
3601 | 669 | |||
3602 | 670 | if (prefix === undefined) prefix = "menu" | ||
3603 | 671 | |||
3604 | 672 | for (var i = 0; i < length; i++) { | ||
3605 | 673 | |||
3606 | 674 | var menuCode = String.fromCharCode(i+65); | ||
3607 | 675 | |||
3608 | 676 | var isSeparator = separatorInterval > 0 && ((i+1) % separatorInterval == 0); | ||
3609 | 677 | var row = { | ||
3610 | 678 | "rowData": { // 1 | ||
3611 | 679 | "label": prefix + "&" + menuCode, | ||
3612 | 680 | "sensitive": true, | ||
3613 | 681 | "isSeparator": isSeparator, | ||
3614 | 682 | "icon": "", | ||
3615 | 683 | "type": "com.canonical.indicator.test", | ||
3616 | 684 | "ext": {}, | ||
3617 | 685 | "action": prefix + menuCode, | ||
3618 | 686 | "actionState": {}, | ||
3619 | 687 | "isCheck": false, | ||
3620 | 688 | "isRadio": false, | ||
3621 | 689 | "isToggled": false, | ||
3622 | 690 | "shortcut": "" | ||
3623 | 691 | } | ||
3624 | 692 | } | ||
3625 | 693 | if (!isSeparator && depth > 1) { | ||
3626 | 694 | var submenu = generateTestData(length, depth-1, separatorInterval, prefix + menuCode + "."); | ||
3627 | 695 | row["submenu"] = submenu; | ||
3628 | 696 | } | ||
3629 | 697 | data[i] = row; | ||
3630 | 698 | } | ||
3631 | 699 | return data; | ||
3632 | 700 | } | ||
3633 | 701 | } | ||
3634 | 702 | |||
3635 | 0 | 703 | ||
3636 | === modified file 'tests/qmltests/Stages/tst_DesktopStage.qml' | |||
3637 | --- tests/qmltests/Stages/tst_DesktopStage.qml 2016-01-07 14:00:21 +0000 | |||
3638 | +++ tests/qmltests/Stages/tst_DesktopStage.qml 2016-01-15 13:11:04 +0000 | |||
3639 | @@ -19,8 +19,10 @@ | |||
3640 | 19 | import Ubuntu.Components 1.3 | 19 | import Ubuntu.Components 1.3 |
3641 | 20 | import Ubuntu.Components.ListItems 1.3 | 20 | import Ubuntu.Components.ListItems 1.3 |
3642 | 21 | import Unity.Application 0.1 | 21 | import Unity.Application 0.1 |
3643 | 22 | import Unity.Indicators 0.1 as Indicators | ||
3644 | 22 | import Unity.Test 0.1 | 23 | import Unity.Test 0.1 |
3645 | 23 | import Utils 0.1 | 24 | import Utils 0.1 |
3646 | 25 | import QMenuModel 0.1 | ||
3647 | 24 | 26 | ||
3648 | 25 | import ".." // For EdgeBarrierControls | 27 | import ".." // For EdgeBarrierControls |
3649 | 26 | import "../../../qml/Stages" | 28 | import "../../../qml/Stages" |
3650 | @@ -40,7 +42,17 @@ | |||
3651 | 40 | value: false | 42 | value: false |
3652 | 41 | } | 43 | } |
3653 | 42 | 44 | ||
3655 | 43 | Component.onCompleted: resetGeometry() | 45 | DesktopMenuData { |
3656 | 46 | id: appMenuData | ||
3657 | 47 | } | ||
3658 | 48 | |||
3659 | 49 | Component.onCompleted: { | ||
3660 | 50 | resetGeometry(); | ||
3661 | 51 | |||
3662 | 52 | Indicators.UnityMenuModelCache.setCachedModelData("/dialer-app", appMenuData.dialerData); | ||
3663 | 53 | Indicators.UnityMenuModelCache.setCachedModelData("/camera-app", appMenuData.cameraData); | ||
3664 | 54 | Indicators.UnityMenuModelCache.setCachedModelData("/gallery-app", appMenuData.galleryData); | ||
3665 | 55 | } | ||
3666 | 44 | 56 | ||
3667 | 45 | function resetGeometry() { | 57 | function resetGeometry() { |
3668 | 46 | // ensures apps which are tested decorations are in view. | 58 | // ensures apps which are tested decorations are in view. |
3669 | 47 | 59 | ||
3670 | === added file 'tests/qmltests/Stages/tst_WindowDecoration.qml' | |||
3671 | --- tests/qmltests/Stages/tst_WindowDecoration.qml 1970-01-01 00:00:00 +0000 | |||
3672 | +++ tests/qmltests/Stages/tst_WindowDecoration.qml 2016-01-15 13:11:04 +0000 | |||
3673 | @@ -0,0 +1,163 @@ | |||
3674 | 1 | /* | ||
3675 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3676 | 3 | * | ||
3677 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3678 | 5 | * it under the terms of the GNU General Public License as published by | ||
3679 | 6 | * the Free Software Foundation; version 3. | ||
3680 | 7 | * | ||
3681 | 8 | * This program is distributed in the hope that it will be useful, | ||
3682 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3683 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3684 | 11 | * GNU General Public License for more details. | ||
3685 | 12 | * | ||
3686 | 13 | * You should have received a copy of the GNU General Public License | ||
3687 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3688 | 15 | */ | ||
3689 | 16 | |||
3690 | 17 | import QtQuick 2.4 | ||
3691 | 18 | import QtTest 1.0 | ||
3692 | 19 | import QtQuick.Layouts 1.1 | ||
3693 | 20 | import Ubuntu.Components 1.3 | ||
3694 | 21 | import Ubuntu.Components.ListItems 1.3 | ||
3695 | 22 | import Unity.Application 0.1 | ||
3696 | 23 | import Unity.Test 0.1 | ||
3697 | 24 | import Utils 0.1 | ||
3698 | 25 | import QMenuModel 0.1 | ||
3699 | 26 | |||
3700 | 27 | import "../../../qml/Stages" | ||
3701 | 28 | |||
3702 | 29 | Item { | ||
3703 | 30 | id: root | ||
3704 | 31 | width: units.gu(70) | ||
3705 | 32 | height: units.gu(50) | ||
3706 | 33 | |||
3707 | 34 | Binding { | ||
3708 | 35 | target: MouseTouchAdaptor | ||
3709 | 36 | property: "enabled" | ||
3710 | 37 | value: false | ||
3711 | 38 | } | ||
3712 | 39 | |||
3713 | 40 | DesktopMenuData { id: desktopMenuData } | ||
3714 | 41 | |||
3715 | 42 | Rectangle { | ||
3716 | 43 | anchors { | ||
3717 | 44 | left: parent.left | ||
3718 | 45 | right: parent.right | ||
3719 | 46 | bottom: parent.bottom | ||
3720 | 47 | margins: units.gu(1) | ||
3721 | 48 | } | ||
3722 | 49 | height: units.gu(20) | ||
3723 | 50 | border.width: 1 | ||
3724 | 51 | border.color: "black" | ||
3725 | 52 | |||
3726 | 53 | TextArea { | ||
3727 | 54 | id: log | ||
3728 | 55 | anchors.fill: parent | ||
3729 | 56 | readOnly: true | ||
3730 | 57 | } | ||
3731 | 58 | } | ||
3732 | 59 | |||
3733 | 60 | WindowDecoration { | ||
3734 | 61 | id: decoration | ||
3735 | 62 | anchors { left: parent.left; right: parent.right; top: parent.top } | ||
3736 | 63 | anchors.margins: units.gu(1) | ||
3737 | 64 | title: "TestTitle - Doing something" | ||
3738 | 65 | active: true | ||
3739 | 66 | height: units.gu(3) | ||
3740 | 67 | menu: menuBackend | ||
3741 | 68 | UnityMenuModel { | ||
3742 | 69 | id: menuBackend | ||
3743 | 70 | modelData: desktopMenuData.testData | ||
3744 | 71 | onActivated: log.text = "Activated " + action + "\n" + log.text | ||
3745 | 72 | } | ||
3746 | 73 | |||
3747 | 74 | onClose: log.text = "Close\n" + log.text | ||
3748 | 75 | onMinimize: log.text = "Minimize\n" + log.text | ||
3749 | 76 | onMaximize: log.text = "Maximize\n" + log.text | ||
3750 | 77 | } | ||
3751 | 78 | |||
3752 | 79 | SignalSpy { | ||
3753 | 80 | id: signalSpy | ||
3754 | 81 | target: decoration | ||
3755 | 82 | } | ||
3756 | 83 | |||
3757 | 84 | UnityTestCase { | ||
3758 | 85 | id: testCase | ||
3759 | 86 | name: "MenuPage" | ||
3760 | 87 | when: windowShown | ||
3761 | 88 | |||
3762 | 89 | function init() { | ||
3763 | 90 | decoration.menu = menuBackend; | ||
3764 | 91 | signalSpy.clear(); | ||
3765 | 92 | } | ||
3766 | 93 | |||
3767 | 94 | function test_windowControlButtons_data() { | ||
3768 | 95 | return [ { tag: "close", controlName: "closeWindowButton", signal: "close"}, | ||
3769 | 96 | { tag: "minimize", controlName: "minimizeWindowButton", signal: "minimize"}, | ||
3770 | 97 | { tag: "maximize", controlName: "maximizeWindowButton", signal: "maximize"}]; | ||
3771 | 98 | } | ||
3772 | 99 | |||
3773 | 100 | function test_windowControlButtons(data) { | ||
3774 | 101 | signalSpy.signalName = data.signal; | ||
3775 | 102 | var controlButton = findChild(decoration, data.controlName); | ||
3776 | 103 | verify(controlButton !== null); | ||
3777 | 104 | |||
3778 | 105 | mouseClick(controlButton, controlButton.width/2, controlButton.height/2); | ||
3779 | 106 | compare(signalSpy.count, 1); | ||
3780 | 107 | } | ||
3781 | 108 | |||
3782 | 109 | function test_titleRemainsWhenHoveringOnTitleBarWithNoMenu() { | ||
3783 | 110 | decoration.menu = undefined; | ||
3784 | 111 | |||
3785 | 112 | var menuLoader = findChild(decoration, "windowDecorationMenuBarLoader"); | ||
3786 | 113 | verify(menuLoader); | ||
3787 | 114 | mouseMove(menuLoader, menuLoader.width/2, menuLoader.height/2); | ||
3788 | 115 | wait(200); | ||
3789 | 116 | |||
3790 | 117 | var titleLabel = findChild(decoration, "windowDecorationTitle"); | ||
3791 | 118 | verify(menuLoader); | ||
3792 | 119 | |||
3793 | 120 | compare(menuLoader.opacity, 0, "Menu should not show when present") | ||
3794 | 121 | compare(titleLabel.opacity, 1, "Title should always show when app menu not present") | ||
3795 | 122 | } | ||
3796 | 123 | |||
3797 | 124 | function test_menuShowsWhenHoveringOnTitleBar() { | ||
3798 | 125 | var menuLoader = findChild(decoration, "windowDecorationMenuBarLoader"); | ||
3799 | 126 | verify(menuLoader); | ||
3800 | 127 | mouseMove(menuLoader, menuLoader.width/2, menuLoader.height/2) | ||
3801 | 128 | |||
3802 | 129 | var titleLabel = findChild(decoration, "windowDecorationTitle"); | ||
3803 | 130 | verify(menuLoader); | ||
3804 | 131 | |||
3805 | 132 | tryCompare(menuLoader, "opacity", 1); | ||
3806 | 133 | tryCompare(titleLabel, "opacity", 0); | ||
3807 | 134 | |||
3808 | 135 | mouseMove(menuLoader, menuLoader.width/2, menuLoader.height * 2); | ||
3809 | 136 | |||
3810 | 137 | tryCompare(menuLoader, "opacity", 0); | ||
3811 | 138 | tryCompare(titleLabel, "opacity", 1); | ||
3812 | 139 | } | ||
3813 | 140 | |||
3814 | 141 | function test_showMenuBarWithShortcutsOnLongAltPress() { | ||
3815 | 142 | var menuLoader = findChild(decoration, "windowDecorationMenuBarLoader"); | ||
3816 | 143 | verify(menuLoader); | ||
3817 | 144 | |||
3818 | 145 | var titleLabel = findChild(decoration, "windowDecorationTitle"); | ||
3819 | 146 | verify(menuLoader); | ||
3820 | 147 | |||
3821 | 148 | var menuBar = findChild(decoration, "menuBar"); | ||
3822 | 149 | verify(menuBar); | ||
3823 | 150 | verify(menuBar.enableMnemonic === false, "Menubar should not show shortcuts") | ||
3824 | 151 | |||
3825 | 152 | keyPress(Qt.Key_Alt, Qt.NoModifier); | ||
3826 | 153 | tryCompare(menuLoader, "opacity", 1); | ||
3827 | 154 | tryCompare(titleLabel, "opacity", 0); | ||
3828 | 155 | compare(menuBar.enableMnemonic, true, "Menubar should show shortcuts when long alt pressed"); | ||
3829 | 156 | |||
3830 | 157 | keyRelease(Qt.Key_Alt, Qt.NoModifier); | ||
3831 | 158 | tryCompare(menuLoader, "opacity", 0); | ||
3832 | 159 | tryCompare(titleLabel, "opacity", 1); | ||
3833 | 160 | compare(menuBar.enableMnemonic, false, "Menubar should not show shortcuts after long alt pressed"); | ||
3834 | 161 | } | ||
3835 | 162 | } | ||
3836 | 163 | } | ||
3837 | 0 | 164 | ||
3838 | === modified file 'tests/qmltests/tst_Shell.qml' | |||
3839 | --- tests/qmltests/tst_Shell.qml 2015-12-08 15:37:51 +0000 | |||
3840 | +++ tests/qmltests/tst_Shell.qml 2016-01-15 13:11:04 +0000 | |||
3841 | @@ -30,6 +30,7 @@ | |||
3842 | 30 | import Powerd 0.1 | 30 | import Powerd 0.1 |
3843 | 31 | import Wizard 0.1 as Wizard | 31 | import Wizard 0.1 as Wizard |
3844 | 32 | import Utils 0.1 | 32 | import Utils 0.1 |
3845 | 33 | import Unity.Indicators 0.1 as Indicators | ||
3846 | 33 | 34 | ||
3847 | 34 | import "../../qml" | 35 | import "../../qml" |
3848 | 35 | import "../../qml/Components" | 36 | import "../../qml/Components" |
3849 | @@ -47,6 +48,14 @@ | |||
3850 | 47 | LightDM.Greeter.mockMode = "single"; | 48 | LightDM.Greeter.mockMode = "single"; |
3851 | 48 | LightDM.Users.mockMode = "single"; | 49 | LightDM.Users.mockMode = "single"; |
3852 | 49 | shellLoader.active = true; | 50 | shellLoader.active = true; |
3853 | 51 | |||
3854 | 52 | Indicators.UnityMenuModelCache.setCachedModelData("/dialer-app", appMenuData.dialerData); | ||
3855 | 53 | Indicators.UnityMenuModelCache.setCachedModelData("/camera-app", appMenuData.cameraData); | ||
3856 | 54 | Indicators.UnityMenuModelCache.setCachedModelData("/gallery-app", appMenuData.galleryData); | ||
3857 | 55 | } | ||
3858 | 56 | |||
3859 | 57 | DesktopMenuData { | ||
3860 | 58 | id: appMenuData | ||
3861 | 50 | } | 59 | } |
3862 | 51 | 60 | ||
3863 | 52 | Item { | 61 | Item { |
3864 | @@ -1752,17 +1761,17 @@ | |||
3865 | 1752 | var maximizeButton = findChild(appDelegate, "maximizeWindowButton"); | 1761 | var maximizeButton = findChild(appDelegate, "maximizeWindowButton"); |
3866 | 1753 | 1762 | ||
3867 | 1754 | tryCompare(appDelegate, "state", "normal"); | 1763 | tryCompare(appDelegate, "state", "normal"); |
3869 | 1755 | tryCompare(PanelState, "buttonsVisible", false) | 1764 | tryCompare(PanelState, "decorationsVisible", false) |
3870 | 1756 | 1765 | ||
3871 | 1757 | mouseClick(maximizeButton, maximizeButton.width / 2, maximizeButton.height / 2); | 1766 | mouseClick(maximizeButton, maximizeButton.width / 2, maximizeButton.height / 2); |
3872 | 1758 | tryCompare(appDelegate, "state", "maximized"); | 1767 | tryCompare(appDelegate, "state", "maximized"); |
3874 | 1759 | tryCompare(PanelState, "buttonsVisible", true) | 1768 | tryCompare(PanelState, "decorationsVisible", true) |
3875 | 1760 | 1769 | ||
3876 | 1761 | ApplicationManager.stopApplication(appId); | 1770 | ApplicationManager.stopApplication(appId); |
3878 | 1762 | tryCompare(PanelState, "buttonsVisible", false) | 1771 | tryCompare(PanelState, "decorationsVisible", false) |
3879 | 1763 | 1772 | ||
3880 | 1764 | ApplicationManager.startApplication(appId); | 1773 | ApplicationManager.startApplication(appId); |
3882 | 1765 | tryCompare(PanelState, "buttonsVisible", true) | 1774 | tryCompare(PanelState, "decorationsVisible", true) |
3883 | 1766 | } | 1775 | } |
3884 | 1767 | 1776 | ||
3885 | 1768 | function test_newAppHasValidGeometry() { | 1777 | function test_newAppHasValidGeometry() { |
FAILED: Continuous integration, rev:2109 /unity8- jenkins. ubuntu. com/job/ lp-unity8- 1-ci/90/
https:/
Executed test runs:
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-unity8- 1-ci/90/ rebuild
https:/