2 * Copyright 2013-2016 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/>.
18import Lomiri.Components 1.3
25 property QtObject menuModel: null
26 property QtObject menuData: null
27 property int menuIndex : -1
28 property int maxHeight
29 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
30 property url background: ""
35 "com.canonical.snapdecision.textfield": textfield,
36 "com.canonical.snapdecision.pinlock" : pinLock,
40 if (menuData.type !== undefined) {
41 var component = _map[menuData.type];
42 if (component !== undefined) {
43 if (component === pinLock && shell.hasLockedApp) {
44 // In case we are in emergency mode, just skip this unlock.
45 // Happens with two locked SIMs but the user clicks
46 // Emergency Call on the first unlock dialog.
47 // TODO: if we ever allow showing the indicators in
48 // emergency mode, we'll need to differentiate between
49 // user-initiated ones which we *do* want to show and the
50 // dialogs that appear on boot, which we don't. But for
51 // now we can get away with skipping all such dialogs.
52 menuModel.activate(menuIndex, false);
60 function getExtendedProperty(object, propertyName, defaultValue) {
61 if (object && object.hasOwnProperty(propertyName)) {
62 return object[propertyName];
71 spacing: notification.margins
79 Component.onCompleted: {
80 menuModel.loadExtendedAttributes(menuIndex, {"x-echo-mode-password": "bool"});
81 checkBox.checked = menuData.ext.xEchoModePassword ? false : true
82 checkBoxRow.visible = menuData.ext.xEchoModePassword
87 color: theme.palette.normal.backgroundSecondaryText
91 // TODO using Qt.ImhNoPredictiveText here until lp #1291575 is fixed for lomiri-ui-toolkit
92 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
97 echoMode: checkBox.checked ? TextInput.Normal : TextInput.Password
99 Component.onCompleted: {
103 menuModel.changeState(menuIndex, text);
106 menuFactory.accepted()
113 spacing: notification.margins
119 activeFocusOnPress: false
123 anchors.verticalCenter: checkBox.verticalCenter
124 text: i18n.tr("Show password")
125 color: theme.palette.normal.backgroundSecondaryText
129 onClicked: { checkBox.checked = !checkBox.checked }
144 height: menuFactory.maxHeight
145 infoText: notification.summary
146 errorText: errorAction.valid ? errorAction.state : ""
147 retryText: notification.body
148 background: menuFactory.background
149 darkenBackground: 0.4
152 menuModel.changeState(menuIndex, passphrase);
157 menuModel.activate(menuIndex, false);
161 shell.startLockedApp("dialer-app");
162 menuModel.activate(menuIndex, false);
165 property var extendedData: menuData && menuData.ext || undefined
167 property var pinMinMaxAction : AyatanaMenuAction {
170 name: getExtendedProperty(extendedData, "xAyatanaPinMinMax", "")
173 var min = pinMinMaxAction.state[0];
174 var max = pinMinMaxAction.state[1];
176 if (min === 0) min = -1;
177 if (max === 0) max = -1;
184 property var popupAction: AyatanaMenuAction {
187 name: getExtendedProperty(extendedData, "xAyatanaPinPopup", "")
190 showInfoPopup("", state);
193 onInfoPopupConfirmed: {
194 popupAction.activate();
203 errorAction.activate();
206 property var errorAction: AyatanaMenuAction {
209 name: getExtendedProperty(extendedData, "xAyatanaPinError", "")
214 errorTimer.running = true;
219 function loadAttributes() {
220 if (!menuModel || menuIndex == -1) return;
221 menuModel.loadExtendedAttributes(menuIndex, {'x-ayatana-pin-min-max': 'string',
222 'x-ayatana-pin-popup': 'string',
223 'x-ayatana-pin-error': 'string'});
225 Component.onCompleted: {