Merge lp:~tpeeters/ubuntu-ui-toolkit/toolsItem into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 556
Merged at revision: 540
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/toolsItem
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 358 lines (+176/-69)
5 files modified
CHANGES (+7/-4)
components.api (+4/-2)
modules/Ubuntu/Components/Page.qml (+2/-2)
modules/Ubuntu/Components/Toolbar.qml (+22/-60)
modules/Ubuntu/Components/ToolbarActions.qml (+141/-1)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/toolsItem
Reviewer Review Type Date Requested Status
Tim Peeters Approve
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+168932@code.launchpad.net

Commit message

Tools are now Items:
- Make ToolbarActions a subclass of Item
- Move the visualization of Actions in Toolbar from Toolbar to ToolbarActions
- Allow the tools properties of Toolbar and Page to be any Item

Description of the change

Tools are now Items:
- Make ToolbarActions a subclass of Item
- Move the visualization of Actions in Toolbar from Toolbar to ToolbarActions
- Allow the tools properties of Toolbar and Page to be any Item

This MR prepares the code for changes to the Action API. We can now support two APIs (the old one will be deprecated) at the same time for defining the actions in a toolbar.

To post a comment you must log in.
552. By Tim Peeters

update CHANGES

Revision history for this message
Tim Peeters (tpeeters) wrote :

Wait for https://code.launchpad.net/~tpeeters/gallery-app/newTools/+merge/168923 to be included in the image so that gallery-app will not break.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
553. By Tim Peeters

avoid disappearing tools

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
554. By Tim Peeters

Change type of tools from ToolbarActions to Item

555. By Tim Peeters

support tools items that do not have opened or locked properties

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
556. By Tim Peeters

update documentation

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

nice work

review: Approve
Revision history for this message
Tim Peeters (tpeeters) wrote :

