Ejemplo n.º 1
0
EmoticonLabel::EmoticonLabel(Emoticon emoticon, QWidget *parent)
  : QLabel(parent)
  , m_ready(false)
{
  QMovie *movie = new QMovie(emoticon->file(), QByteArray(), this);
  setMovie(movie);
  setAlignment(Qt::AlignCenter);

  m_text = emoticon->texts().first();
  setToolTip(LS("<span>") + m_text + LS("</span>"));

  movie->start();

  updateStyleSheet();
}
Ejemplo n.º 2
0
void EmoticonsFilter::make(QList<HtmlToken> &tokens, const QString &text) const
{
  Emoticon emoticon = m_emoticons->get(text);
  if (!emoticon) {
    tokens.append(HtmlToken(text));
    return;
  }

  m_count++;
  HtmlToken a(HtmlToken::Tag, HtmlATag(LS("emoticon:") + ChatId::toBase32(text.toUtf8()), text).toText());
  tokens.append(a);

  QString img = QString(LS("<img class=\"emoticon\" title=\"%1\" alt=\"%1\" src=\"%2\" width=\"%3\" height=\"%4\" />"))
      .arg(text)
      .arg(QUrl::fromLocalFile(emoticon->file()).toString())
      .arg(emoticon->width())
      .arg(emoticon->height());

  HtmlToken tag(img);
  tag.parent = LS("a");
  tokens.append(tag);
  tokens.append(a.toEndTag());
}