20
20
import Ubuntu.Components 1.3
21
21
import Ubuntu.OnlineAccounts.Client 0.1
22
import Qt.labs.settings 1.0
25
26
title: i18n.tr("Settings")
27
property var setMethods: {
28
"mmsEnabled": function(value) { telepathyHelper.mmsEnabled = value }/*,
29
"characterCountEnabled": function(value) { msgSettings.showCharacterCount = value }*/
31
property var settingsModel: [
32
{ "name": "mmsEnabled",
33
"description": i18n.tr("Enable MMS messages"),
34
"property": telepathyHelper.mmsEnabled,
35
"activatedFuncion": null
37
{ "name": "addAccount",
38
"description": i18n.tr("Add an online account"),
39
"onActivated": "createAccount",
28
function createAccount()
30
if (onlineAccountHelper.item)
31
onlineAccountHelper.item.run()
34
readonly property var setMethods: {
35
"mmsEnabled": function(value) { telepathyHelper.mmsEnabled = value },
36
"threadSort": function(value) { mainView.sortThreadsBy = value },
37
"compactView": function(value) { mainView.compactView = value }
38
//"characterCountEnabled": function(value) { msgSettings.showCharacterCount = value }
41
property var sortByModel: {
42
"timestamp": i18n.tr("Sort by timestamp"),
43
"title": i18n.tr("Sort by title")
46
readonly property var settingsModel: [
48
"data": {"name": "mmsEnabled",
49
"description": i18n.tr("Enable MMS messages"),
50
"property": telepathyHelper.mmsEnabled,
51
"activatedFuncion": null,
52
"setMethod": "mmsEnabled"}
55
"data": {"name": "compactView",
56
"description": i18n.tr("Simplified conversation view"),
57
"property": mainView.compactView,
58
"activatedFuncion": null,
59
"setMethod": "compactView"}
62
"data": { "name": "addAccount",
63
"description": i18n.tr("Add an online account"),
64
"onActivated": "createAccount" }
67
"data": { "name": "threadSort",
68
"description": i18n.tr("Sort threads"),
69
"currentValue": mainView.sortTrheadsBy,
70
"subtitle": settingsPage.sortByModel[mainView.sortTrheadsBy],
71
"options": sortByModel,
72
"setMethod": "threadSort"}
43
75
{ "name": "characterCountEnabled",
82
114
id: settingDelegate
85
if (checkbox.visible) {
86
checkbox.checked = !checkbox.checked
88
settingsPage[modelData.onActivated]()
117
layoutDelegate.item.activate()
118
settingsList.currentIndex = index
92
title.text: modelData.description
96
objectName: modelData.name
98
visible: modelData.property !== null
99
SlotsLayout.position: SlotsLayout.trailing
100
checked: modelData.property
102
if (checked != modelData.property) {
103
settingsPage.setMethods[modelData.name](checked)
122
title.text: modelData.data.description
123
subtitle.text: modelData.data.subtitle ? modelData.data.subtitle : ""
129
switch(modelData.type) {
131
return actionDelegate
133
return booleanDelegate
135
return optionsDelegate
109
visible: modelData.property === null
140
target: layoutDelegate.item
141
property: "modelData"
142
value: modelData.data
143
when: layoutDelegate.status === Loader.Ready
146
target: layoutDelegate.item
149
when: layoutDelegate.status === Loader.Ready
161
objectName: modelData.name
163
property var modelData: null
164
property int index: -1
168
checkbox.checked = !checkbox.checked
171
SlotsLayout.position: SlotsLayout.Trailing
172
checked: modelData.property
174
if (checked != modelData.property) {
175
settingsPage.setMethods[modelData.setMethod](checked)
186
objectName: modelData.name
188
property var modelData: null
189
property int index: -1
192
settingsPage[modelData.onActivated]()
202
objectName: modelData.name
204
property var modelData: null
205
property int index: -1
208
pageStack.addPageToNextColumn(settingsPage, optionsDelegatePage,
209
{"title": modelData.description,
210
"model": modelData.options,
212
"currentIndex": modelData.currentValue,
213
"setMethod": modelData.setMethod})
219
id: optionsDelegatePage
224
property alias title: pageHeader.title
226
property string currentIndex
227
property string setMethod
228
property int index: -1
230
signal selected(string key)
232
function indexOf(key) {
233
return Object.keys(optionsPage.model).indexOf(key)
238
settingsPage.setMethods[optionsPage.setMethod](key)
240
//WORKAROUND: re-set index of settings page because the list is
241
// rebuild after a value change and that cause the index to reset to 0
242
settingsList.currentIndex = index
243
pageStack.removePages(optionsPage)
249
leadingActionBar.actions: [
252
text: i18n.tr("Back")
254
onTriggered: optionsPage.selected("")
263
model: Object.keys(optionsPage.model)
265
currentIndex: optionsPage.indexOf(optionsPage.currentIndex)
268
title.text: optionsPage.model[modelData]
270
onClicked: optionsPage.selected(modelData)
274
onActiveChanged: this.forceActiveFocus()