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 var menuIndex: undefined
32 property var extAttrib: menuData && menuData.ext ? menuData.ext : undefined
33 property var actionsDescription: extAttrib && extAttrib.hasOwnProperty("xCanonicalMessageActions") ? extAttrib.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 implicitHeight: contents.status == Loader.Ready ? contents.item.implicitHeight : 0
58 sourceComponent: loadMessage(actionsDescription);
64 title: menuData && menuData.label ? menuData.label : ""
65 time: extAttrib && extAttrib.hasOwnProperty("xCanonicalTime") ? extAttrib.xCanonicalTime : 0
66 message: extAttrib && extAttrib.hasOwnProperty("xCanonicalText") ? extAttrib.xCanonicalText : ""
68 avatar: extAttrib && extAttrib.hasOwnProperty("icon") ? extAttrib.icon : "qrc:/indicators/artwork/messaging/default_contact.png"
69 appIcon: extAttrib && extAttrib.hasOwnProperty("xCanonicalAppIcon") ? extAttrib.xCanonicalAppIcon : "qrc:/indicators/artwork/messaging/default_app.svg"
72 menuModel.activate(menuIndex, true);
73 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
76 menuModel.activate(menuIndex, false);
79 menuSelected: messageFactoryItem.menuSelected
80 onSelectMenu: messageFactoryItem.selectMenu()
81 onDeselectMenu: messageFactoryItem.deselectMenu()
87 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
89 property var replyAction: QMenuModel.UnityMenuAction {
92 name: replyActionDescription !== undefined ? replyActionDescription.name : ""
96 title: menuData && menuData.label ? menuData.label : ""
97 time: extAttrib && extAttrib.hasOwnProperty("xCanonicalTime") ? extAttrib.xCanonicalTime : 0
98 message: extAttrib && extAttrib.hasOwnProperty("xCanonicalText") ? extAttrib.xCanonicalText : ""
99 replyButtonText: replyActionDescription !== undefined && replyActionDescription.hasOwnProperty("label") ? replyActionDescription.label : "Send"
101 avatar: extAttrib && extAttrib.hasOwnProperty("icon") ? extAttrib.icon : "qrc:/indicators/artwork/messaging/default_contact.png"
102 appIcon: extAttrib && extAttrib.hasOwnProperty("xCanonicalAppIcon") ? extAttrib.xCanonicalAppIcon : "qrc:/indicators/artwork/messaging/default_app.svg"
104 replyEnabled: replyAction.valid && replyAction.enabled
107 menuModel.activate(menuIndex, true);
108 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
111 menuModel.activate(menuIndex, false);
114 replyAction.activate(value);
117 menuSelected: messageFactoryItem.menuSelected
118 onSelectMenu: messageFactoryItem.selectMenu()
119 onDeselectMenu: messageFactoryItem.deselectMenu()
125 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
126 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
128 property var activateAction: QMenuModel.UnityMenuAction {
131 name: activateActionDescription !== undefined ? activateActionDescription.name : ""
133 property var replyAction: QMenuModel.UnityMenuAction {
136 name: replyActionDescription !== undefined ? replyActionDescription.name : ""
140 title: menuData && menuData.label ? menuData.label : ""
141 time: extAttrib && extAttrib.hasOwnProperty("xCanonicalTime") ? extAttrib.xCanonicalTime : ""
142 message: extAttrib && extAttrib.hasOwnProperty("xCanonicalText") ? extAttrib.xCanonicalText : ""
143 actionButtonText: activateActionDescription !== undefined && activateActionDescription.hasOwnProperty("label") ? activateActionDescription.label : "Call back"
144 replyButtonText: replyActionDescription !== undefined && replyActionDescription.hasOwnProperty("label") ? replyActionDescription.label : "Send"
145 replyMessages: replyActionDescription !== undefined && replyActionDescription.hasOwnProperty("parameter-hint") ? replyActionDescription["parameter-hint"] : ""
147 avatar: extAttrib && extAttrib.hasOwnProperty("icon") ? extAttrib.icon : "qrc:/indicators/artwork/messaging/default_contact.png"
148 appIcon: extAttrib && extAttrib.hasOwnProperty("xCanonicalAppIcon") ? extAttrib.xCanonicalAppIcon : "qrc:/indicators/artwork/messaging/default_app.svg"
150 activateEnabled: activateAction.valid && activateAction.enabled
151 replyEnabled: replyAction.valid && replyAction.enabled
154 menuModel.activate(menuIndex, true);
155 shell.hideIndicatorMenu(UbuntuAnimation.FastDuration);
158 menuModel.activate(menuIndex, false);
161 activateAction.activate();
164 replyAction.activate(value);
167 menuSelected: messageFactoryItem.menuSelected
168 onSelectMenu: messageFactoryItem.selectMenu()
169 onDeselectMenu: messageFactoryItem.deselectMenu()
174 function loadMessage(actions)
176 var parameterType = ""
177 for (var actIndex in actions) {
178 var desc = actions[actIndex];
179 if (desc["parameter-type"] !== undefined) {
180 parameterType += desc["parameter-type"];
182 parameterType += "_";
186 if (parameterType === "") {
187 return simpleTextMessage;
188 } else if (parameterType === "s") {
190 } else if (parameterType === "_s") {
193 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