From 97e5c928a4ac97adcab3f937cf8f54f40034ddb3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 25 May 2014 16:41:01 -0700 Subject: [PATCH 1/2] Fix chat scroll bar widget jumping Hovering over the chat window's scroll bar was causing it to jump around. Replaced the 12px style spacing that was causing the problem with a widget-based solution. --- interface/src/ui/ChatWindow.cpp | 4 ++-- interface/ui/chatWindow.ui | 40 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 611f955031..1cf45ab81b 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -80,7 +80,7 @@ ChatWindow::ChatWindow(QWidget* parent) : } else { ui->numOnlineLabel->hide(); ui->closeButton->hide(); - ui->usersWidget->hide(); + ui->usersArea->hide(); ui->messagesScrollArea->hide(); ui->messagePlainTextEdit->hide(); connect(&XmppClient::getInstance(), SIGNAL(joinedPublicChatRoom()), this, SLOT(connected())); @@ -208,7 +208,7 @@ void ChatWindow::connected() { ui->connectingToXMPPLabel->hide(); ui->numOnlineLabel->show(); ui->closeButton->show(); - ui->usersWidget->show(); + ui->usersArea->show(); ui->messagesScrollArea->show(); ui->messagePlainTextEdit->show(); ui->messagePlainTextEdit->setFocus(); diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index 4d223b2665..46ccafd5f8 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -128,19 +128,43 @@ QPushButton:pressed { - - - #usersWidget { - margin-right: 20px; -} + + + + 0 + 0 + + + + 0 + 0 + + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 12 + + + + + - - margin-top: 12px; - Qt::ScrollBarAlwaysOff From 7c3d3976eeac578db0c2ddf3522617840ad2324d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 25 May 2014 16:42:36 -0700 Subject: [PATCH 2/2] 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. --- interface/src/ui/ChatWindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 1cf45ab81b..2f044739df 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -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) {