Tested on galaxy nexus with saucy-8. Worked with all apps except gallery-app which has an update to fix in the newest package (not yet included in the image). After apt-get upgrade, all apps including gallery-app work fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-05-30 08:21:58 +0000
3+++ CHANGES 2013-06-13 09:30:37 +0000
4@@ -19,15 +19,18 @@
5 * DEPRECATED IN Toolbar: property bool lock
6 * DEPRECATED IN ToolbarActions: property bool active
7 * DEPRECATED IN ToolbarActions: property bool lock
8-* CHANGED IN Page: property Header header to property Header __propagated.header
9-* CHANGED IN Page: property Toolbar toolbar to property Toolbar __propagated.toolbar
10-* CHANGED IN MainView: property Header header to property Header __propagated.header
11-* CHANGED IN MainView: property Toolbar toolbar to property Toolbar __propagated.toolbar
12+* CHANGED IN Page: property Header header TO property Header __propagated.header
13+* CHANGED IN Page: property Toolbar toolbar TO property Toolbar __propagated.toolbar
14+* CHANGED IN MainView: property Header header TO property Header __propagated.header
15+* CHANGED IN MainView: property Toolbar toolbar TO property Toolbar __propagated.toolbar
16 * DEPRECATED IN Page: property Header header
17 * DEPRECATED IN Page: property Toolbar toolbar
18 * DEPRECATED IN MainView: property Header header
19 * DEPRECATED IN Page: property Toolbar toolbar
20 * REMOVED in MainView: property QtObject __hud
21+* CHANGED in ToolbarActions: INHERIT Item INSTEAD OF ActionList
22+* CHANGED in Page: property ToolbarActions tools TO property Item tools
23+* CHANGED IN Toolbar: property ToolbarActions tools TO property Item tools
24
25 Compatibility Breaks
26 ********************
27
28=== modified file 'components.api'
29--- components.api 2013-05-29 16:18:00 +0000
30+++ components.api 2013-06-13 09:30:37 +0000
31@@ -287,9 +287,11 @@
32 Panel
33 property bool active
34 property bool lock
35- property ToolbarActions tools
36+ property Item tools
37 modules/Ubuntu/Components/ToolbarActions.qml
38-ActionList
39+Item
40+ default property alias children
41+ property list<Action> actions
42 property Action back
43 property Item __pageStack
44 property bool opened
45
46=== modified file 'modules/Ubuntu/Components/Page.qml'
47--- modules/Ubuntu/Components/Page.qml 2013-05-22 16:24:18 +0000
48+++ modules/Ubuntu/Components/Page.qml 2013-06-13 09:30:37 +0000
49@@ -76,7 +76,7 @@
50 /*!
51 The list of actions associated with this Page.
52 */
53- property ToolbarActions tools: ToolbarActions { }
54+ property Item tools: ToolbarActions { }
55
56 /*!
57 Optional flickable that controls the header. This property
58@@ -109,7 +109,7 @@
59 internal.header.flickable = page.flickable;
60 }
61 if (tools) {
62- tools.__pageStack = page.pageStack;
63+ if (tools.hasOwnProperty("__pageStack")) tools.__pageStack = page.pageStack;
64 }
65 if (internal.toolbar) {
66 internal.toolbar.tools = page.tools;
67
68=== modified file 'modules/Ubuntu/Components/Toolbar.qml'
69--- modules/Ubuntu/Components/Toolbar.qml 2013-05-23 17:00:58 +0000
70+++ modules/Ubuntu/Components/Toolbar.qml 2013-06-13 09:30:37 +0000
71@@ -63,17 +63,19 @@
72 \preliminary
73 The list of \l Actions to be shown on the toolbar
74 */
75- property ToolbarActions tools: null
76+ property Item tools: null
77+
78 /*! \internal */
79 onToolsChanged: {
80- locked = tools.locked;
81- if (tools && tools.opened && tools.locked) {
82+ if (tools.hasOwnProperty("locked")) locked = tools.locked;
83+ if (tools && tools.hasOwnProperty("locked") && tools.hasOwnProperty("opened")
84+ && tools.opened && tools.locked) {
85 // toolbar is locked in visible state.
86- internal.visibleTools = tools;
87+ internal.updateVisibleTools();
88 opened = true;
89 } else if (!opened && !animating) {
90 // toolbar is invisible
91- internal.visibleTools = tools;
92+ internal.updateVisibleTools();
93 } else {
94 opened = false;
95 // internal.visibleTools will be updated
96@@ -82,22 +84,30 @@
97 }
98
99 // if tools is not specified, lock the toolbar in closed position
100- locked: tools ? tools.locked : true
101+ locked: tools && tools.hasOwnProperty("locked") ? tools.locked : false
102
103 Connections {
104 target: tools
105+ ignoreUnknownSignals: true
106 onOpenedChanged: toolbar.opened = tools.opened;
107 onLockedChanged: toolbar.locked = tools.locked;
108 }
109
110 QtObject {
111 id: internal
112- property ToolbarActions visibleTools: tools
113+ property Item visibleTools: tools
114+ function updateVisibleTools() {
115+ if (internal.visibleTools !== toolbar.tools) {
116+ if (internal.visibleTools) internal.visibleTools.parent = null;
117+ internal.visibleTools = toolbar.tools;
118+ internal.visibleTools.parent = visibleToolsContainer;
119+ }
120+ }
121 }
122
123 onAnimatingChanged: {
124 if (!animating && !opened) {
125- internal.visibleTools = toolbar.tools;
126+ internal.updateVisibleTools();
127 }
128 }
129
130@@ -120,58 +130,10 @@
131 property bool animating: toolbar.animating
132 }
133
134- Component {
135- id: toolButtonComponent
136- Button {
137- id: toolButton
138- // Disable the mouse area so swipes on the button will not be blocked
139- // from going to the toolbar. The panel will take care calling the button's clicked().
140- __mouseArea.visible: false
141- Theming.ItemStyle.class: "toolbar-button"
142- width: units.gu(5)
143- height: toolbar.height
144- }
145- }
146-
147- Loader {
148- id: backButton
149- property Action backAction: toolbar.tools ? toolbar.tools.back : null
150- sourceComponent: backAction ? backAction.itemHint ? backAction.itemHint : toolButtonComponent : null
151- anchors {
152- left: parent.left
153- leftMargin: units.gu(2)
154- verticalCenter: parent.verticalCenter
155- }
156- onStatusChanged: {
157- if (item && status == Loader.Ready) {
158- if (item.hasOwnProperty("action")) item.action = backAction;
159- }
160- }
161- // ensure the item's action is up-to-date (which is not the case without this line):
162- onBackActionChanged: if (item && item.hasOwnProperty("action")) item.action = backAction;
163- }
164-
165- Row {
166- id: toolButtonsContainer
167- anchors {
168- right: parent.right
169- bottom: parent.bottom
170- top: parent.top
171- rightMargin: units.gu(2)
172- }
173- spacing: units.gu(1)
174-
175- Repeater {
176- model: internal.visibleTools ? internal.visibleTools.children : 0
177- Loader {
178- sourceComponent: modelData.itemHint ? modelData.itemHint : toolButtonComponent
179- anchors.verticalCenter: toolButtonsContainer.verticalCenter
180- onStatusChanged: {
181- if (item && status == Loader.Ready) {
182- if (item.hasOwnProperty("action")) item.action = modelData
183- }
184- }
185- }
186+ Item {
187+ id: visibleToolsContainer
188+ anchors {
189+ fill: background
190 }
191 }
192 }
193
194=== modified file 'modules/Ubuntu/Components/ToolbarActions.qml'
195--- modules/Ubuntu/Components/ToolbarActions.qml 2013-05-30 12:07:03 +0000
196+++ modules/Ubuntu/Components/ToolbarActions.qml 2013-06-13 09:30:37 +0000
197@@ -15,6 +15,11 @@
198 */
199
200 import QtQuick 2.0
201+// FIXME: When a module contains QML, C++ and JavaScript elements exported,
202+// we need to use named imports otherwise namespace collision is reported
203+// by the QML engine. As workaround, we use Theming named import.
204+// Bug to watch: https://bugreports.qt-project.org/browse/QTBUG-27645
205+import Ubuntu.Components 0.1 as Theming
206
207 /*!
208 \qmltype ToolbarActions
209@@ -70,8 +75,88 @@
210 }
211 \endqml
212 */
213-ActionList {
214+Item {
215 id: toolbarActions
216+ anchors.fill: parent
217+
218+ // internal objects using nested elements,
219+ // which isn't allowed by QtObject; this fix makes this possible
220+ /*!
221+ Default property to allow adding of children. For example, the tools of a \l Page
222+ can be defined as follows:
223+ \qml
224+ import QtQuick 2.0
225+ import Ubuntu.Components 0.1
226+
227+ MainView {
228+ width: units.gu(50)
229+ height: units.gu(80)
230+
231+ Page {
232+ title: "test page"
233+
234+ Label {
235+ anchors.centerIn: parent
236+ text: "Hello, world"
237+ }
238+
239+ tools: ToolbarActions {
240+ Action {
241+ text: "action 1"
242+ }
243+ Action {
244+ text: "action 2"
245+ }
246+ }
247+ }
248+ }
249+ \endqml
250+ ToolbarActions will automatically create a visual representation of the actions.
251+ \qmlproperty list<Action> children
252+ */
253+ default property alias children: toolbarActions.actions
254+
255+ /*!
256+ List of already defined actions when not defining them as children of the ToolbarActions.
257+ Note that when you set this property, the children of ToolbarActions will be ignored,
258+ so do not set the list and define children.
259+ \qml
260+ import QtQuick 2.0
261+ import Ubuntu.Components 0.1
262+
263+ MainView {
264+ width: units.gu(50)
265+ height: units.gu(80)
266+
267+ Action {
268+ id: action1
269+ text: "action 1"
270+ onTriggered: print("one!")
271+ }
272+ Action {
273+ id: action2
274+ text: "action 2"
275+ onTriggered: print("two!")
276+ }
277+
278+ Page {
279+ title: "test page"
280+
281+ Label {
282+ anchors.centerIn: parent
283+ text: "Hello, world"
284+ }
285+
286+ tools: ToolbarActions {
287+ actions: [action1, action2]
288+ }
289+ }
290+ }
291+ \endqml
292+ the advantage of setting actions over using the children is that the same
293+ \l Action items can be used in several sets of actions.
294+ */
295+ property list<Action> actions
296
297 /*!
298 The back \l Action. If the action is visible, the back button will be shown
299@@ -150,4 +235,59 @@
300 }
301 return false;
302 }
303+
304+ Component {
305+ id: toolButtonComponent
306+ Button {
307+ id: toolButton
308+ // Disable the mouse area so swipes on the button will not be blocked
309+ // from going to the toolbar. The panel will take care calling the button's clicked().
310+ __mouseArea.visible: false
311+ Theming.ItemStyle.class: "toolbar-button"
312+ width: units.gu(5)
313+ height: toolbarActions.height
314+ }
315+ }
316+
317+ Loader {
318+ id: backButton
319+ property Action backAction: toolbarActions.back
320+ sourceComponent: backAction ? backAction.itemHint ? backAction.itemHint : toolButtonComponent : null
321+ anchors {
322+ left: parent.left
323+ leftMargin: units.gu(2)
324+ verticalCenter: parent.verticalCenter
325+ }
326+ onStatusChanged: {
327+ if (item && status == Loader.Ready) {
328+ if (item.hasOwnProperty("action")) item.action = backAction;
329+ }
330+ }
331+ // ensure the item's action is up-to-date (which is not the case without this line):
332+ onBackActionChanged: if (item && item.hasOwnProperty("action")) item.action = backAction;
333+ }
334+
335+ Row {
336+ id: toolButtonsContainer
337+ anchors {
338+ right: parent.right
339+ bottom: parent.bottom
340+ top: parent.top
341+ rightMargin: units.gu(2)
342+ }
343+ spacing: units.gu(1)
344+
345+ Repeater {
346+ model: toolbarActions.actions
347+ Loader {
348+ sourceComponent: modelData.itemHint ? modelData.itemHint : toolButtonComponent
349+ anchors.verticalCenter: toolButtonsContainer.verticalCenter
350+ onStatusChanged: {
351+ if (item && status == Loader.Ready) {
352+ if (item.hasOwnProperty("action")) item.action = modelData
353+ }
354+ }
355+ }
356+ }
357+ }
358 }

Subscribers

People subscribed via source and target branches

to status/vote changes: