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 Ubuntu.Settings.Menus 0.1 as Menus
24import QMenuModel 0.1 as QMenuModel
25import Utils 0.1 as Utils
28 id: messageFactoryItem
29 property var menuModel: null
30 property QtObject menuData: null
31 property int menuIndex: -1
33 property bool selected: false
37 property var extendedData: menuData && menuData.ext || undefined
38 property var actionsDescription: getExtendedProperty(extendedData, "xCanonicalMessageActions", undefined)
40 // TODO - bug #1260728
41 property var timeFormatter: Utils.TimeFormatter {
42 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
43 format: "hh:mm - MMM dd"
53 function loadAttributes() {
54 if (!menuModel || menuIndex == -1) return;
55 menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-time': 'int64',
56 'x-canonical-text': 'string',
57 'x-canonical-message-actions': 'variant',
59 'x-canonical-app-icon': 'icon'});
62 function getExtendedProperty(object, propertyName, defaultValue) {
63 if (object && object.hasOwnProperty(propertyName)) {
64 return object[propertyName];
69 implicitHeight: contents.status == Loader.Ready ? contents.item.implicitHeight : 0
76 sourceComponent: loadMessage(actionsDescription);
81 Menus.SimpleTextMessageMenu {
83 objectName: "simpleTextMessage"
85 title: menuData && menuData.label || ""
86 time: timeFormatter.timeString
87 message: getExtendedProperty(extendedData, "xCanonicalText", "")
89 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
90 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
92 enabled: menuData && menuData.sensitive || false
94 selected: messageFactoryItem.selected
97 menuModel.activate(menuIndex, true);
98 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
101 menuModel.activate(menuIndex, false);
111 backgroundIndicator: RemoveBackground {
112 state: message.swipingState
120 Menus.TextMessageMenu {
122 objectName: "textMessage"
123 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
125 property var replyAction: QMenuModel.UnityMenuAction {
128 name: getExtendedProperty(replyActionDescription, "name", "")
132 title: menuData && menuData.label || ""
133 time: timeFormatter.timeString
134 message: getExtendedProperty(extendedData, "xCanonicalText", "")
135 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
137 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
138 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
140 replyEnabled: replyAction.valid && replyAction.enabled
141 enabled: menuData && menuData.sensitive || false
143 selected: messageFactoryItem.selected
146 menuModel.activate(menuIndex, true);
147 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
150 menuModel.activate(menuIndex, false);
153 replyAction.activate(value);
163 backgroundIndicator: RemoveBackground {
164 state: message.swipingState
171 Menus.SnapDecisionMenu {
173 objectName: "snapDecision"
174 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
175 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
177 property var activateAction: QMenuModel.UnityMenuAction {
180 name: getExtendedProperty(activateActionDescription, "name", "")
182 property var replyAction: QMenuModel.UnityMenuAction {
185 name: getExtendedProperty(replyActionDescription, "name", "")
189 title: menuData && menuData.label || ""
190 time: timeFormatter.timeString
191 message: getExtendedProperty(extendedData, "xCanonicalText", "")
192 actionButtonText: getExtendedProperty(activateActionDescription, "label", "Call back")
193 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
194 replyMessages: getExtendedProperty(replyActionDescription, "parameter-hint", "")
196 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
197 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
199 activateEnabled: activateAction.valid && activateAction.enabled
200 replyEnabled: replyAction.valid && replyAction.enabled
201 enabled: menuData && menuData.sensitive || false
203 selected: messageFactoryItem.selected
206 menuModel.activate(menuIndex, true);
207 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
210 menuModel.activate(menuIndex, false);
213 activateAction.activate();
216 replyAction.activate(value);
226 backgroundIndicator: RemoveBackground {
227 state: message.swipingState
233 function loadMessage(actions)
235 var parameterType = ""
236 for (var actIndex in actions) {
237 var desc = actions[actIndex];
238 if (desc["parameter-type"] !== undefined) {
239 parameterType += desc["parameter-type"];
241 parameterType += "_";
245 if (parameterType === "") {
246 return simpleTextMessage;
247 } else if (parameterType === "s") {
249 } else if (parameterType === "_s") {
252 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