Ensured messages are always aligned at the top to user names, and users

onine are deleted.
This commit is contained in:
Dimitar Dobrev 2014-03-11 15:46:07 +02:00
parent 60bf473be7
commit ed90e45c96
2 changed files with 6 additions and 3 deletions

View file

@ -153,6 +153,7 @@ void ChatWindow::participantsChanged() {
ui->numOnlineLabel->setText(tr("%1 online now:").arg(participants.count()));
while (QLayoutItem* item = ui->usersWidget->layout()->takeAt(0)) {
delete item->widget();
delete item;
}
foreach (const QString& participant, participants) {
@ -173,13 +174,15 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
font.setBold(true);
userLabel->setFont(font);
userLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
userLabel->setStyleSheet("padding: 4px;");
userLabel->setStyleSheet("padding: 2px;");
userLabel->setAlignment(Qt::AlignTop);
QLabel* messageLabel = new QLabel(message.body().replace(regexLinks, "<a href=\"\\1\">\\1</a>"));
messageLabel->setWordWrap(true);
messageLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
messageLabel->setOpenExternalLinks(true);
messageLabel->setStyleSheet("padding: 4px;");
messageLabel->setStyleSheet("padding: 2px;");
messageLabel->setAlignment(Qt::AlignTop);
ui->messagesFormLayout->addRow(userLabel, messageLabel);
ui->messagesFormLayout->parentWidget()->updateGeometry();

View file

@ -95,7 +95,7 @@
<number>0</number>
</property>
<property name="verticalSpacing">
<number>4</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>