Hi all!

I made a little patch which comes as attachments here.
It makes chatmode messageviews using easier.

It was a bit annoying when having multiple chat windows opened
and when a message arrived from somebody. The message arriving
event was cleared right away when it was written to some of
the chat windows. I had to browse all windows to see where
did it come to. Sometimes I didn't notice at all that a message
had arrived because it was written to some window which was hidden
somewhere.

This patch changes Licq's behaviour to remind WinIcq. Now if
a message arrives at a chat window which is not activated, the
event is not cleared until the user activates that window.

Regards,
Tumppi.
--- licq/plugins/qt-gui/src/ewidgets.orig.h     2002-08-29 02:37:03.000000000 +0300
+++ licq/plugins/qt-gui/src/ewidgets.h  2002-08-29 02:37:58.000000000 +0300
@@ -129,6 +129,7 @@
   Q_OBJECT
 private:
   unsigned long m_nUin;
+  QWidget *parentWidget;
 public:
   CMessageViewWidget(unsigned long _nUin, QWidget* parent=0, const char * name =0);
   virtual ~CMessageViewWidget(){};
--- licq/plugins/qt-gui/src/ewidgets.orig.cpp   2002-08-29 02:36:53.000000000 +0300
+++ licq/plugins/qt-gui/src/ewidgets.cpp        2002-08-29 02:39:14.000000000 +0300
@@ -506,6 +506,7 @@
 :CHistoryWidget(parent,name)
 {
   m_nUin= _nUin;
+  parentWidget = parent;
   // add all unread messages.
 //   ICQUser *u = gUserManager.FetchUser(_nUin, LOCK_W);
 //   if (u != NULL && u->NewMessages() > 0)
@@ -608,7 +609,8 @@
 #endif 
   GotoEnd();
 
-  if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
+  if (parentWidget && parentWidget->isActiveWindow() &&
+      e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
     ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R );
     if (u != NULL) {
        u->EventClearId(e->Id());
--- licq/plugins/qt-gui/src/usereventdlg.orig.h 2002-08-29 02:37:20.000000000 +0300
+++ licq/plugins/qt-gui/src/usereventdlg.h      2002-08-29 02:46:36.000000000 +0300
@@ -160,6 +160,7 @@
   virtual ~UserSendCommon();
 
   void setText(const QString& txt);
+  virtual void windowActivationChange(bool activated);
 
 signals:
   void autoCloseNotify();
--- licq/plugins/qt-gui/src/usereventdlg.orig.cpp       2002-08-29 02:37:13.000000000 
+0300
+++ licq/plugins/qt-gui/src/usereventdlg.cpp    2002-08-29 02:50:24.000000000 +0300
@@ -1025,6 +1025,31 @@
 {
 }
 
+
+//-----UserSendCommon::windowActivationChange--------------------------------
+void UserSendCommon::windowActivationChange(bool activated)
+{
+    if (activated && mainwin->m_bMsgChatView)
+    {
+       ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R);
+       if (u != NULL && u->NewMessages() > 0)
+       {
+           vector<int> idList;
+           for (unsigned short i = 0; i < u->NewMessages(); i++)
+           {
+               CUserEvent *e = u->EventPeek(i);
+               if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG)
+                    idList.push_back(e->Id());
+           }
+
+           for (int i = 0; i < idList.size(); i++)
+               u->EventClearId(idList[i]);
+       }
+       gUserManager.DropUser(u);
+    }
+}
+
+
 //-----UserSendCommon::slot_SetForegroundColor-------------------------------
 void UserSendCommon::slot_SetForegroundICQColor()
 {

Reply via email to