on 04da464 help sign in
unity8/Notifications/NotificationMenuItemFactory.qml
110 lines 3.0 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import "../Components"
23import "../Greeter"
25Loader {
26 id: menuFactory
28 property QtObject menuModel: null
29 property QtObject menuData: null
30 property int menuIndex
31 property var notification
33 property var _map: {
34 "com.canonical.snapdecision.textfield": textfield,
35 "com.canonical.snapdecision.pinlock" : pinLock,
36 }
38 sourceComponent: {
39 if (menuData.type !== undefined) {
40 var component = _map[menuData.type];
41 if (component !== undefined) {
42 return component;
43 }
44 }
45 }
47 Component {
48 id: textfield
50 Column {
51 spacing: units.gu(2)
53 anchors.left: parent.left; anchors.right: parent.right
55 Component.onCompleted: {
56 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
57 checkBox.checked = menuData.ext.xEchoModePassword ? false : true
58 checkBoxRow.visible = menuData.ext.xEchoModePassword
59 }
61 Label {
62 text: menuData.label
63 }
65 TextField {
66 id: textfield
68 anchors.left: parent.left; anchors.right: parent.right
69 echoMode: checkBox.checked ? TextInput.Normal : TextInput.Password
70 height: units.gu(5)
71 onTextChanged: {
72 menuModel.changeState(menuIndex, text);
73 }
74 }
76 Row {
77 id: checkBoxRow
79 spacing: units.gu(.5)
81 CheckBox {
82 id: checkBox
84 checked: false
85 }
87 Label {
88 anchors.verticalCenter: checkBox.verticalCenter
89 text: i18n.tr("Show password")
90 }
91 }
92 }
93 }
95 Component {
96 id: pinLock
97 PinLockscreen {
98 anchors.left: parent.left; anchors.right: parent.right
100 onEntered: {
101 menuModel.changeState(menuIndex, passphrase);
102 entryEnabled = false;
103 }
105 onCancel: {
106 menuModel.activate(menuIndex, false);
107 }
108 }
109 }