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);
80 Menus.SimpleTextMessageMenu {
82 objectName: "simpleTextMessage"
84 title: menuData && menuData.label || ""
85 time: timeFormatter.timeString
86 message: getExtendedProperty(extendedData, "xCanonicalText", "")
88 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
89 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
91 enabled: menuData && menuData.sensitive || false
93 selected: messageFactoryItem.selected
96 menuModel.activate(menuIndex, true);
97 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
100 menuModel.activate(menuIndex, false);
110 backgroundIndicator: RemoveBackground {
111 state: message.swipingState
118 Menus.TextMessageMenu {
120 objectName: "textMessage"
121 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
123 property var replyAction: QMenuModel.UnityMenuAction {
126 name: getExtendedProperty(replyActionDescription, "name", "")
130 title: menuData && menuData.label || ""
131 time: timeFormatter.timeString
132 message: getExtendedProperty(extendedData, "xCanonicalText", "")
133 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
135 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
136 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
138 replyEnabled: replyAction.valid && replyAction.enabled
139 enabled: menuData && menuData.sensitive || false
141 selected: messageFactoryItem.selected
144 menuModel.activate(menuIndex, true);
145 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
148 menuModel.activate(menuIndex, false);
151 replyAction.activate(value);
161 backgroundIndicator: RemoveBackground {
162 state: message.swipingState
168 Menus.SnapDecisionMenu {
170 objectName: "snapDecision"
171 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
172 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
174 property var activateAction: QMenuModel.UnityMenuAction {
177 name: getExtendedProperty(activateActionDescription, "name", "")
179 property var replyAction: QMenuModel.UnityMenuAction {
182 name: getExtendedProperty(replyActionDescription, "name", "")
186 title: menuData && menuData.label || ""
187 time: timeFormatter.timeString
188 message: getExtendedProperty(extendedData, "xCanonicalText", "")
189 actionButtonText: getExtendedProperty(activateActionDescription, "label", "Call back")
190 replyButtonText: getExtendedProperty(replyActionDescription, "label", "Send")
191 replyMessages: getExtendedProperty(replyActionDescription, "parameter-hint", "")
193 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
194 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
196 activateEnabled: activateAction.valid && activateAction.enabled
197 replyEnabled: replyAction.valid && replyAction.enabled
198 enabled: menuData && menuData.sensitive || false
200 selected: messageFactoryItem.selected
203 menuModel.activate(menuIndex, true);
204 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
207 menuModel.activate(menuIndex, false);
210 activateAction.activate();
213 replyAction.activate(value);
223 backgroundIndicator: RemoveBackground {
224 state: message.swipingState
230 function loadMessage(actions)
232 var parameterType = ""
233 for (var actIndex in actions) {
234 var desc = actions[actIndex];
235 if (desc["parameter-type"] !== undefined) {
236 parameterType += desc["parameter-type"];
238 parameterType += "_";
242 if (parameterType === "") {
243 return simpleTextMessage;
244 } else if (parameterType === "s") {
246 } else if (parameterType === "_s") {
249 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