~untrusted-ci-dev-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-yakkety-landing-004

« back to all changes in this revision

Viewing changes to plugins/notifications/PageComponent.qml

  • Committer: Ken VanDine
  • Date: 2016-07-22 14:36:16 UTC
  • mfrom: (1673 ubuntu-system-settings)
  • mto: This revision was merged to the branch mainline in revision 1678.
  • Revision ID: ken.vandine@canonical.com-20160722143616-xdhvfbvp1g8dku77
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import QtQuick 2.4
20
20
import Ubuntu.Components 1.3
21
 
import Ubuntu.Components.ListItems 1.3 as ListItem
 
21
import Ubuntu.Components.ListItems 1.3 as ListItems
22
22
import Ubuntu.SystemSettings.Notifications 1.0
23
23
import SystemSettings 1.0
24
24
 
28
28
 
29
29
    title: i18n.tr("Notifications")
30
30
 
31
 
    NotificationsManager {
32
 
        id: notificationsManager
33
 
    }
34
 
 
35
 
    ListItem.Base {
36
 
        id: subtitle
37
 
        height: labelSubtitle.height + units.gu(2)
38
 
        Label {
39
 
            id: labelSubtitle
40
 
            text: i18n.tr("Selected apps can alert you using notification bubbles, sounds, vibrations, and the Notifications list.")
41
 
            wrapMode: Text.WordWrap
42
 
            anchors {
43
 
                top: parent.top
44
 
                left: parent.left
45
 
                right: parent.right
46
 
                margins: units.gu(1)
47
 
            }
 
31
    onActiveChanged: {
 
32
        if (active) {
 
33
            clickAppsSoundsNotifyModel.updateEnabledEntries()
 
34
            clickAppsVibrationsNotifyModel.updateEnabledEntries()
48
35
        }
49
 
        highlightWhenPressed: false
 
36
    }
 
37
 
 
38
    ClickApplicationsNotifyModel {
 
39
        id: clickAppsSoundsNotifyModel
 
40
        objectName: "clickAppsSoundsNotifyModel"
 
41
        notifyType: ClickApplicationsNotifyModel.SoundsNotify
 
42
        sourceModel: ClickApplicationsModel
 
43
    }
 
44
 
 
45
    ClickApplicationsNotifyModel {
 
46
        id: clickAppsVibrationsNotifyModel
 
47
        objectName: "clickAppsVibrationsNotifyModel"
 
48
        notifyType: ClickApplicationsNotifyModel.VibrationsNotify
 
49
        sourceModel: ClickApplicationsModel
50
50
    }
51
51
 
52
52
    ListView {
55
55
        anchors {
56
56
            left: parent.left
57
57
            right: parent.right
58
 
            top: subtitle.bottom
 
58
            top: parent.top
59
59
            bottom: parent.bottom
60
60
        }
61
 
        model: notificationsManager.model
 
61
        model: ClickApplicationsModel
62
62
        clip: true
63
 
        contentHeight: contentItem.childrenRect.height
64
 
 
65
 
        delegate: ListItem.Standard {
66
 
            text: modelData.title
67
 
            Component.onCompleted: {
68
 
                if (modelData.icon.search("/") == -1) {
69
 
                    iconName = modelData.icon
70
 
                }
71
 
                else {
72
 
                    iconSource = modelData.icon
73
 
                }
74
 
            }
75
 
            control: Switch {
76
 
                checked: modelData.status
77
 
 
78
 
                onCheckedChanged: {
79
 
                    modelData.status = checked;
 
63
 
 
64
        header: Column {
 
65
            anchors {
 
66
                left: parent.left
 
67
                right: parent.right
 
68
            }
 
69
 
 
70
            ListItems.Base {
 
71
                height: labelSubtitle.height + units.gu(2)
 
72
                Label {
 
73
                    id: labelSubtitle
 
74
                    text: i18n.tr("Apps can alert you using sounds, vibrations, notification bubbles and the Notification list.")
 
75
                    wrapMode: Text.WordWrap
 
76
                    color: theme.palette.normal.backgroundSecondaryText
 
77
                    anchors {
 
78
                        top: parent.top
 
79
                        left: parent.left
 
80
                        right: parent.right
 
81
                        topMargin: units.gu(1)
 
82
                    }
 
83
                }
 
84
 
 
85
                highlightWhenPressed: false
 
86
            }
 
87
 
 
88
            ListItem {
 
89
                ListItemLayout {
 
90
                    title.text: i18n.tr("Apps that notify with sound");
 
91
                    Label {
 
92
                        objectName: "clickAppsSoundsNotifyLabel"
 
93
                        text: clickAppsSoundsNotifyModel.count
 
94
                        SlotsLayout.position: SlotsLayout.Trailing;
 
95
                    }
 
96
                    Icon {
 
97
                        name: "next"
 
98
                        SlotsLayout.position: SlotsLayout.Trailing;
 
99
                        width: units.gu(2)
 
100
                    }
 
101
                }
 
102
 
 
103
                onClicked: {
 
104
                    if (clickAppsSoundsNotifyModel.count <= 0) {
 
105
                        return
 
106
                    }
 
107
 
 
108
                    pageStack.push(Qt.resolvedUrl("ClickAppsSoundsNotify.qml"),
 
109
                                                  { model: clickAppsSoundsNotifyModel })
 
110
                }
 
111
            }
 
112
 
 
113
            ListItem {
 
114
                ListItemLayout {
 
115
                    title.text: i18n.tr("Apps that notify with vibration");
 
116
                    Label {
 
117
                        objectName: "clickAppsVibrationsNotifyLabel"
 
118
                        text: clickAppsVibrationsNotifyModel.count
 
119
                        SlotsLayout.position: SlotsLayout.Trailing;
 
120
                    }
 
121
                    Icon {
 
122
                        name: "next"
 
123
                        SlotsLayout.position: SlotsLayout.Trailing;
 
124
                        width: units.gu(2)
 
125
                    }
 
126
                }
 
127
 
 
128
                onClicked: {
 
129
                    if (clickAppsVibrationsNotifyModel.count <= 0) {
 
130
                        return
 
131
                    }
 
132
 
 
133
                    pageStack.push(Qt.resolvedUrl("ClickAppsVibrationsNotify.qml"),
 
134
                                                  { model: clickAppsVibrationsNotifyModel })
 
135
                }
 
136
            }
 
137
 
 
138
            ListItem {
 
139
                ListItemLayout {
 
140
                    title.text: i18n.tr("Applications:")
 
141
                    title.color: theme.palette.normal.backgroundSecondaryText
 
142
                }
 
143
            }
 
144
 
 
145
        }
 
146
 
 
147
        delegate: ListItem {
 
148
            height: layout.height + (divider.visible ? divider.height : 0)
 
149
 
 
150
            onClicked: pageStack.push(Qt.resolvedUrl("ClickAppNotifications.qml"),
 
151
                                                     { entry: model,
 
152
                                                       entryIndex: index })
 
153
 
 
154
            ListItemLayout {
 
155
                id: layout
 
156
 
 
157
                Component.onCompleted: {
 
158
                    var iconPath = model.icon.toString()
 
159
                    if (iconPath.search("/") == -1) {
 
160
                        icon.name = model.icon
 
161
                    } else {
 
162
                        icon.source = model.icon
 
163
                    }
 
164
                }
 
165
 
 
166
                title.text: model.displayName
 
167
                subtitle.text: {
 
168
                    if (!model.enableNotifications) {
 
169
                        return i18n.tr("No notifications")
 
170
                    }
 
171
 
 
172
                    var arr = []
 
173
                    if (model.soundsNotify) {
 
174
                        arr.push(i18n.tr("Sounds"))
 
175
                    }
 
176
                    if (model.vibrationsNotify) {
 
177
                        arr.push(i18n.tr("Vibrations"))
 
178
                    }
 
179
                    if (model.bubblesNotify) {
 
180
                        arr.push(i18n.tr("Bubbles"))
 
181
                    }
 
182
                    if (model.listNotify) {
 
183
                        arr.push(i18n.tr("Notification List"))
 
184
                    }
 
185
 
 
186
                    return arr.join(", ")
 
187
                }
 
188
                Icon {
 
189
                    id: icon
 
190
                    SlotsLayout.position: SlotsLayout.Leading;
 
191
                    width: units.gu(5)
 
192
                }
 
193
                Icon {
 
194
                    name: "next"
 
195
                    SlotsLayout.position: SlotsLayout.Trailing;
 
196
                    width: units.gu(2)
80
197
                }
81
198
            }
82
199
        }