Merge lp:~boiko/phone-app/contact_editing_toolbar into lp:phone-app

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 653
Merged at revision: 655
Proposed branch: lp:~boiko/phone-app/contact_editing_toolbar
Merge into: lp:phone-app
Diff against target: 202 lines (+151/-1)
2 files modified
src/qml/DetailViewContact/ContactDetails.qml (+22/-1)
src/qml/DetailViewContact/EditToolbar.qml (+129/-0)
To merge this branch: bzr merge lp:~boiko/phone-app/contact_editing_toolbar
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+165478@code.launchpad.net

Commit message

Add a temporary toolbar shown when editing contacts to make it easier to save or cancel the editing.

Description of the change

Add a temporary toolbar shown when editing contacts to make it easier to save or cancel the editing.

To post a comment you must log in.
651. By Gustavo Pichorim Boiko

Remove leftover code.

652. By Gustavo Pichorim Boiko

Fix copyright.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
653. By Gustavo Pichorim Boiko

Move the buttons away from the border to avoid triggering the edge swipe when
clicking the button.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/DetailViewContact/ContactDetails.qml'
2--- src/qml/DetailViewContact/ContactDetails.qml 2013-05-20 20:54:07 +0000
3+++ src/qml/DetailViewContact/ContactDetails.qml 2013-05-23 22:20:33 +0000
4@@ -40,6 +40,7 @@
5 title: "Contact Details"
6
7 tools: ToolbarActions {
8+ lock: editable
9
10 Action {
11 text: "Edit"
12@@ -50,6 +51,7 @@
13 }
14
15 Action {
16+ id: deleteAction
17 text: "Delete"
18 iconSource: Qt.resolvedUrl("../assets/delete.png")
19 visible: editable && !added
20@@ -62,6 +64,7 @@
21 }
22
23 Action {
24+ id: cancelAction
25 text: "Cancel"
26 iconSource: Qt.resolvedUrl("../assets/cancel.png")
27 visible: editable
28@@ -77,6 +80,7 @@
29 }
30
31 Action {
32+ id: saveAction
33 text: "Save"
34 iconSource: Qt.resolvedUrl("../assets/save.png")
35 visible: editable
36@@ -163,7 +167,7 @@
37 id: scrollArea
38
39 anchors.top: parent.top
40- anchors.bottom: keyboard.top
41+ anchors.bottom: editToolbar.top
42 anchors.left: parent.left
43 anchors.right: parent.right
44 flickableDirection: Flickable.VerticalFlick
45@@ -266,6 +270,23 @@
46 }
47 }
48
49+ EditToolbar {
50+ id: editToolbar
51+ visible: editable
52+ anchors.bottom: keyboard.top
53+
54+ onDeleteClicked: deleteAction.triggered(editToolbar)
55+ onCancelClicked: cancelAction.triggered(editToolbar)
56+ onSaveClicked: saveAction.triggered(editToolbar)
57+
58+ onVisibleChanged: {
59+ if (visible) {
60+ // hide the toolbar
61+ toolbar.opened = false;
62+ }
63+ }
64+ }
65+
66 Scrollbar {
67 flickableItem: scrollArea
68 align: Qt.AlignTrailing
69
70=== added file 'src/qml/DetailViewContact/EditToolbar.qml'
71--- src/qml/DetailViewContact/EditToolbar.qml 1970-01-01 00:00:00 +0000
72+++ src/qml/DetailViewContact/EditToolbar.qml 2013-05-23 22:20:33 +0000
73@@ -0,0 +1,129 @@
74+/*
75+ * Copyright 2013 Canonical Ltd.
76+ *
77+ * This file is part of phone-app.
78+ *
79+ * phone-app is free software; you can redistribute it and/or modify
80+ * it under the terms of the GNU General Public License as published by
81+ * the Free Software Foundation; version 3.
82+ *
83+ * phone-app is distributed in the hope that it will be useful,
84+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
85+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86+ * GNU General Public License for more details.
87+ *
88+ * You should have received a copy of the GNU General Public License
89+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
90+ */
91+
92+import QtQuick 2.0
93+import Ubuntu.Components 0.1 as Theming
94+
95+Item {
96+ id: toolbar
97+ Theming.ItemStyle.class: "toolbar"
98+ height: visible ? units.gu(6.5) : 0
99+ anchors.left: parent.left
100+ anchors.right: parent.right
101+
102+ signal deleteClicked()
103+ signal cancelClicked()
104+ signal saveClicked()
105+
106+ Component {
107+ id: toolButtonComponent
108+ Item {
109+ id: toolButton
110+ Theming.ItemStyle.class: "toolbar-button"
111+ property string text: parent && parent.text ? parent.text : ""
112+ property url iconSource: parent && parent.iconSource ? parent.iconSource : ""
113+ signal clicked()
114+ width: units.gu(5)
115+ height: toolbar.height
116+
117+ MouseArea {
118+ anchors.fill: parent
119+ onClicked: parent.clicked()
120+ }
121+ }
122+ }
123+
124+ Loader {
125+ id: backButton
126+ sourceComponent: toolButtonComponent
127+
128+ property string text: tools.back.text
129+ property string iconSource: tools.back.iconSource
130+
131+ anchors {
132+ left: parent.left
133+ leftMargin: units.gu(2)
134+ verticalCenter: parent.verticalCenter
135+ }
136+ onStatusChanged: {
137+ if (item && status == Loader.Ready) {
138+ if (item.hasOwnProperty("clicked")) item.clicked.connect(backButton.itemTriggered);
139+ }
140+ }
141+ signal itemTriggered()
142+ onItemTriggered: mainView.resetView();
143+ }
144+
145+ Row {
146+ id: buttonsRow
147+ anchors.right: parent.right
148+ anchors.rightMargin: units.gu(2)
149+ anchors.top: parent.top
150+ anchors.bottom: parent.bottom
151+
152+ //delete, cancel, save
153+ Loader {
154+ id: deleteButton
155+
156+ property string text: "Delete"
157+ property string iconSource: Qt.resolvedUrl("../assets/delete.png")
158+ sourceComponent: toolButtonComponent
159+ anchors.verticalCenter: parent.verticalCenter
160+ onStatusChanged: {
161+ if (item && status == Loader.Ready) {
162+ if (item.hasOwnProperty("clicked")) item.clicked.connect(deleteButton.itemTriggered);
163+ }
164+ }
165+ signal itemTriggered()
166+ onItemTriggered: toolbar.deleteClicked()
167+ visible: !added
168+ }
169+
170+ Loader {
171+ id: cancelButton
172+
173+ property string text: "Cancel"
174+ property string iconSource: Qt.resolvedUrl("../assets/cancel.png")
175+ sourceComponent: toolButtonComponent
176+ anchors.verticalCenter: parent.verticalCenter
177+ onStatusChanged: {
178+ if (item && status == Loader.Ready) {
179+ if (item.hasOwnProperty("clicked")) item.clicked.connect(cancelButton.itemTriggered);
180+ }
181+ }
182+ signal itemTriggered()
183+ onItemTriggered: toolbar.cancelClicked()
184+ }
185+
186+ Loader {
187+ id: saveButton
188+
189+ property string text: "Save"
190+ property string iconSource: Qt.resolvedUrl("../assets/save.png")
191+ sourceComponent: toolButtonComponent
192+ anchors.verticalCenter: parent.verticalCenter
193+ onStatusChanged: {
194+ if (item && status == Loader.Ready) {
195+ if (item.hasOwnProperty("clicked")) item.clicked.connect(saveButton.itemTriggered);
196+ }
197+ }
198+ signal itemTriggered()
199+ onItemTriggered: toolbar.saveClicked()
200+ }
201+ }
202+}

Subscribers

People subscribed via source and target branches