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
66 sourceComponent: loadMessage(actionsDescription);
71 objectName: "simpleTextMessage"
73 title: menuData && menuData.label || ""
74 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
75 message: getExtendedProperty(extendedData, "xCanonicalText", "")
77 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
78 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
80 enabled: menuData && menuData.sensitive || false
83 menuModel.activate(menuIndex, true);
84 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
87 menuModel.activate(menuIndex, false);
90 menuSelected: messageFactoryItem.menuSelected
91 onSelectMenu: messageFactoryItem.selectMenu()
92 onDeselectMenu: messageFactoryItem.deselectMenu()
98 objectName: "textMessage"
99 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
101 property var replyAction: QMenuModel.UnityMenuAction {
104 name: getExtendedProperty(replyActionDescription, "name", "")
108 title: menuData && menuData.label || ""
109 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
110 message: getExtendedProperty(extendedData, "xCanonicalText", "")
111 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
113 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
114 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
116 replyEnabled: replyAction.valid && replyAction.enabled
117 enabled: menuData && menuData.sensitive || false
120 menuModel.activate(menuIndex, true);
121 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
124 menuModel.activate(menuIndex, false);
127 replyAction.activate(value);
130 menuSelected: messageFactoryItem.menuSelected
131 onSelectMenu: messageFactoryItem.selectMenu()
132 onDeselectMenu: messageFactoryItem.deselectMenu()
138 objectName: "snapDecision"
139 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
140 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
142 property var activateAction: QMenuModel.UnityMenuAction {
145 name: getExtendedProperty(activateActionDescription, "name", "")
147 property var replyAction: QMenuModel.UnityMenuAction {
150 name: getExtendedProperty(replyActionDescription, "name", "")
154 title: menuData && menuData.label || ""
155 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
156 message: getExtendedProperty(extendedData, "xCanonicalText", "")
157 actionButtonText: getExtendedProperty(activateActionDescription, "label", "Call back")
158 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
159 replyMessages: getExtendedProperty(replyActionDescription, "parameter-hint", "")
161 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
162 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
164 activateEnabled: activateAction.valid && activateAction.enabled
165 replyEnabled: replyAction.valid && replyAction.enabled
166 enabled: menuData && menuData.sensitive || false
169 menuModel.activate(menuIndex, true);
170 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
173 menuModel.activate(menuIndex, false);
176 activateAction.activate();
179 replyAction.activate(value);
182 menuSelected: messageFactoryItem.menuSelected
183 onSelectMenu: messageFactoryItem.selectMenu()
184 onDeselectMenu: messageFactoryItem.deselectMenu()
189 function loadMessage(actions)
191 var parameterType = ""
192 for (var actIndex in actions) {
193 var desc = actions[actIndex];
194 if (desc["parameter-type"] !== undefined) {
195 parameterType += desc["parameter-type"];
197 parameterType += "_";
201 if (parameterType === "") {
202 return simpleTextMessage;
203 } else if (parameterType === "s") {
205 } else if (parameterType === "_s") {
208 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