Debian Codegraph @

src/imports/Settings/SettingsPage.qml

raw ◀ ▶
Source reconstructed at patch state 3 of 4 — not the installed (fully patched) source.
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 header: PageHeader {
33 id: pageHeader
34
35 title: i18n.tr("Settings")
36 flickable: null
37 }
38
39 ContactsUI.SIMList {
40 id: simList
41 }
42
43 MyselfPhoneNumbersModel {
44 id: myself
45 }
46
47 Flickable {
48 id: numberFlickable
49 contentHeight: childrenRect.height
50 anchors {
51 top: pageHeader.bottom
52 left: parent.left
53 right: parent.right
54 bottom: parent.bottom
55 }
56 clip: true
57
58 Column {
59 anchors{
60 left: parent.left
61 right: parent.right
62 }
63 height: childrenRect.height + units.gu(4)
64
65 Repeater {
66 anchors {
67 left: parent.left
68 right: parent.right
69 }
70 model: myself
71 delegate: ListItem.Subtitled {
72 text: phoneNumber.length > 0 ? i18n.tr("My phone number: %1").arg(phoneNumber) : i18n.tr("Could not read phone number from SIM card")
73 subText: network != "" ? network : i18n.tr("SIM %1").arg(index)
74 }
75 onCountChanged: numberFlickable.contentY = 0
76 }
77
78 ListItem.Standard {
79 id: mynumbersPlaceHolder
80 text: i18n.dtr("lomiri-addressbook-app", "Reading my phone number(s)...")
81 visible: myself.count == 0
82 }
83
84 Repeater {
85 model: onlineAccountsHelper.providerModel
86
87 ListItem.Standard {
88 id: addAccountItem
89 property bool selected: (activeFocus && pageStack.hasKeyboard)
90
91 function activate()
92 {
93 onlineAccountsHelper.setupExec(model.providerId)
94 }
95
96 text: i18n.tr("Add %1 account").arg(model.displayName)
97 progression: true
98 enabled: buteoSync.serviceAvailable
99
100 onClicked: activate()
101 Keys.onRightPressed: activate()
102 Keys.onDownPressed: {
103 if (importFromSimItem.enabled) {
104 importFromSimItem.forceActiveFocus()
105 }
106 }
107 }
108 }
109 ListItem.Standard {
110 id: importFromSimItem
111
112 property bool selected: (activeFocus && pageStack.hasKeyboard)
113
114 function activate()
115 {
116 pageStack.addPageToCurrentColumn(root, simCardImportPageComponent)
117 }
118
119 text: i18n.tr("Import from SIM")
120 progression: true
121 enabled: (simList.sims.length > 0) && (simList.present.length > 0)
122 onClicked: importFromSimItem.activate()
123 Keys.onRightPressed: importFromSimItem.activate()
124 Keys.onUpPressed: addGoogleAccountItem.forceActiveFocus()
125 Keys.onDownPressed: importFromVCFItem.forceActiveFocus()
126 }
127
128 ListItem.Standard {
129 id: importFromVCFItem
130
131 property bool selected: (activeFocus && pageStack.hasKeyboard)
132 function activate()
133 {
134 pageStack.addPageToCurrentColumn(root, importContactPageComponent)
135 }
136 text: i18n.tr("Import from vCard file")
137 progression: true
138 onClicked: importFromVCFItem.activate()
139 Keys.onRightPressed: importFromVCFItem.activate()
140 Keys.onUpPressed: importFromSimItem.forceActiveFocus()
141 Keys.onDownPressed: exportAllContactsItem.forceActiveFocus()
142
143 }
144
145 ListItem.Standard {
146 id: exportAllContactsItem
147
148 property bool selected: (activeFocus && pageStack.hasKeyboard)
149
150 function activate()
151 {
152 pageStack.addPageToNextColumn(root,
153 Qt.resolvedUrl("../ContactShare/ContactSharePage.qml"),
154 {contactModel: root.contactListModel,
155 contacts: root.contactListModel.contacts })
156 }
157
158 text: i18n.tr("Export all contacts")
159 progression: true
160 onClicked: exportAllContactsItem.activate()
161 Keys.onRightPressed: exportAllContactsItem.activate()
162 Keys.onUpPressed: importFromVCFItem.forceActiveFocus()
163 }
164 ListItem.Empty {
165 height: childrenRect.height
166 Label {
167 id: label
168
169 text: i18n.tr("Default address book")
170 anchors {
171 left: parent.left
172 top: parent.top
173 right: parent.right
174 margins: units.gu(2)
175 }
176 height: units.gu(4)
177 }
178
179 ContactsUI.AddressBooksSelector {
180 id: addressBooksSelector
181
182 anchors {
183 left: parent.left
184 leftMargin: units.gu(2)
185 top: label.bottom
186 right: parent.right
187 rightMargin: units.gu(2)
188 bottom: parent.bottom
189 bottomMargin: units.gu(2)
190 }
191 height: implicitHeight
192
193 currentCollectionId: ContactsUI.Contacts.defaultCollectionId
194 contactModel: contactListModel
195 onAddressBookChanged: {
196 ContactsUI.Contacts.defaultCollectionId = collectionId
197 }
198 }
199 }
200 }
201 }
202 ContactsUI.OnlineAccountsHelper {
203 id: onlineAccountsHelper
204 }
205
206 Binding {
207 target: pageStack
208 property: 'bottomEdge'
209 value: null
210 }
211
212 Component {
213 id: simCardImportPageComponent
214
215 ContactsUI.SIMCardImportPage {
216 id: importFromSimPage
217
218 objectName: "simCardImportPage"
219 targetModel: root.contactListModel
220 sims: simList.sims
221 onImportCompleted: pageStack.removePages(root)
222 }
223 }
224
225 Component {
226 id: importContactPageComponent
227 ContactsUI.ContactImportPage {
228 id: importFromVCF
229 }
230 }
231
232 ButeoSync {
233 id: buteoSync
234 }
235
236 Keys.onDownPressed: addGoogleAccountItem.forceActiveFocus()
237 Keys.onRightPressed: addGoogleAccountItem.forceActiveFocus()
238 Keys.onLeftPressed: pageStack.removePages(root)
239 Keys.onEscapePressed: pageStack.removePages(root)
240 onActiveChanged: {
241 if (active) {
242 root.forceActiveFocus()
243 addressBooksSelector.update()
244 }
245 }
246 }