2 * Copyright 2013 Canonical Ltd.
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.
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.
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/>.
17 * Nick Dedekind <nick.dedekind@canonical.com>
21 import Ubuntu.Components 0.1
23 import "../Components"
28 property QtObject menuModel: null
29 property QtObject menuData: null
30 property int menuIndex : -1
31 property int maxHeight
32 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
37 "com.canonical.snapdecision.textfield": textfield,
38 "com.canonical.snapdecision.pinlock" : pinLock,
42 if (menuData.type !== undefined) {
43 var component = _map[menuData.type];
44 if (component !== undefined) {
50 function getExtendedProperty(object, propertyName, defaultValue) {
51 if (object && object.hasOwnProperty(propertyName)) {
52 return object[propertyName];
69 Component.onCompleted: {
70 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
71 checkBox.checked = menuData.ext.xEchoModePassword ? false : true
72 checkBoxRow.visible = menuData.ext.xEchoModePassword
77 color: notification.sdFontColor
83 // TODO using Qt.ImhNoPredictiveText here until lp #1291575 is fixed for ubuntu-ui-toolkit
84 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
89 echoMode: checkBox.checked ? TextInput.Normal : TextInput.Password
91 Component.onCompleted: {
95 menuModel.changeState(menuIndex, text);
98 menuFactory.accepted()
105 spacing: units.gu(.5)
111 activeFocusOnPress: false
115 anchors.verticalCenter: checkBox.verticalCenter
116 text: i18n.tr("Show password")
117 color: notification.sdFontColor
131 height: menuFactory.maxHeight
132 infoText: notification.summary
133 errorText: errorAction.valid ? errorAction.state : ""
134 retryText: notification.body
135 background: shell.background
138 menuModel.changeState(menuIndex, passphrase);
143 menuModel.activate(menuIndex, false);
147 shell.activateApplication("dialer-app")
148 menuModel.activate(menuIndex, false)
151 property var extendedData: menuData && menuData.ext || undefined
153 property var pinMinMaxAction : UnityMenuAction {
156 name: getExtendedProperty(extendedData, "xCanonicalPinMinMax", "")
159 var min = pinMinMaxAction.state[0];
160 var max = pinMinMaxAction.state[1];
162 if (min === 0) min = -1;
163 if (max === 0) max = -1;
170 property var popupAction: UnityMenuAction {
173 name: getExtendedProperty(extendedData, "xCanonicalPinPopup", "")
176 showInfoPopup("", state);
179 onInfoPopupConfirmed: {
180 popupAction.activate();
189 errorAction.activate();
192 property var errorAction: UnityMenuAction {
195 name: getExtendedProperty(extendedData, "xCanonicalPinError", "")
200 errorTimer.running = true;
205 function loadAttributes() {
206 if (!menuModel || menuIndex == -1) return;
207 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-min-max': 'string',
208 'x-canonical-pin-popup': 'string',
209 'x-canonical-pin-error': 'string'});
211 Component.onCompleted: {