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());

}
Пример #2
0
void ChatMessagePanel::initialize(const QString &userName, const QString &msg,
                                  const QColor &msgBackgroundColor, const QColor &textColor,
                                  bool showTranslationButton, bool showBlockButton)
{
    if (!userName.isEmpty() && !userName.isNull()) {
        ui->labelUserName->setText(userName + ":");
    } else {
        ui->labelUserName->setVisible(false);
    }

    setStyleSheet(buildCssString(msgBackgroundColor, textColor));

    setMessageLabelText(msg);

    ui->labelTimeStamp->setText(QTime::currentTime().toString("hh:mm:ss"));

    ui->translateButton->setVisible(showTranslationButton);

    ui->blockButton->setVisible(showBlockButton);

    this->originalText = msg;
}