Fix chat window scrolling to stay at bottom

Stay at bottom window when:
- There is new chat.
- People come and go from online list.
- Chat window hides and restores when application focus changes.
- Interface is minimized and restored.
This commit is contained in:
David Rowe 2014-05-25 16:42:36 -07:00
parent 97e5c928a4
commit 7c3d3976ee

View file

@ -248,6 +248,7 @@ void ChatWindow::notificationClicked() {
return;
}
}
Application::processEvents();
scrollToBottom();
}
@ -262,6 +263,8 @@ void ChatWindow::error(QXmppClient::Error error) {
}
void ChatWindow::participantsChanged() {
bool atBottom = isNearBottom();
QStringList participants = XmppClient::getInstance().getPublicChatRoom()->participants();
ui->numOnlineLabel->setText(tr("%1 online now:").arg(participants.count()));
@ -288,6 +291,11 @@ void ChatWindow::participantsChanged() {
userLabel->installEventFilter(this);
ui->usersWidget->layout()->addWidget(userLabel);
}
Application::processEvents();
if (atBottom) {
scrollToBottom();
}
}
void ChatWindow::messageReceived(const QXmppMessage& message) {