changeset 13623:f03f4ac63569

Now scrolling down on new messages.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Thu, 18 Aug 2011 13:53:32 +0200
parents e744593197ef
children e0a8e35e750e
files gui/src/IRCWidget.cpp gui/src/IRCWidget.h gui/src/terminal/QTerminalWidget.cpp gui/src/terminal/QTerminalWidget.h
diffstat 4 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/IRCWidget.cpp	Thu Aug 18 13:36:20 2011 +0200
+++ b/gui/src/IRCWidget.cpp	Thu Aug 18 13:53:32 2011 +0200
@@ -301,6 +301,7 @@
         arg (htmlMessage);
     }
   m_chatWindow->append (output);
+  scrollToBottom ();
 }
 
 void
@@ -308,6 +309,7 @@
 {
   Q_UNUSED (sender);
   m_chatWindow->append (QString ("<font color=\"#007700\">%1</font>").arg (message));
+  scrollToBottom ();
 }
 
 void
@@ -370,7 +372,7 @@
                             arg (m_ircClientInterface->nickname ()).arg (message));
     }
 
-  m_chatWindow->verticalScrollBar ()->setValue (m_chatWindow->verticalScrollBar ()->maximum ());
+  scrollToBottom ();
 }
 
 void
@@ -384,6 +386,15 @@
 }
 
 void
+IRCWidget::scrollToBottom ()
+{
+  if (m_chatWindow->verticalScrollBar ())
+    {
+      m_chatWindow->verticalScrollBar ()->setValue (m_chatWindow->verticalScrollBar ()->maximum ());
+    }
+}
+
+void
 IRCWidget::focusInEvent (QFocusEvent *focusEvent)
 {
   Q_UNUSED (focusEvent);
@@ -410,18 +421,21 @@
 IRCWidget::handleNickChange (const QString &oldNick, const QString &newNick)
 {
   m_chatWindow->append (QString ("%1 is now known as %2.").arg (oldNick).arg (newNick));
+  scrollToBottom ();
 }
 
 void
 IRCWidget::handleUserJoined (const QString &nick, const QString &channel)
 {
   m_chatWindow->append (QString ("<i>%1 has joined %2.</i>").arg (nick).arg (channel));
+  scrollToBottom ();
 }
 
 void
 IRCWidget::handleUserQuit (const QString &nick, const QString &reason)
 {
   m_chatWindow->append (QString ("<i>%1 has quit.(%2).</i>").arg (nick).arg (reason));
+  scrollToBottom ();
 }
 
 void
--- a/gui/src/IRCWidget.h	Thu Aug 18 13:36:20 2011 +0200
+++ b/gui/src/IRCWidget.h	Thu Aug 18 13:53:32 2011 +0200
@@ -78,6 +78,7 @@
   void sendMessage (QString);
 
   void maybeIdentifyOnNickServ ();
+  void scrollToBottom ();
 
 signals:
   void unreadMessages (bool yes);
--- a/gui/src/terminal/QTerminalWidget.cpp	Thu Aug 18 13:36:20 2011 +0200
+++ b/gui/src/terminal/QTerminalWidget.cpp	Thu Aug 18 13:53:32 2011 +0200
@@ -81,9 +81,6 @@
   setFocus (Qt::OtherFocusReason);
   m_impl->m_terminalDisplay->resize (this->size ());
   setFocusProxy (m_impl->m_terminalDisplay);
-
-  connect (m_impl->m_terminalDisplay, SIGNAL (keyPressedSignal (QKeyEvent*)),
-           this, SLOT (terminalKeyPressed (QKeyEvent*)));
 }
 
 void
@@ -112,9 +109,6 @@
 void
 QTerminalWidget::openTeletype (int fd)
 {
-  //if (m_impl->m_session->isRunning ())
-  //  return;
-
   m_impl->m_session->openTeletype (fd);
 }
 
@@ -161,10 +155,3 @@
 {
   emit finished ();
 }
-
-void
-QTerminalWidget::terminalKeyPressed (QKeyEvent *keyEvent)
-{
-  Q_UNUSED (keyEvent);
-  emit scrollToBottomRequest ();
-}
--- a/gui/src/terminal/QTerminalWidget.h	Thu Aug 18 13:36:20 2011 +0200
+++ b/gui/src/terminal/QTerminalWidget.h	Thu Aug 18 13:53:32 2011 +0200
@@ -51,14 +51,11 @@
   /** Emitted, when the current program has finished. */
   void finished ();
 
-  void scrollToBottomRequest ();
-
 protected:
   virtual void resizeEvent (QResizeEvent *);
 
 protected slots:
   void sessionFinished ();
-  void terminalKeyPressed (QKeyEvent *keyEvent);
 
 private:
   /** Performs initial operations on this widget. */