From 59692a9aa902d24263a4cae2e1958c07895ae922 Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 4 Aug 2009 14:38:31 +0000 Subject: [PATCH] improve vertical scrollbar popupchatdialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1490 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index dae59e563..99815c46d 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -228,6 +228,11 @@ void PopupChatDialog::updateChat() void PopupChatDialog::addChatMsg(ChatInfo *ci) { + //store the state of the vertical scrollbar to set it at the end of the function + QScrollBar *qsb = ui.textBrowser->verticalScrollBar(); + int oldQsbValue = qsb->value(); + bool maxQsbValue = (qsb->maximum() == qsb->value()); + bool offline = true; { @@ -300,9 +305,12 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n"); - QTextCursor cursor = ui.textBrowser->textCursor(); - cursor.movePosition(QTextCursor::End); - ui.textBrowser->setTextCursor(cursor); + + if (maxQsbValue ) { + qsb -> setValue(qsb->maximum()); + } else { + qsb -> setValue(oldQsbValue); + } if(ci->chatflags & RS_CHAT_AVATAR_AVAILABLE) {