Debian Codegraph @

src/imports/Settings/SettingsPage.qml

raw ◀ ▶
4 Debian patches touch this file
1 /*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import QtContacts 5.0
19
20 import Lomiri.Components 1.3
•21 import Lomiri.Components.ListItems 1.3 as ListItem
22 import Lomiri.Contacts 0.1 as ContactsUI
•23
24 import Buteo 0.1
25
26 Page {
27 id: root
28 objectName: "settingsPage"
29
30 property var contactListModel
31
•32 /*!
33 This handler is called when online account operation finish
34 */
35 signal onlineAccountFinished()
36
37 header: PageHeader {
38 id: pageHeader
39
40 title: i18n.tr("Settings")
41 flickable: null
42 }
43
44 ContactsUI.SIMList {
45 id: simList
46 }
47
48 MyselfPhoneNumbersModel {
49 id: myself
50 }
51
52 Flickable {
53 id: numberFlickable
54 contentHeight: childrenRect.height
55 anchors {
56 top: pageHeader.bottom
57 left: parent.left
58 right: parent.right
59 bottom: parent.bottom
60 }
61 clip: true
62
63 Column {
64 anchors{
65 left: parent.left
66 right: parent.right
67 }
68 height: childrenRect.height + units.gu(4)
69
70 Repeater {
71 anchors {
72 left: parent.left
73 right: parent.right
74 }
75 model: myself
•76 delegate: ListItem.Subtitled {
77 text: phoneNumber.length > 0 ? i18n.tr("My phone number: %1").arg(phoneNumber) : i18n.tr("Could not read phone number from SIM card")
78 subText: network != "" ? network : i18n.tr("SIM %1").arg(index)
79 }
80 onCountChanged: numberFlickable.contentY = 0
81 }
82
•83 ListItem.Standard {
84 id: mynumbersPlaceHolder
85 text: i18n.dtr("lomiri-addressbook-app", "Reading my phone number(s)...")
86 visible: myself.count == 0
87 }
88
89 Repeater {
90 model: onlineAccountsHelper.providerModel
91
•92 ListItem.Standard {
93 id: addAccountItem
94 property bool selected: (activeFocus && pageStack.hasKeyboard)
95
96 function activate()
97 {
98 onlineAccountsHelper.setupExec(model.providerId)
99 }
100
101 text: i18n.tr("Add %1 account").arg(model.displayName)
102 progression: true
103 enabled: buteoSync.serviceAvailable
104
105 onClicked: activate()
106 Keys.onRightPressed: activate()
107 Keys.onDownPressed: {
108 if (importFromSimItem.enabled) {
109 importFromSimItem.forceActiveFocus()
110 }
111 }
112 }
113 }
•114 ListItem.Standard {
115 id: importFromSimItem
116
117 property bool selected: (activeFocus && pageStack.hasKeyboard)
118
119 function activate()
120 {
121 pageStack.addPageToCurrentColumn(root, simCardImportPageComponent)
122 }
123
124 text: i18n.tr("Import from SIM")
125 progression: true
126 enabled: (simList.sims.length > 0) && (simList.present.length > 0)
127 onClicked: importFromSimItem.activate()
128 Keys.onRightPressed: importFromSimItem.activate()
129 Keys.onUpPressed: addGoogleAccountItem.forceActiveFocus()
130 Keys.onDownPressed: importFromVCFItem.forceActiveFocus()
131 }
132
•133 ListItem.Standard {
134 id: importFromVCFItem
135
136 property bool selected: (activeFocus && pageStack.hasKeyboard)
137 function activate()
138 {
139 pageStack.addPageToCurrentColumn(root, importContactPageComponent)
140 }
141 text: i18n.tr("Import from vCard file")
142 progression: true
143 onClicked: importFromVCFItem.activate()
144 Keys.onRightPressed: importFromVCFItem.activate()
145 Keys.onUpPressed: importFromSimItem.forceActiveFocus()
146 Keys.onDownPressed: exportAllContactsItem.forceActiveFocus()
147
148 }
149
•150 ListItem.Standard {
151 id: exportAllContactsItem
152
153 property bool selected: (activeFocus && pageStack.hasKeyboard)
154
155 function activate()
156 {
157 pageStack.addPageToNextColumn(root,
158 Qt.resolvedUrl("../ContactShare/ContactSharePage.qml"),
159 {contactModel: root.contactListModel,
160 contacts: root.contactListModel.contacts })
161 }
162
163 text: i18n.tr("Export all contacts")
164 progression: true
165 onClicked: exportAllContactsItem.activate()
166 Keys.onRightPressed: exportAllContactsItem.activate()
167 Keys.onUpPressed: importFromVCFItem.forceActiveFocus()
168 }
•169 ListItem.Empty {
170 height: childrenRect.height
171 Label {
172 id: label
173
174 text: i18n.tr("Default address book")
•175 anchors {
176 left: parent.left
177 top: parent.top
178 right: parent.right
179 margins: units.gu(2)
180 }
181 height: units.gu(4)
182 }
183
•184 ContactsUI.AddressBooksSelector {
185 id: addressBooksSelector
186
187 anchors {
188 left: parent.left
189 leftMargin: units.gu(2)
190 top: label.bottom
191 right: parent.right
192 rightMargin: units.gu(2)
193 bottom: parent.bottom
194 bottomMargin: units.gu(2)
195 }
196 height: implicitHeight
197
•198 currentCollectionId: ContactsUI.Contacts.defaultCollectionId
199 contactModel: contactListModel
200 onAddressBookChanged: {
201 ContactsUI.Contacts.defaultCollectionId = collectionId
202 }
203 }
204 }
205 }
206 }
207 ContactsUI.OnlineAccountsHelper {
208 id: onlineAccountsHelper
•209 onFinished: {
210 root.onlineAccountFinished()
211 }
212 }
213
214 Binding {
215 target: pageStack
216 property: 'bottomEdge'
217 value: null
218 }
219
220 Component {
221 id: simCardImportPageComponent
222
223 ContactsUI.SIMCardImportPage {
224 id: importFromSimPage
225
226 objectName: "simCardImportPage"
227 targetModel: root.contactListModel
228 sims: simList.sims
229 onImportCompleted: pageStack.removePages(root)
230 }
231 }
232
233 Component {
234 id: importContactPageComponent
235 ContactsUI.ContactImportPage {
236 id: importFromVCF
237 }
238 }
239
•240 ButeoSync {
241 id: buteoSync
242 }
243
244 Keys.onDownPressed: addGoogleAccountItem.forceActiveFocus()
245 Keys.onRightPressed: addGoogleAccountItem.forceActiveFocus()
246 Keys.onLeftPressed: pageStack.removePages(root)
247 Keys.onEscapePressed: pageStack.removePages(root)
248 onActiveChanged: {
249 if (active) {
250 root.forceActiveFocus()
•251 addressBooksSelector.update()
252 }
253 }
254 }