changeset 13611:7f6f339761f9

Chat Window changes logo on new messages.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Wed, 17 Aug 2011 02:49:24 +0200
parents 506e24d12b63
children 7d893674a427
files gui/media/icons_license gui/media/jabber_protocol.png gui/src/IRCWidget.cpp gui/src/IRCWidget.h gui/src/MainWindow.cpp gui/src/MainWindow.h
diffstat 6 files changed, 44 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gui/media/icons_license	Wed Aug 17 02:05:57 2011 +0200
+++ b/gui/media/icons_license	Wed Aug 17 02:49:24 2011 +0200
@@ -2,6 +2,7 @@
 chat.png
 help_index.png
 terminal.png
+jabber_protocol.png
 
 by http://www.everaldo.com/ on 17.07.2011:
 
Binary file gui/media/jabber_protocol.png has changed
--- a/gui/src/IRCWidget.cpp	Wed Aug 17 02:05:57 2011 +0200
+++ b/gui/src/IRCWidget.cpp	Wed Aug 17 02:49:24 2011 +0200
@@ -168,8 +168,7 @@
   m_nickButton->setEnabled (false);
   m_chatMessageTextEdit->setEnabled (false);
 
-  //m_chatWindow->setFocusProxy (m_inputLine);
-  this->setFocusProxy (m_chatMessageTextEdit);
+  //setFocusProxy (m_chatMessageTextEdit);
   m_nickButton->setFocusProxy (m_chatMessageTextEdit);
 
   QFont font;
@@ -257,6 +256,14 @@
 IRCWidget::showMessage (const QString& channel, const QString& sender, const QString& message)
 {
   Q_UNUSED (channel);
+  if (!hasFocus()
+      && !m_chatMessageTextEdit->hasFocus ()
+      && !m_nickButton->hasFocus ()
+      && !m_chatWindow->hasFocus ())
+    {
+      emit unreadMessages (true);
+    }
+
   QString output;
   if (message.contains (m_ircClientInterface->nickname ()))
     {
@@ -343,6 +350,16 @@
 }
 
 void
+IRCWidget::focusInEvent (QFocusEvent *focusEvent)
+{
+  Q_UNUSED (focusEvent);
+  emit unreadMessages (false);
+  QWidget::focusInEvent (focusEvent);
+
+  m_chatMessageTextEdit->setFocus ();
+}
+
+void
 IRCWidget::handleLoggedIn (const QString &nick)
 {
   m_chatWindow->
--- a/gui/src/IRCWidget.h	Wed Aug 17 02:05:57 2011 +0200
+++ b/gui/src/IRCWidget.h	Wed Aug 17 02:49:24 2011 +0200
@@ -77,6 +77,12 @@
   void showChangeUserNickPopup ();
   void sendMessage (QString);
 
+signals:
+  void unreadMessages (bool yes);
+
+protected:
+  void focusInEvent (QFocusEvent *focusEvent);
+
 private:
   IRCClientInterface *m_ircClientInterface;
   IRCChannelProxyInterface *m_octaveChannel;
--- a/gui/src/MainWindow.cpp	Wed Aug 17 02:05:57 2011 +0200
+++ b/gui/src/MainWindow.cpp	Wed Aug 17 02:49:24 2011 +0200
@@ -151,6 +151,19 @@
 }
 
 void
+MainWindow::handleUnreadMessages (bool yes)
+{
+  if (yes)
+    {
+      m_ircWidgetSubWindow->setWindowIcon (QIcon ("../media/jabber_protocol.png"));
+    }
+  else
+    {
+      m_ircWidgetSubWindow->setWindowIcon (QIcon ("../media/chat.png"));
+    }
+}
+
+void
 MainWindow::alignMdiWindows ()
 {
   m_centralMdiArea->tileSubWindows ();
@@ -281,6 +294,7 @@
   m_octaveTerminalSubWindow->setObjectName ("OctaveTerminalSubWindow");
   m_octaveTerminalSubWindow->setWindowTitle (tr ("Terminal"));
   m_octaveTerminalSubWindow->setWindowIcon (QIcon ("../media/terminal.png"));
+  m_octaveTerminalSubWindow->setFocusProxy (m_octaveTerminal);
   m_octaveTerminalSubWindow->setStatusTip (tr ("Enter your commands into the Octave terminal."));
 
   // Documentation subwindow.
@@ -291,6 +305,7 @@
   m_documentationWidgetSubWindow->setObjectName ("DocumentationWidgetSubWindow");
   m_documentationWidgetSubWindow->setWindowTitle (tr ("Documentation"));
   m_documentationWidgetSubWindow->setWindowIcon (QIcon ("../media/help_index.png"));
+  m_documentationWidgetSubWindow->setFocusProxy (m_documentationWidget);
   m_documentationWidgetSubWindow->setStatusTip (tr ("Browse the Octave documentation for help."));
 
   // Chat subwindow.
@@ -303,6 +318,8 @@
   m_ircWidgetSubWindow->setWindowTitle (tr ("Chat"));
   m_ircWidgetSubWindow->setWindowIcon (QIcon ("../media/chat.png"));
   m_ircWidgetSubWindow->setStatusTip(tr ("Instantly chat with other Octave users for help."));
+  m_ircWidgetSubWindow->setFocusProxy (m_ircWidget);
+  connect (m_ircWidget, SIGNAL (unreadMessages (bool)), this, SLOT (handleUnreadMessages (bool)));
 
   m_lexer = NULL;  // initialise the empty lexer for the edtiors
 
--- a/gui/src/MainWindow.h	Wed Aug 17 02:05:57 2011 +0200
+++ b/gui/src/MainWindow.h	Wed Aug 17 02:49:24 2011 +0200
@@ -75,6 +75,7 @@
   void handleLoadWorkspaceRequest ();
   void handleClearWorkspaceRequest ();
   void handleCommandDoubleClicked (QString command);
+  void handleUnreadMessages (bool yes);
   void alignMdiWindows ();
   void openEditor ();
   void openEditorFile (QString fileName);