~saviq/ubuntu-system-settings/one-xvfb

« back to all changes in this revision

Viewing changes to plugins/notifications/ClickAppsVibrationsNotify.qml

Implement extended Notifications panel using Gsettings to store notifications settings for each app

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2013-2014 Canonical Ltd.
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License version 3, as published
 
8
 * by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
12
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
13
 * PURPOSE.  See the GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import Ubuntu.Components 1.3
 
21
import Ubuntu.SystemSettings.Notifications 1.0
 
22
import SystemSettings 1.0
 
23
 
 
24
ItemPage {
 
25
    id: appsVibrationsNotifyPage
 
26
    objectName: "appsVibrationsNotifyPage"
 
27
 
 
28
    property alias model: appsVibrationsNotifyList.model
 
29
 
 
30
    title: i18n.tr("Vibration")
 
31
 
 
32
    ListView {
 
33
        id: appsVibrationsNotifyList
 
34
        objectName: "appsVibrationsNotifyList"
 
35
 
 
36
        anchors {
 
37
            left: parent.left
 
38
            right: parent.right
 
39
            top: parent.top
 
40
            bottom: parent.bottom
 
41
        }
 
42
 
 
43
        clip: true
 
44
        contentHeight: contentItem.childrenRect.height
 
45
 
 
46
        header: Column {
 
47
            anchors {
 
48
                left: parent.left
 
49
                right: parent.right
 
50
            }
 
51
 
 
52
            ListItem {
 
53
                ListItemLayout {
 
54
                    title.text: i18n.tr("When in Silent mode:") 
 
55
                    title.color: theme.palette.normal.backgroundSecondaryText
 
56
                }
 
57
            }
 
58
 
 
59
            ListItem {
 
60
                height: layout.height + (divider.visible ? divider.height : 0)
 
61
                SlotsLayout {
 
62
                    id: layout
 
63
 
 
64
                    mainSlot: Item {
 
65
                        height: optionSelector.itemHeight * 2
 
66
                        width: parent.width - 2 * (layout.padding.leading + layout.padding.trailing)
 
67
                        OptionSelector {
 
68
                            id: optionSelector
 
69
 
 
70
                            selectedIndex: GeneralNotificationSettings.vibrateInSilentMode ? 0 : 1
 
71
                            expanded: true
 
72
                            model: [i18n.tr("Vibrate as normal"),
 
73
                                    i18n.tr("Don't vibrate")]
 
74
 
 
75
                            onDelegateClicked: {
 
76
                                if (index === 0) {
 
77
                                    GeneralNotificationSettings.vibrateInSilentMode = true
 
78
                                } else {
 
79
                                    GeneralNotificationSettings.vibrateInSilentMode = false
 
80
                                }
 
81
                            }
 
82
                        }
 
83
                    }
 
84
                }
 
85
            }
 
86
 
 
87
            ListItem {
 
88
                ListItemLayout {
 
89
                    title.text: i18n.tr("Apps that notify with vibrations:")
 
90
                    title.color: theme.palette.normal.backgroundSecondaryText
 
91
                }
 
92
            }
 
93
        }
 
94
 
 
95
        delegate: ListItem {
 
96
            ListItemLayout {
 
97
                Component.onCompleted: {
 
98
                    var iconPath = model.icon.toString()
 
99
                    if (iconPath.search("/") == -1) {
 
100
                        icon.name = model.icon
 
101
                    } else {
 
102
                        icon.source = model.icon
 
103
                    }
 
104
                }
 
105
 
 
106
                title.text: model.displayName
 
107
 
 
108
                Row {
 
109
                    spacing: units.gu(2)
 
110
 
 
111
                    SlotsLayout.position: SlotsLayout.Leading;
 
112
 
 
113
                    CheckBox {
 
114
                        anchors.verticalCenter: icon.verticalCenter
 
115
                        checked: model.vibrationsNotify
 
116
 
 
117
                        onCheckedChanged: appsVibrationsNotifyPage.model.setNotifyEnabled(index, checked)
 
118
                    }
 
119
 
 
120
                    Icon {
 
121
                        id: icon
 
122
                        width: units.gu(5)
 
123
                    }
 
124
                }
 
125
            }
 
126
        }
 
127
    }
 
128
}