ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString& rawMessage, SystemMessageType type, const QDateTime& date) { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); QString text = rawMessage.toHtmlEscaped(); QString img; switch (type) { case INFO: img = ":/ui/chatArea/info.svg"; break; case ERROR: img = ":/ui/chatArea/error.svg"; break; case TYPING: img = ":/ui/chatArea/typing.svg"; break; } QFont baseFont = Settings::getInstance().getChatMessageFont(); msg->addColumn(new Image(QSize(18, 18), img), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new Text("<b>" + text + "</b>", baseFont, false, ""), ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Left)); msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); return msg; }
ChatMessage::Ptr ChatMessage::createFileTransferMessage(const QString& sender, ToxFile file, bool isMe, const QDateTime& date) { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); msg->addColumn(new Text(sender, isMe ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file), 320, 0.6f), ColumnFormat(1.0, ColumnFormat::VariableSize)); msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), Style::getFont(Style::Big)), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); return msg; }
ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QString &rawMessage, MessageType type, bool isMe, const QDateTime &date) { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); QString text = rawMessage.toHtmlEscaped(); QString senderText = sender; const QColor actionColor = QColor("#1818FF"); // has to match the color in innerStyle.css (div.action) //smileys if (Settings::getInstance().getUseEmoticons()) text = SmileyPack::getInstance().smileyfied(text); //quotes (green text) text = detectQuotes(detectAnchors(text), type); //text styling if (Settings::getInstance().getStylePreference() != Settings::StyleType::NONE) text = detectStyle(text); switch(type) { case NORMAL: text = wrapDiv(text, "msg"); break; case ACTION: senderText = "*"; text = wrapDiv(QString("%1 %2").arg(sender.toHtmlEscaped(), text), "action"); msg->setAsAction(); break; case ALERT: text = wrapDiv(text, "alert"); break; } // Note: Eliding cannot be enabled for RichText items. (QTBUG-17207) QFont baseFont = Settings::getInstance().getChatMessageFont(); QFont authorFont = baseFont; if (isMe) authorFont.setBold(true); msg->addColumn(new Text(senderText, authorFont, true, sender, type == ACTION ? actionColor : Qt::black), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new Text(text, baseFont, false, ((type == ACTION) && isMe) ? QString("%1 %2").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize)); msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); if (!date.isNull()) msg->markAsSent(date); return msg; }
ChatMessage::Ptr ChatMessage::createTypingNotification() { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); // Note: "[user]..." is just a placeholder. The actual text is set in ChatForm::setFriendTyping() // // FIXME: Due to circumstances, placeholder is being used in a case where // user received typing notifications constantly since contact came online. // This causes "[user]..." to be displayed in place of user nick, as long // as user will keep typing. Issue #1280 msg->addColumn(new NotificationIcon(QSize(18, 18)), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new Text("[user]...", Style::getFont(Style::Big), false, ""), ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Left)); return msg; }
ChatMessage::Ptr ChatMessage::createFileTransferMessage(const QString& sender, ToxFile file, bool isMe, const QDateTime& date) { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); QFont baseFont = Settings::getInstance().getChatMessageFont(); QFont authorFont = baseFont; if (isMe) authorFont.setBold(true); msg->addColumn(new Text(sender, authorFont, true), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file), 320, 0.6f), ColumnFormat(1.0, ColumnFormat::VariableSize)); msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); return msg; }
ChatMessage::Ptr ChatMessage::createBusyNotification() { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); // TODO: Bigger font msg->addColumn(new Text(QObject::tr("Resizing"), Style::getFont(Style::ExtraBig), false, ""), ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Center)); return msg; }
ChatMessage::Ptr ChatMessage::createBusyNotification() { ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage); QFont baseFont = Settings::getInstance().getChatMessageFont(); baseFont.setPixelSize(baseFont.pixelSize() + 2); baseFont.setBold(true); msg->addColumn(new Text(QObject::tr("Resizing"), baseFont, false, ""), ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Center)); return msg; }