From 97d8640f3a380851915a3a558c6593ef20f393b5 Mon Sep 17 00:00:00 2001 From: joss17 Date: Fri, 27 Nov 2009 22:05:38 +0000 Subject: [PATCH] tweak the peer chat and group chat vertical scroll git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1848 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/PeersDialog.cpp | 10 +++++++++- retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 817af8c6a..37204b90f 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -842,7 +842,15 @@ void PeersDialog::insertChat() extraTxt.replace(code, ""); } - msgWidget->append(extraTxt); + if ((msgWidget->verticalScrollBar()->maximum() - 30) < msgWidget->verticalScrollBar()->value() ) { + msgWidget->append(extraTxt); + } else { + //the vertical scroll is not at the bottom, so just update the text, the scroll will stay at the current position + int scroll = msgWidget->verticalScrollBar()->value(); + msgWidget->setHtml(msgWidget->toHtml() + extraTxt); + msgWidget->verticalScrollBar()->setValue(scroll); + msgWidget->update(); + } } } diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 5a3a6bc77..cc1916de5 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -289,7 +289,15 @@ std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << .replace("%name%", name) .replace("%message%", message); - ui.textBrowser->append(formatMsg + "\n"); + if ((ui.textBrowser->verticalScrollBar()->maximum() - 30) < ui.textBrowser->verticalScrollBar()->value() ) { + ui.textBrowser->append(formatMsg + "\n"); + } else { + //the vertical scroll is not at the bottom, so just update the text, the scroll will stay at the current position + int scroll = ui.textBrowser->verticalScrollBar()->value(); + ui.textBrowser->setHtml(ui.textBrowser->toHtml() + formatMsg + "\n"); + ui.textBrowser->verticalScrollBar()->setValue(scroll); + ui.textBrowser->update(); + } resetStatusBar() ; }