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 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1 as Indicators
24import QMenuModel 0.1 as QMenuModel
26Indicators.BaseMenuItem {
27 id: messageFactoryItem
28 property var menuModel: null
29 property QtObject menuData: null
30 property int menuIndex: -1
32 property var extendedData: menuData && menuData.ext || undefined
33 property var actionsDescription: getExtendedProperty(extendedData, "xCanonicalMessageActions", undefined)
42 function loadAttributes() {
43 if (!menuModel || menuIndex == undefined) return;
45 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64',
46 'x-canonical-text': 'string',
47 'x-canonical-message-actions': 'variant',
49 'x-canonical-app-icon': 'icon'});
52 function getExtendedProperty(object, propertyName, defaultValue) {
53 if (object && object.hasOwnProperty(propertyName)) {
54 return object[propertyName];
59 implicitHeight: contents.status == Loader.Ready ? contents.item.implicitHeight : 0
65 sourceComponent: loadMessage(actionsDescription);
71 title: menuData && menuData.label || ""
72 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
73 message: getExtendedProperty(extendedData, "xCanonicalText", "")
75 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
76 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
79 menuModel.activate(menuIndex, true);
80 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
83 menuModel.activate(menuIndex, false);
86 menuSelected: messageFactoryItem.menuSelected
87 onSelectMenu: messageFactoryItem.selectMenu()
88 onDeselectMenu: messageFactoryItem.deselectMenu()
94 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
96 property var replyAction: QMenuModel.UnityMenuAction {
99 name: getExtendedProperty(replyActionDescription, "name", "")
103 title: menuData && menuData.label || ""
104 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
105 message: getExtendedProperty(extendedData, "xCanonicalText", "")
106 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
108 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
109 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
111 replyEnabled: replyAction.valid && replyAction.enabled
114 menuModel.activate(menuIndex, true);
115 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
118 menuModel.activate(menuIndex, false);
121 replyAction.activate(value);
124 menuSelected: messageFactoryItem.menuSelected
125 onSelectMenu: messageFactoryItem.selectMenu()
126 onDeselectMenu: messageFactoryItem.deselectMenu()
132 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
133 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
135 property var activateAction: QMenuModel.UnityMenuAction {
138 name: getExtendedProperty(activateActionDescription, "name", "")
140 property var replyAction: QMenuModel.UnityMenuAction {
143 name: getExtendedProperty(replyActionDescription, "name", "")
147 title: menuData && menuData.label || ""
148 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
149 message: getExtendedProperty(extendedData, "xCanonicalText", "")
150 actionButtonText: getExtendedProperty(activateActionDescription, "label", "Call back")
151 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
152 replyMessages: getExtendedProperty(replyActionDescription, "parameter-hint", "")
154 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
155 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
157 activateEnabled: activateAction.valid && activateAction.enabled
158 replyEnabled: replyAction.valid && replyAction.enabled
161 menuModel.activate(menuIndex, true);
162 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
165 menuModel.activate(menuIndex, false);
168 activateAction.activate();
171 replyAction.activate(value);
174 menuSelected: messageFactoryItem.menuSelected
175 onSelectMenu: messageFactoryItem.selectMenu()
176 onDeselectMenu: messageFactoryItem.deselectMenu()
181 function loadMessage(actions)
183 var parameterType = ""
184 for (var actIndex in actions) {
185 var desc = actions[actIndex];
186 if (desc["parameter-type"] !== undefined) {
187 parameterType += desc["parameter-type"];
189 parameterType += "_";
193 if (parameterType === "") {
194 return simpleTextMessage;
195 } else if (parameterType === "s") {
197 } else if (parameterType === "_s") {
200 console.debug("Unknown paramater type: " + parameterType);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list