on 5b03213 help sign in
unity8/Notifications/NotificationMenuItemFactory.qml
96 lines 2.7 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 textfield.echoMode = menuData.ext.xEchoModePassword ? TextInput.Password : TextInput.Normal
58 }
60 Label {
61 text: menuData.label
62 }
64 TextField {
65 id: textfield
67 anchors.left: parent.left; anchors.right: parent.right
68 height: units.gu(5)
69 onTextChanged: {
70 menuModel.changeState(menuIndex, text);
71 }
72 }
73 }
74 }
76 Component {
77 id: pinLock
78 PinLockscreen {
79 anchors.left: parent.left; anchors.right: parent.right
81 Component.onCompleted: {
82 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-length': 'int'});
83 pinLength = menuData.ext.xCanonicalPinLength;
84 }
86 onEntered: {
87 menuModel.changeState(menuIndex, passphrase);
88 entryEnabled = false;
89 }
91 onCancel: {
92 menuModel.activate(menuIndex, false);
93 }
94 }
95 }