Debian Codegraph @

src/imports/Settings/SettingsPage.qml

raw ◀ ▶
Source reconstructed at patch state 2 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
165
166 SettingsDefaultSyncTarget {
167 id: defaultSyncTarget
168 onChanged: save()
169 }
170 }
171 }
172 ContactsUI.OnlineAccountsHelper {
173 id: onlineAccountsHelper
174 }
175
176 Binding {
177 target: pageStack
178 property: 'bottomEdge'
179 value: null
180 }
181
182 Component {
183 id: simCardImportPageComponent
184
185 ContactsUI.SIMCardImportPage {
186 id: importFromSimPage
187
188 objectName: "simCardImportPage"
189 targetModel: root.contactListModel
190 sims: simList.sims
191 onImportCompleted: pageStack.removePages(root)
192 }
193 }
194
195 Component {
196 id: importContactPageComponent
197 ContactsUI.ContactImportPage {
198 id: importFromVCF
199 }
200 }
201
202 ButeoSync {
203 id: buteoSync
204 }
205
206 Keys.onDownPressed: addGoogleAccountItem.forceActiveFocus()
207 Keys.onRightPressed: addGoogleAccountItem.forceActiveFocus()
208 Keys.onLeftPressed: pageStack.removePages(root)
209 Keys.onEscapePressed: pageStack.removePages(root)
210 onActiveChanged: {
211 if (active) {
212 root.forceActiveFocus()
213 defaultSyncTarget.update()
214 }
215 }
216 }