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) {
45 if (component === pinLock && shell.hasLockedApp) {
46 // In case we are in emergency mode, just skip this unlock.
47 // Happens with two locked SIMs but the user clicks
48 // Emergency Call on the first unlock dialog.
49 // TODO: if we ever allow showing the indicators in
50 // emergency mode, we'll need to differentiate between
51 // user-initiated ones which we *do* want to show and the
52 // dialogs that appear on boot, which we don't. But for
53 // now we can get away with skipping all such dialogs.
54 menuModel.activate(menuIndex, false);
62 function getExtendedProperty(object, propertyName, defaultValue) {
63 if (object && object.hasOwnProperty(propertyName)) {
64 return object[propertyName];
81 Component.onCompleted: {
82 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
83 checkBox.checked = menuData.ext.xEchoModePassword ? false : true
84 checkBoxRow.visible = menuData.ext.xEchoModePassword
89 color: notification.sdFontColor
95 // TODO using Qt.ImhNoPredictiveText here until lp #1291575 is fixed for ubuntu-ui-toolkit
96 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
101 echoMode: checkBox.checked ? TextInput.Normal : TextInput.Password
103 Component.onCompleted: {
107 menuModel.changeState(menuIndex, text);
110 menuFactory.accepted()
117 spacing: units.gu(.5)
123 activeFocusOnPress: false
127 anchors.verticalCenter: checkBox.verticalCenter
128 text: i18n.tr("Show password")
129 color: notification.sdFontColor
133 onClicked: { checkBox.checked = !checkBox.checked }
148 height: menuFactory.maxHeight
149 infoText: notification.summary
150 errorText: errorAction.valid ? errorAction.state : ""
151 retryText: notification.body
152 background: shell.background
153 darkenBackground: 0.4
156 menuModel.changeState(menuIndex, passphrase);
161 menuModel.activate(menuIndex, false);
165 shell.startLockedApp("dialer-app");
166 menuModel.activate(menuIndex, false);
169 property var extendedData: menuData && menuData.ext || undefined
171 property var pinMinMaxAction : UnityMenuAction {
174 name: getExtendedProperty(extendedData, "xCanonicalPinMinMax", "")
177 var min = pinMinMaxAction.state[0];
178 var max = pinMinMaxAction.state[1];
180 if (min === 0) min = -1;
181 if (max === 0) max = -1;
188 property var popupAction: UnityMenuAction {
191 name: getExtendedProperty(extendedData, "xCanonicalPinPopup", "")
194 showInfoPopup("", state);
197 onInfoPopupConfirmed: {
198 popupAction.activate();
207 errorAction.activate();
210 property var errorAction: UnityMenuAction {
213 name: getExtendedProperty(extendedData, "xCanonicalPinError", "")
218 errorTimer.running = true;
223 function loadAttributes() {
224 if (!menuModel || menuIndex == -1) return;
225 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-min-max': 'string',
226 'x-canonical-pin-popup': 'string',
227 'x-canonical-pin-error': 'string'});
229 Component.onCompleted: {