void HandleTemplateAdded(ActivityFeedItemTemplate template) { QApplication.Invoke(delegate { string category = (template.Category == null) ? null : template.Category.ToLower().Replace(" ", "-"); string js = Util.CreateJavascriptCall("ActivityFeed.addTemplate", template.Name, category, template.SingularText, template.PluralText, template.IconUrl, template.Actions); var ret = m_ActivityWebView.Page().MainFrame().EvaluateJavaScript(js); if (ret.IsNull() || !ret.ToBool()) { throw new Exception("Failed to add template!\n" + js); } }); }
public override void DesktopNotify(ActivityFeedItemTemplate template, IActivityFeedItem item, string text) { // FIXME: This will need to be different on windows/osx... QApplication.Invoke(delegate { Notification notif = new Notification(text, item.Content); foreach (var action in template.Actions) { notif.AddAction(action.Name, action.Label, delegate { item.TriggerAction(action.Name); }); } notif.Show(); }); }
public NotificationItemWidget(IActivityFeedItem item, QWidget parent) : base(parent) { m_Item = item; item.ActionTriggered += HandleActionTriggered; QHBoxLayout layout = new QHBoxLayout(this); layout.Margin = 3; var service = ServiceManager.Get <ActivityFeedService>(); ActivityFeedItemTemplate template = service.Templates[item.Type]; var builder = new StringBuilder(); builder.AppendFormat("<span style=\"font-size: 9pt;\">"); builder.AppendFormat("<b>{0}</b>", item.FromName); builder.Append(" "); builder.AppendFormat(template.SingularText, "<b>{0}</b>".FormatWith(item.ActionItem)); if (!String.IsNullOrEmpty(item.Content)) { builder.Append(":"); builder.Append("<p style=\"margin-left: 20px; margin-top: 0px; margin-bottom: 0px;\">"); builder.Append(item.Content); builder.Append("</p>"); } else { builder.Append("."); } if (template.Actions != null && template.Actions.Length > 0) { builder.Append("<br/>"); foreach (var action in template.Actions) { builder.AppendFormat("<a style=\"color: white\" href=\"{0}\">{1}</a> ", action.Name, action.Label); } } builder.Append("</span>"); QLabel label = new QLabel(builder.ToString(), this); QObject.Connect(label, Qt.SIGNAL("linkActivated(const QString &)"), delegate(string link) { m_Item.TriggerAction(link); }); label.MinimumWidth = 1; label.WordWrap = true; layout.AddWidget(label, 1); if (item is XmppActivityFeedItem) { label.ToolTip = String.Format("From: {0}", ((XmppActivityFeedItem)item).FromJid); } QPushButton closeButton = new QPushButton(this); QObject.Connect(closeButton, Qt.SIGNAL("clicked()"), delegate { Close(); }); closeButton.icon = Gui.LoadIcon("window-close", 16); layout.AddWidget(closeButton, 0); }
public abstract void DesktopNotify(ActivityFeedItemTemplate template, IActivityFeedItem item, string text);