on 572bc68 help sign in
unity8/Notifications/NotificationMenuItemFactory.qml
97 lines 2.6 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 } else {
45 if (menuData.isSeparator) {
46 return divMenu;
47 }
48 }
49 return standardMenu;
50 }
52 Component {
53 id: textfield
55 Column {
56 spacing: units.gu(.5)
58 anchors.left: parent.left; anchors.right: parent.right
60 Component.onCompleted: {
61 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
62 textfield.echoMode = menuData.ext.xEchoModePassword ? TextInput.Password : TextInput.Normal
63 }
65 Label {
66 fontSize: "medium"
67 color: "white"
68 text: menuData.label
69 }
71 TextField {
72 id: textfield
74 anchors.left: parent.left; anchors.right: parent.right
76 onTextChanged: {
77 menuModel.changeState(menuIndex, text);
78 }
79 }
80 }
81 }
83 Component {
84 id: pinLock
85 PinLockscreen {
86 anchors.left: parent.left; anchors.right: parent.right
88 onEntered: {
89 menuModel.changeState(menuIndex, passphrase);
90 }
92 onCancel: {
93 menuModel.activate(menuIndex, false);
94 }
95 }
96 }