예제 #1
0
void ChatMessagePanel::setMessageLabelText(const QString &msg)
{
    QString newMessage(msg);
    newMessage = newMessage.replace(QRegExp("<.+?>"), "");// scape html tags
    newMessage = newMessage.replace("\n", "<br/>");
    newMessage = replaceLinksInString(newMessage);

    ui->labelMessage->setText(newMessage);
}
void ChatMessagePanel::initialize(QString userName, QString msg, QColor userNameBackgroundColor, QColor msgBackgroundColor, QColor textColor, bool drawBorder ){
    if(!userName.isEmpty() && !userName.isNull()){
        ui->labelUserName->setText(userName);
        ui->labelUserName->setStyleSheet(buildCssString(userNameBackgroundColor, textColor, drawBorder));
    }
    else{
        ui->labelUserName->setVisible(false);
    }

    msg = msg.replace(QRegExp("<.+?>"), "");//scape html tags
    msg = msg.replace("\n", "<br/>");
    msg = replaceLinksInString(msg);
    ui->labelMessage->setText(msg);
    ui->labelMessage->setStyleSheet(buildCssString(msgBackgroundColor, textColor, drawBorder));

    ui->translateButton->setStyleSheet( buildCssString(userNameBackgroundColor, textColor, drawBorder));

    this->originalText = msg;

    //ui->widget->setFixedHeight(sizeHint().height());

}