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 1.3
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"
33 property url background: ""
38 "com.canonical.snapdecision.textfield": textfield,
39 "com.canonical.snapdecision.pinlock" : pinLock,
43 if (menuData.type !== undefined) {
44 var component = _map[menuData.type];
45 if (component !== undefined) {
46 if (component === pinLock && shell.hasLockedApp) {
47 // In case we are in emergency mode, just skip this unlock.
48 // Happens with two locked SIMs but the user clicks
49 // Emergency Call on the first unlock dialog.
50 // TODO: if we ever allow showing the indicators in
51 // emergency mode, we'll need to differentiate between
52 // user-initiated ones which we *do* want to show and the
53 // dialogs that appear on boot, which we don't. But for
54 // now we can get away with skipping all such dialogs.
55 menuModel.activate(menuIndex, false);
63 function getExtendedProperty(object, propertyName, defaultValue) {
64 if (object && object.hasOwnProperty(propertyName)) {
65 return object[propertyName];
82 Component.onCompleted: {
83 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
84 checkBox.checked = menuData.ext.xEchoModePassword ? false : true
85 checkBoxRow.visible = menuData.ext.xEchoModePassword
90 color: notification.sdFontColor
96 // TODO using Qt.ImhNoPredictiveText here until lp #1291575 is fixed for ubuntu-ui-toolkit
97 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
102 echoMode: checkBox.checked ? TextInput.Normal : TextInput.Password
104 Component.onCompleted: {
108 menuModel.changeState(menuIndex, text);
111 menuFactory.accepted()
118 spacing: units.gu(.5)
124 activeFocusOnPress: false
128 anchors.verticalCenter: checkBox.verticalCenter
129 text: i18n.tr("Show password")
130 color: notification.sdFontColor
134 onClicked: { checkBox.checked = !checkBox.checked }
149 height: menuFactory.maxHeight
150 infoText: notification.summary
151 errorText: errorAction.valid ? errorAction.state : ""
152 retryText: notification.body
153 background: menuFactory.background
154 darkenBackground: 0.4
157 menuModel.changeState(menuIndex, passphrase);
162 menuModel.activate(menuIndex, false);
166 shell.startLockedApp("dialer-app");
167 menuModel.activate(menuIndex, false);
170 property var extendedData: menuData && menuData.ext || undefined
172 property var pinMinMaxAction : UnityMenuAction {
175 name: getExtendedProperty(extendedData, "xCanonicalPinMinMax", "")
178 var min = pinMinMaxAction.state[0];
179 var max = pinMinMaxAction.state[1];
181 if (min === 0) min = -1;
182 if (max === 0) max = -1;
189 property var popupAction: UnityMenuAction {
192 name: getExtendedProperty(extendedData, "xCanonicalPinPopup", "")
195 showInfoPopup("", state);
198 onInfoPopupConfirmed: {
199 popupAction.activate();
208 errorAction.activate();
211 property var errorAction: UnityMenuAction {
214 name: getExtendedProperty(extendedData, "xCanonicalPinError", "")
219 errorTimer.running = true;
224 function loadAttributes() {
225 if (!menuModel || menuIndex == -1) return;
226 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-min-max': 'string',
227 'x-canonical-pin-popup': 'string',
228 'x-canonical-pin-error': 'string'});
230 Component.onCompleted: {