Merge lp:~mzanetti/reminders-app/improve-edit-focus into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 486
Merged at revision: 488
Proposed branch: lp:~mzanetti/reminders-app/improve-edit-focus
Merge into: lp:reminders-app
Diff against target: 328 lines (+129/-94)
5 files modified
src/app/qml/components/Header.qml (+99/-93)
src/app/qml/reminders.qml (+2/-1)
src/app/qml/ui/EditNotePage.qml (+2/-0)
src/app/qml/ui/EditNoteView.qml (+25/-0)
src/app/qml/ui/NotesPage.qml (+1/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/improve-edit-focus
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Review via email: mp+270755@code.launchpad.net

Commit message

Improve focus handling when entering EditNoteView

To post a comment you must log in.
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Lgtm, thanks

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

PASSED: Continuous integration, rev:486
http://91.189.93.70:8080/job/reminders-app-ci/781/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/reminders-app-vivid-amd64-ci/203

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/reminders-app-ci/781/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/components/Header.qml'
2--- src/app/qml/components/Header.qml 2015-07-25 01:52:22 +0000
3+++ src/app/qml/components/Header.qml 2015-09-10 21:53:52 +0000
4@@ -6,10 +6,10 @@
5 import Evernote 0.1
6
7
8-Column {
9+FocusScope {
10 id: root
11 width: parent.width
12- height: childrenRect.height
13+ height: column.height
14
15 property var note: null
16
17@@ -19,16 +19,16 @@
18
19 signal editReminders();
20 signal editTags();
21-
22 Notebooks {
23 id: notebooks
24 }
25-
26 Component.onCompleted: setNotebookTimer.start();
27 onNoteChanged: setNotebookTimer.start();
28 // in case note is set during creation, the animation breaks if we set selectedIndex. Wait for a eventloop pass
29 Timer { id: setNotebookTimer; interval: 1; repeat: false; onTriggered: updateNotebook(); }
30
31+ onFocusChanged: if (focus) titleTextField.forceActiveFocus();
32+
33 function updateNotebook() {
34 if (!root.note) return;
35 for (var i = 0; i < notebooks.count; i++) {
36@@ -39,103 +39,109 @@
37 }
38 }
39 }
40-
41- TextField {
42- id: titleTextField
43- height: units.gu(6)
44- width: parent.width
45- text: root.note ? root.note.title : ""
46- placeholderText: i18n.tr("Untitled")
47- font.pixelSize: units.gu(4)
48- visible: root.editingEnabled
49- style: TextFieldStyle {
50- background: null
51- }
52- }
53-
54- Label {
55- height: units.gu(6)
56- anchors.left: parent.left
57- anchors.right: parent.right
58- anchors.margins: units.gu(1)
59- text: root.note ? root.note.title : ""
60- visible: !root.editingEnabled
61- font.pixelSize: units.gu(4)
62- verticalAlignment: Text.AlignVCenter
63- }
64-
65- ThinDivider {}
66-
67- ItemSelector {
68- id: notebookSelector
69- width: parent.width
70- model: notebooks
71-
72- onDelegateClicked: {
73- var newNotebookGuid = model.notebook(index).guid;
74- if (newNotebookGuid != root.note.notebookGuid) {
75- root.note.notebookGuid = newNotebookGuid;
76- NotesStore.saveNote(root.note.guid)
77- }
78- }
79-
80- delegate: OptionSelectorDelegate {
81- Rectangle {
82- anchors.fill: parent
83- color: "white"
84-
85- RowLayout {
86- anchors {
87- fill: parent
88- leftMargin: units.gu(1)
89- rightMargin: units.gu(1)
90- topMargin: units.gu(0.5)
91- bottomMargin: units.gu(0.5)
92- }
93-
94- Item {
95- height: parent.height
96- width: height
97- Icon {
98- anchors.fill: parent
99- anchors.margins: units.gu(0.5)
100- name: "notebook"
101+ Column {
102+ id: column
103+ width: parent.width
104+ height: childrenRect.height
105+
106+ TextField {
107+ id: titleTextField
108+ height: units.gu(6)
109+ width: parent.width
110+ text: root.note ? root.note.title : ""
111+ placeholderText: i18n.tr("Untitled")
112+ font.pixelSize: units.gu(4)
113+ visible: root.editingEnabled
114+ style: TextFieldStyle {
115+ background: null
116+ }
117+ }
118+
119+ Label {
120+ height: units.gu(6)
121+ anchors.left: parent.left
122+ anchors.right: parent.right
123+ anchors.margins: units.gu(1)
124+ text: root.note ? root.note.title : ""
125+ visible: !root.editingEnabled
126+ font.pixelSize: units.gu(4)
127+ verticalAlignment: Text.AlignVCenter
128+ }
129+
130+ ThinDivider {}
131+
132+ ItemSelector {
133+ id: notebookSelector
134+ width: parent.width
135+ model: notebooks
136+
137+ onDelegateClicked: {
138+ var newNotebookGuid = model.notebook(index).guid;
139+ if (newNotebookGuid != root.note.notebookGuid) {
140+ root.note.notebookGuid = newNotebookGuid;
141+ NotesStore.saveNote(root.note.guid)
142+ }
143+ }
144+
145+ delegate: OptionSelectorDelegate {
146+ Rectangle {
147+ anchors.fill: parent
148+ color: "white"
149+
150+ RowLayout {
151+ anchors {
152+ fill: parent
153+ leftMargin: units.gu(1)
154+ rightMargin: units.gu(1)
155+ topMargin: units.gu(0.5)
156+ bottomMargin: units.gu(0.5)
157+ }
158+
159+ Item {
160+ height: parent.height
161+ width: height
162+ Icon {
163+ anchors.fill: parent
164+ anchors.margins: units.gu(0.5)
165+ name: "notebook"
166+ color: preferences.colorForNotebook(model.guid)
167+ }
168+ }
169+
170+ Label {
171+ text: model.name
172+ Layout.fillWidth: true
173 color: preferences.colorForNotebook(model.guid)
174 }
175- }
176-
177- Label {
178- text: model.name
179- Layout.fillWidth: true
180- color: preferences.colorForNotebook(model.guid)
181- }
182- RtfButton {
183- iconName: root.note && root.note.reminder ? "reminder" : "reminder-new"
184- height: parent.height
185- width: height
186- iconColor: root.note && note.reminder ? UbuntuColors.blue : Qt.rgba(0.0, 0.0, 0.0, 0.0)
187- visible: index == notebookSelector.selectedIndex
188- onClicked: {
189- Qt.inputMethod.hide();
190- root.editReminders();
191+ RtfButton {
192+ iconName: root.note && root.note.reminder ? "reminder" : "reminder-new"
193+ height: parent.height
194+ width: height
195+ iconColor: root.note && note.reminder ? UbuntuColors.blue : Qt.rgba(0.0, 0.0, 0.0, 0.0)
196+ visible: index == notebookSelector.selectedIndex
197+ onClicked: {
198+ Qt.inputMethod.hide();
199+ root.editReminders();
200+ }
201 }
202- }
203- RtfButton {
204- id: tagsButton
205- iconSource: "../images/tags.svg"
206- height: parent.height
207- width: height
208- visible: index == notebookSelector.selectedIndex
209- onClicked: {
210- Qt.inputMethod.hide();
211- root.editTags();
212+ RtfButton {
213+ id: tagsButton
214+ iconSource: "../images/tags.svg"
215+ height: parent.height
216+ width: height
217+ visible: index == notebookSelector.selectedIndex
218+ onClicked: {
219+ Qt.inputMethod.hide();
220+ root.editTags();
221+ }
222 }
223 }
224 }
225 }
226 }
227+
228+ ThinDivider {}
229 }
230-
231- ThinDivider {}
232 }
233
234+
235
236=== modified file 'src/app/qml/reminders.qml'
237--- src/app/qml/reminders.qml 2015-09-08 18:10:48 +0000
238+++ src/app/qml/reminders.qml 2015-09-10 21:53:52 +0000
239@@ -480,12 +480,13 @@
240 var note = NotesStore.note(guid);
241 print("note created:", note.guid);
242 if (root.narrowMode) {
243- var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note});
244+ var page = pagestack.push(Qt.resolvedUrl("ui/EditNotePage.qml"), {note: note, newNote: true});
245 page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop();});
246 } else {
247 notesPage.selectedNote = note;
248 var view = sideViewLoader.embed(Qt.resolvedUrl("ui/EditNoteView.qml"));
249 view.note = note;
250+ view.newNote = true;
251 view.exitEditMode.connect(function(note) {root.displayNote(note)});
252 }
253 }
254
255=== modified file 'src/app/qml/ui/EditNotePage.qml'
256--- src/app/qml/ui/EditNotePage.qml 2015-07-25 01:52:22 +0000
257+++ src/app/qml/ui/EditNotePage.qml 2015-09-10 21:53:52 +0000
258@@ -25,6 +25,8 @@
259 Page {
260 id: root
261 property alias note: editNoteView.note
262+ property alias newNote: editNoteView.newNote
263+ property alias isBottomEdge: editNoteView.isBottomEdge
264
265 signal exitEditMode(var note)
266
267
268=== modified file 'src/app/qml/ui/EditNoteView.qml'
269--- src/app/qml/ui/EditNoteView.qml 2015-07-25 01:52:22 +0000
270+++ src/app/qml/ui/EditNoteView.qml 2015-09-10 21:53:52 +0000
271@@ -30,6 +30,8 @@
272 Item {
273 id: root
274 property var note
275+ property bool newNote: false
276+ property bool isBottomEdge: false
277
278 onNoteChanged: {
279 note.renderWidth = noteTextArea.width - noteTextArea.textMargin * 2
280@@ -51,6 +53,28 @@
281 }
282 }
283
284+ Component.onCompleted: {
285+ init();
286+ }
287+
288+ onNewNoteChanged: {
289+ init();
290+ }
291+
292+ function init() {
293+ if (root.isBottomEdge) {
294+ return;
295+ }
296+
297+ if (root.newNote) {
298+ header.title = "";
299+ header.forceActiveFocus();
300+ } else {
301+ noteTextArea.forceActiveFocus();
302+ }
303+ }
304+
305+
306 QtObject {
307 id: priv
308 property int insertPosition
309@@ -134,6 +158,7 @@
310 Header {
311 id: header
312 note: root.note
313+ focus: root.newNote
314
315 onEditReminders: {
316 pageStack.push(Qt.resolvedUrl("SetReminderPage.qml"), { note: root.note});
317
318=== modified file 'src/app/qml/ui/NotesPage.qml'
319--- src/app/qml/ui/NotesPage.qml 2015-07-25 01:52:22 +0000
320+++ src/app/qml/ui/NotesPage.qml 2015-09-10 21:53:52 +0000
321@@ -42,6 +42,7 @@
322 bottomEdgeLabelVisible: narrowMode && (!notes.filterNotebookGuid || !notes.loading)
323 bottomEdgeTitle: i18n.tr("Add note")
324 bottomEdgePageComponent: EditNotePage {
325+ isBottomEdge: true
326 MouseArea {
327 anchors.fill: parent
328 }

Subscribers

People subscribed via source and target branches