Juan F. Codagnone wrote:
On Friday 04 April 2003 09:05, Thomas Reitelbach wrote:
Use Alt + Left/Right, this is the combination in some KDE apps as well
(ksirc for example).

Opera (not the cookies you eat!) also use Alt+Left/Right, and that was the first tabbed app i saw out there.

Yeap, here is the updated patch file where the shortcut is this Alt + Left/Right. The patch is also in here: http://tumppi.net/licq/tabbedchatting3.diff

This patch file is also against the current cvs repository.

Regards,
--
#  Tuomas Jaakola
Index: ewidgets.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/ewidgets.cpp,v
retrieving revision 1.68
diff -u -r1.68 ewidgets.cpp
--- ewidgets.cpp        22 Feb 2003 08:34:38 -0000      1.68
+++ ewidgets.cpp        3 Apr 2003 21:04:32 -0000
@@ -25,6 +25,7 @@
 #include "eventdesc.h"
 #include "ewidgets.h"
 #include "usercodec.h"
+#include "usereventdlg.h"
 
 using namespace std;
 
@@ -516,11 +517,11 @@
 
 //- Message View Widget ---------------------------------------------------------
 
-CMessageViewWidget::CMessageViewWidget(unsigned long _nUin, QWidget* parent, const 
char * name)
+CMessageViewWidget::CMessageViewWidget(unsigned long _nUin, CMainWindow *m, QWidget* 
parent, const char * name)
 :CHistoryWidget(parent,name)
 {
   m_nUin= _nUin;
-  parentWidget = parent;
+  mainwin = m;
 
   // add all unread messages.
   vector<CUserEvent*> newEventList;
@@ -628,9 +629,16 @@
 #endif 
   GotoEnd();
 
+  QWidget *parent = NULL;
+  if (parentWidget() &&
+      parentWidget()->parentWidget() &&
+      parentWidget()->parentWidget()->parentWidget())
+    parent = parentWidget()->parentWidget()->parentWidget();
   if (
 #if QT_VERSION >= 300
-      parentWidget && parentWidget->isActiveWindow() &&
+      parent && parent->isActiveWindow() &&
+      (!mainwin->m_bTabbedChatting || (mainwin->m_bTabbedChatting &&
+       mainwin->userEventTabDlg->tabIsSelected(parent))) &&
 #endif
       e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
     ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R );
Index: ewidgets.h
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/ewidgets.h,v
retrieving revision 1.26
diff -u -r1.26 ewidgets.h
--- ewidgets.h  22 Feb 2003 08:34:39 -0000      1.26
+++ ewidgets.h  3 Apr 2003 21:04:32 -0000
@@ -13,6 +13,7 @@
 
 class CUserEvent;
 class ICQEvent;
+class CMainWindow;
 
 bool QueryUser(QWidget *, QString, QString, QString);
 int QueryUser(QWidget *, QString, QString, QString, QString);
@@ -128,9 +129,10 @@
   Q_OBJECT
 private:
   unsigned long m_nUin;
-  QWidget *parentWidget;
+  CMainWindow *mainwin;
 public:
-  CMessageViewWidget(unsigned long _nUin, QWidget* parent=0, const char * name =0);
+  CMessageViewWidget(unsigned long _nUin, CMainWindow *m,
+                    QWidget* parent=0, const char * name =0);
   virtual ~CMessageViewWidget(){};
 public slots:
   virtual void addMsg(CUserEvent *);
Index: mainwin.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/mainwin.cpp,v
retrieving revision 1.275
diff -u -r1.275 mainwin.cpp
--- mainwin.cpp 24 Mar 2003 15:33:52 -0000      1.275
+++ mainwin.cpp 3 Apr 2003 21:04:47 -0000
@@ -41,6 +41,7 @@
 #include <qlayout.h>
 #include <qtextview.h>
 #include <qpainter.h>
+#include <qtabwidget.h>
 #if QT_VERSION >= 300
 #include <qstylefactory.h>
 #endif
@@ -345,6 +346,11 @@
   licqConf.ReadBool("SystemBackground", m_bSystemBackground, false);
   licqConf.ReadBool("SendFromClipboard", m_bSendFromClipboard, true);
   licqConf.ReadBool("MsgChatView", m_bMsgChatView, true );
+#if QT_VERSION < 300
+  m_bTabbedChatting = false;
+#else
+  licqConf.ReadBool("TabbedChatting", m_bTabbedChatting, true);
+#endif
   licqConf.ReadBool("AutoPosReplyWin", m_bAutoPosReplyWin, true);
   licqConf.ReadBool("AutoSendThroughServer", m_bAutoSendThroughServer, false);
   licqConf.ReadBool("EnableMainwinMouseMovement", m_bEnableMainwinMouseMovement, 
true);
@@ -453,6 +459,9 @@
   awayMsgDlg = NULL;
   optionsDlg = NULL;
   registerUserDlg = NULL;
+#if QT_VERSION >= 300
+  userEventTabDlg = NULL;
+#endif
   m_nRealHeight = 0;
 
   ICQOwner *o = gUserManager.FetchOwner(LOCK_R);
@@ -640,6 +649,7 @@
   ClassHint.res_name = (char *)name();
   XSetClassHint(x11Display(), winId(), &ClassHint);
 #endif
+
 }
 
 //-----ApplySkin----------------------------------------------------------------
@@ -1257,6 +1267,11 @@
         v->triggerUpdate();
       }
 
+#if QT_VERSION >= 300
+      // update the tab icon of this user
+      if (m_bTabbedChatting && userEventTabDlg)
+        userEventTabDlg->updateTabLabel(u);
+#endif
       gUserManager.DropUser(u);
 
       break;
@@ -2026,7 +2041,7 @@
     case mnuUserSendSms:
     {
 #if QT_VERSION < 300
-        QListIterator<UserSendCommon> it(licqUserSend );
+        QListIterator<UserSendCommon> it(licqUserSend);
 #else
         QPtrListIterator<UserSendCommon> it(licqUserSend);
 #endif
@@ -2036,22 +2051,51 @@
         for (; it.current(); ++it)
           if ((*it)->Uin() == nUin)
           {
-            e = *it;
-            e->show();
-            if(!qApp->activeWindow() || 
!qApp->activeWindow()->inherits("UserEventCommon"))
-            {
-              e->raise();
+           e = *it;
+#if QT_VERSION >= 300
+           if (userEventTabDlg && userEventTabDlg->tabExists(e))
+           {
+             userEventTabDlg->show();
+             userEventTabDlg->selectTab(e);
+             userEventTabDlg->raise();
 #ifdef USE_KDE
-              KWin::setActiveWindow(e->winId());
+             KWin::setActiveWindow(userEventTabDlg->winId());
 #endif
-            }
-            return e;
-          }
+           }
+#endif
+           else
+           {
+             e->show();
+             if(!qApp->activeWindow() || 
!qApp->activeWindow()->inherits("UserEventCommon"))
+              {
+               e->raise();
+#ifdef USE_KDE
+               KWin::setActiveWindow(e->winId());
+#endif
+             }
+           }
+           return e;
+         }
     }
   default:
     break;
   }
 
+  QWidget *parent = NULL;
+#if QT_VERSION >= 300
+  if (m_bTabbedChatting)
+  {
+    if (userEventTabDlg != NULL)
+      userEventTabDlg->raise();
+    else
+    {
+      // create the tab dialog if it does not exist
+      userEventTabDlg = new UserEventTabDlg();
+      connect(userEventTabDlg, SIGNAL(signal_done()), this, 
SLOT(slot_doneUserEventTabDlg()));
+    }
+    parent = userEventTabDlg;
+  }
+#endif
   switch (fcn)
   {
     case mnuUserView:
@@ -2061,56 +2105,64 @@
     }
     case mnuUserSendMsg:
     {
-      e = new UserSendMsgEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendMsgEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     case mnuUserSendUrl:
     {
-      e = new UserSendUrlEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendUrlEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     case mnuUserSendChat:
     {
-      e = new UserSendChatEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendChatEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     case mnuUserSendFile:
     {
-      e = new UserSendFileEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendFileEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     case mnuUserSendContact:
     {
-      e = new UserSendContactEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendContactEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     case mnuUserSendSms:
     {
-      e = new UserSendSmsEvent(licqDaemon, licqSigMan, this, nUin);
+      e = new UserSendSmsEvent(licqDaemon, licqSigMan, this, nUin, parent);
       break;
     }
     default:
       gLog.Warn("%sunknown callFunction() fcn: %d\n", L_WARNxSTR, fcn);
   }
-  if(e) {
-    connect(e, SIGNAL(viewurl(QWidget*, QString)), this, SLOT(slot_viewurl(QWidget *, 
QString)));
-    e->show();
-    // there might be more than one send window open
-    // make sure we only remember one, or it will get compliated
-    if (fcn == mnuUserView)
-    {
-      slot_userfinished(nUin);
-      connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_userfinished(unsigned 
long)));
-      licqUserView.append(static_cast<UserViewEvent*>(e));
-    }
-    else
-    {
-      slot_sendfinished(nUin);
-      connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_sendfinished(unsigned 
long)));
-      licqUserSend.append(static_cast<UserSendCommon*>(e));
-    }
+  if (e == NULL) return NULL;
+
+  connect(e, SIGNAL(viewurl(QWidget*, QString)), this, SLOT(slot_viewurl(QWidget *, 
QString)));
+#if QT_VERSION >= 300
+  if (m_bTabbedChatting && fcn != mnuUserView)
+  {
+    userEventTabDlg->addTab(e);
+    userEventTabDlg->show();
   }
+  else
+#endif
+    e->show();
 
+  // there might be more than one send window open
+  // make sure we only remember one, or it will get complicated
+  if (fcn == mnuUserView)
+  {
+    slot_userfinished(nUin);
+    connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_userfinished(unsigned 
long)));
+    licqUserView.append(static_cast<UserViewEvent*>(e));
+  }
+  else
+  {
+    slot_sendfinished(nUin);
+    connect(e, SIGNAL(finished(unsigned long)), SLOT(slot_sendfinished(unsigned 
long)));
+    licqUserSend.append(static_cast<UserSendCommon*>(e));
+  }
   return e;
 }
 
@@ -2138,6 +2190,12 @@
 
 
 // -----------------------------------------------------------------------------
+#if QT_VERSION >= 300
+void CMainWindow::slot_doneUserEventTabDlg()
+{
+  userEventTabDlg = NULL;
+}
+#endif
 
 void CMainWindow::slot_userfinished(unsigned long nUin)
 {
@@ -2166,7 +2224,6 @@
 #else
   QPtrListIterator<UserSendCommon> it(licqUserSend);
 #endif
-
   // go through the whole list, there might be more than
   // one hit
   for ( ; it.current(); ++it)
@@ -2564,6 +2621,7 @@
   licqConf.WriteBool("SystemBackground", m_bSystemBackground);
   licqConf.WriteBool("SendFromClipboard", m_bSendFromClipboard);
   licqConf.WriteBool("MsgChatView", m_bMsgChatView);
+  licqConf.WriteBool("TabbedChatting", m_bTabbedChatting);
   licqConf.WriteBool("AutoPosReplyWin", m_bAutoPosReplyWin);
   licqConf.WriteBool("AutoSendThroughServer", m_bAutoSendThroughServer);
   licqConf.WriteBool("EnableMainwinMouseMovement", m_bEnableMainwinMouseMovement);
Index: mainwin.h
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/mainwin.h,v
retrieving revision 1.102
diff -u -r1.102 mainwin.h
--- mainwin.h   18 Mar 2003 17:03:49 -0000      1.102
+++ mainwin.h   3 Apr 2003 21:04:48 -0000
@@ -49,6 +49,9 @@
 
 class CICQSignal;
 class UserInfoDlg;
+#if QT_VERSION >= 300
+class UserEventTabDlg;
+#endif
 
 #if QT_VERSION < 300
   typedef QList<UserViewEvent> UserViewEventList;
@@ -118,7 +121,8 @@
        m_bPopLastOnline,
        m_bPopOnlineSince,
        m_bPopIdleTime,
-       m_bShowAllEncodings;
+       m_bShowAllEncodings,
+       m_bTabbedChatting;
 
   QString m_MsgAutopopupKey;
   QString m_DefaultEncoding;
@@ -149,6 +153,9 @@
   AwayMsgDlg *awayMsgDlg;
   OptionsDlg *optionsDlg;
   RegisterUserDlg *registerUserDlg;
+#if QT_VERSION >= 300
+  UserEventTabDlg *userEventTabDlg;
+#endif
 
   // Widgets
   CUserView *userView;
@@ -292,6 +299,9 @@
   void slot_popupall();
   void slot_aboutToQuit();
   void UserInfoDlg_finished(unsigned long);
+#if QT_VERSION >= 300
+  void slot_doneUserEventTabDlg();
+#endif
 
 signals:
   void changeDockStatus(unsigned short);
Index: optionsdlg.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/optionsdlg.cpp,v
retrieving revision 1.133
diff -u -r1.133 optionsdlg.cpp
--- optionsdlg.cpp      19 Mar 2003 07:44:34 -0000      1.133
+++ optionsdlg.cpp      3 Apr 2003 21:05:02 -0000
@@ -207,6 +207,9 @@
   chkSysBack->setChecked(mainwin->m_bSystemBackground);
   chkSendFromClipboard->setChecked(mainwin->m_bSendFromClipboard);
   chkMsgChatView->setChecked( mainwin->m_bMsgChatView );
+#if QT_VERSION >= 300
+  chkTabbedChatting->setChecked(mainwin->m_bTabbedChatting);
+#endif
   chkAutoPosReplyWin->setChecked(mainwin->m_bAutoPosReplyWin);
   chkAutoSendThroughServer->setChecked(mainwin->m_bAutoSendThroughServer);
   chkEnableMainwinMouseMovement->setChecked(mainwin->m_bEnableMainwinMouseMovement);
@@ -458,6 +461,9 @@
   mainwin->m_bSystemBackground = chkSysBack->isChecked();
   mainwin->m_bSendFromClipboard = chkSendFromClipboard->isChecked();
   mainwin->m_bMsgChatView = chkMsgChatView->isChecked();
+#if QT_VERSION >= 300
+  mainwin->m_bTabbedChatting = chkTabbedChatting->isChecked();
+#endif
   mainwin->m_bAutoPosReplyWin = chkAutoPosReplyWin->isChecked();
   mainwin->m_bAutoSendThroughServer = chkAutoSendThroughServer->isChecked();
   mainwin->m_bEnableMainwinMouseMovement = chkEnableMainwinMouseMovement->isChecked();
@@ -709,6 +715,12 @@
   chkMsgChatView = new QCheckBox(tr("Chatmode Messageview"), boxMainWin);
   QWhatsThis::add(chkMsgChatView, tr("Show the current chat history in Send Window"));
 
+#if QT_VERSION >= 300
+  chkTabbedChatting = new QCheckBox(tr("Tabbed Chatting"), boxMainWin);
+  QWhatsThis::add(chkTabbedChatting, tr("Use tabs in Send Window"));
+  connect(chkMsgChatView, SIGNAL(toggled(bool)), this, 
SLOT(slot_useMsgChatView(bool)));
+#endif
+
   l = new QVBoxLayout(l);
   boxLocale = new QGroupBox(1, Horizontal, tr("Localization"), w);
   lblDefaultEncoding = new QLabel(tr("Default Encoding:"), boxLocale);
@@ -973,6 +985,12 @@
 {
   spnPortLow->setEnabled(b);
   spnPortHigh->setEnabled(b);
+}
+
+void OptionsDlg::slot_useMsgChatView(bool b)
+{
+  if (!b) chkTabbedChatting->setChecked(false);
+  chkTabbedChatting->setEnabled(b);
 }
 
 void OptionsDlg::slot_useProxy(bool b)
Index: optionsdlg.h
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/optionsdlg.h,v
retrieving revision 1.62
diff -u -r1.62 optionsdlg.h
--- optionsdlg.h        18 Mar 2003 17:03:53 -0000      1.62
+++ optionsdlg.h        3 Apr 2003 21:05:03 -0000
@@ -77,7 +77,7 @@
              *chkBoldOnMsg, *chkManualNewUser,
              *chkAlwaysShowONU, *chkScrollBar, *chkShowExtIcons,
              *chkSysBack, *chkSendFromClipboard, *chkMsgChatView, *chkAutoPosReplyWin,
-            *chkAutoSendThroughServer,
+            *chkAutoSendThroughServer, *chkTabbedChatting,
              *chkEnableMainwinMouseMovement;
    QRadioButton *rdbDockDefault, *rdbDockThemed;
    QComboBox *cmbDockTheme, *cmbSortBy;
@@ -145,6 +145,7 @@
   void slot_useDockToggled(bool);
   void slot_useFirewall(bool);
   void slot_usePortRange(bool b);
+  void slot_useMsgChatView(bool);
   void slot_ok();
 };
 
Index: usereventdlg.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/usereventdlg.cpp,v
retrieving revision 1.113
diff -u -r1.113 usereventdlg.cpp
--- usereventdlg.cpp    23 Mar 2003 17:49:39 -0000      1.113
+++ usereventdlg.cpp    3 Apr 2003 21:05:13 -0000
@@ -37,6 +37,7 @@
 #include <qpopupmenu.h>
 #include <qtextcodec.h>
 #include <qwhatsthis.h>
+#include <qtabwidget.h>
 
 #ifdef USE_KDE
 #include <kfiledialog.h>
@@ -73,6 +74,166 @@
 #include "xpm/chatChangeBg.xpm"
 
 // -----------------------------------------------------------------------------
+#if QT_VERSION >= 300
+UserEventTabDlg::UserEventTabDlg(QWidget *parent, const char *name)
+  : QWidget(parent, name, WDestructiveClose)
+{
+  QBoxLayout *lay = new QVBoxLayout(this);
+  tabw = new QTabWidget(this);
+  lay->addWidget(tabw);
+  connect(tabw, SIGNAL(currentChanged(QWidget *)),
+         this, SLOT(updateTitle(QWidget *)));
+  connect(tabw, SIGNAL(currentChanged(QWidget *)),
+          this, SLOT(clearEvents(QWidget *)));
+}
+
+UserEventTabDlg::~UserEventTabDlg()
+{
+  emit signal_done();
+}
+
+void UserEventTabDlg::addTab(UserEventCommon *tab, int index)
+{
+  QString label;
+  ICQUser *u = gUserManager.FetchUser(tab->Uin(), LOCK_W);
+  if (u == NULL) return;
+
+  // initalize codec
+  QTextCodec *codec = QTextCodec::codecForLocale();
+  label = codec->toUnicode(u->GetAlias());
+  tabw->insertTab(tab, label, index);
+  updateTabLabel(u);
+  gUserManager.DropUser(u);
+  tabw->showPage(tab);
+}
+
+void UserEventTabDlg::removeTab(QWidget *tab)
+{
+  if (tabw->count() > 1)
+  {
+    tabw->removePage(tab);
+    tab->close(true);
+  }
+  else
+    close();
+}
+
+void UserEventTabDlg::selectTab(QWidget *tab)
+{
+  tabw->showPage(tab);
+  updateTitle(tab);
+}
+
+void UserEventTabDlg::replaceTab(QWidget *oldTab,
+                                UserEventCommon *newTab)
+{
+  addTab(newTab, tabw->indexOf(oldTab));
+  removeTab(oldTab);
+}
+
+bool UserEventTabDlg::tabIsSelected(QWidget *tab)
+{
+  if (tabw->currentPageIndex() == tabw->indexOf(tab))
+    return true;
+  else
+    return false;
+}
+
+bool UserEventTabDlg::tabExists(QWidget *tab)
+{
+  if (tabw->indexOf(tab) != -1)
+    return true;
+  else return false;
+}
+
+void UserEventTabDlg::updateTabLabel(ICQUser *u)
+{
+  for (int index = 0; index < tabw->count(); index++)
+  {
+    UserEventCommon *tab = static_cast<UserEventCommon*>(tabw->page(index));
+    if (tab->Uin() == u->Uin())
+    {
+      if (u->NewMessages() > 0)
+      {
+       // use an event icon
+       unsigned short SubCommand = 0;
+       for (unsigned short i = 0; i < u->NewMessages(); i++)
+       {
+         switch(u->EventPeek(i)->SubCommand())
+         {
+         case ICQ_CMDxSUB_FILE:
+           SubCommand = ICQ_CMDxSUB_FILE;
+           break;
+         case ICQ_CMDxSUB_CHAT:
+           if (SubCommand != ICQ_CMDxSUB_FILE) SubCommand = ICQ_CMDxSUB_CHAT;
+           break;
+         case ICQ_CMDxSUB_URL:
+           if (SubCommand != ICQ_CMDxSUB_FILE && SubCommand != ICQ_CMDxSUB_CHAT)
+             SubCommand = ICQ_CMDxSUB_URL;
+           break;
+         case ICQ_CMDxSUB_CONTACTxLIST:
+           if(SubCommand != ICQ_CMDxSUB_FILE && SubCommand != ICQ_CMDxSUB_CHAT
+              && SubCommand != ICQ_CMDxSUB_URL)
+             SubCommand = ICQ_CMDxSUB_CONTACTxLIST;
+         case ICQ_CMDxSUB_MSG:
+         default:
+           if (SubCommand == 0) SubCommand = ICQ_CMDxSUB_MSG;
+           break;
+         }
+       }
+       if(SubCommand)
+         tabw->setTabIconSet(tab, CMainWindow::iconForEvent(SubCommand));
+      }
+      // use status icon
+      else tabw->setTabIconSet(tab, CMainWindow::iconForStatus(u->StatusFull()));
+      return;
+    }
+  }
+}
+
+void UserEventTabDlg::updateTitle(QWidget *tab)
+{
+  if (tab->caption())
+    setCaption(tab->caption());
+}
+
+void UserEventTabDlg::clearEvents(QWidget *tab)
+{
+  if (!isActiveWindow()) return;
+  UserEventCommon *e = static_cast<UserEventCommon*>(tab);
+  ICQUser *u = gUserManager.FetchUser(e->Uin(), LOCK_R);
+  if (u != NULL && u->NewMessages() > 0)
+  {
+    std::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 (unsigned short i = 0; i < idList.size(); i++)
+      u->EventClearId(idList[i]);
+  }
+  gUserManager.DropUser(u);
+}
+
+void UserEventTabDlg::moveLeft()
+{
+  int index = tabw->currentPageIndex();
+  if (index > 0)
+    tabw->setCurrentPage(index - 1);
+}
+
+void UserEventTabDlg::moveRight()
+{
+  int index = tabw->currentPageIndex();
+  if (index < tabw->count() - 1)
+    tabw->setCurrentPage(index + 1);
+}
+#endif
+
+// -----------------------------------------------------------------------------
 
 UserEventCommon::UserEventCommon(CICQDaemon *s, CSignalManager *theSigMan,
                                  CMainWindow *m, unsigned long _nUin,
@@ -245,6 +406,11 @@
   m_sBaseTitle = codec->toUnicode(u->GetAlias()) + " (" +
              codec->toUnicode(u->GetFirstName()) + " " +
              codec->toUnicode(u->GetLastName())+ ")";
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   setIconText(codec->toUnicode(u->GetAlias()));
 }
@@ -944,6 +1110,16 @@
 
   QAccel *a = new QAccel( this );
   a->connectItem(a->insertItem(Key_Escape), this, SLOT(cancelSend()));
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      parent == mainwin->userEventTabDlg)
+  {
+    a->connectItem(a->insertItem(ALT + Key_Left),
+                  mainwin->userEventTabDlg, SLOT(moveLeft()));
+    a->connectItem(a->insertItem(ALT + Key_Right),
+                  mainwin->userEventTabDlg, SLOT(moveRight()));
+  }
+#endif
 
   QGroupBox *box = new QGroupBox(this);
   top_lay->addWidget(box);
@@ -1010,7 +1186,7 @@
   //splView->setOpaqueResize();
   mleHistory=0;
   if (mainwin->m_bMsgChatView) {
-    mleHistory = new CMessageViewWidget(_nUin, splView);
+    mleHistory = new CMessageViewWidget(_nUin, mainwin, splView);
 #if QT_VERSION >= 300
     connect(mleHistory, SIGNAL(viewurl(QWidget*, QString)), mainwin, 
SLOT(slot_viewurl(QWidget *, QString)));
 #endif
@@ -1041,8 +1217,12 @@
 //-----UserSendCommon::windowActivationChange--------------------------------
 void UserSendCommon::windowActivationChange(bool oldActive)
 {
-  if (isActiveWindow() && mainwin->m_bMsgChatView)
-  {
+  if (isActiveWindow() && mainwin->m_bMsgChatView &&
+      (!mainwin->userEventTabDlg ||
+       (mainwin->userEventTabDlg &&
+       (!mainwin->userEventTabDlg->tabExists(this) ||
+        mainwin->userEventTabDlg->tabIsSelected(this)))))
+    {
     ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R);
     if (u != NULL && u->NewMessages() > 0)
     {
@@ -1063,6 +1243,17 @@
 }
 #endif
 
+//-----UserSendCommon::slot_resettitle---------------------------------------
+void UserSendCommon::slot_resettitle()
+{
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
+  setCaption(m_sBaseTitle);
+}
+
 //-----UserSendCommon::slot_SetForegroundColor-------------------------------
 void UserSendCommon::slot_SetForegroundICQColor()
 {
@@ -1115,31 +1306,36 @@
 void UserSendCommon::changeEventType(int id)
 {
   UserSendCommon* e = NULL;
+  QWidget *parent = NULL;
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+      parent = mainwin->userEventTabDlg;
+#endif
   switch(id)
   {
   case 0:
-    e = new UserSendMsgEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendMsgEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   case 1:
-    e = new UserSendUrlEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendUrlEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   case 2:
-    e = new UserSendChatEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendChatEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   case 3:
-    e = new UserSendFileEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendFileEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   case 4:
-    e = new UserSendContactEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendContactEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   case 5:
-    e = new UserSendSmsEvent(server, sigman, mainwin, m_nUin);
+    e = new UserSendSmsEvent(server, sigman, mainwin, m_nUin, parent);
     break;
   }
 
   if (e != NULL)
   {
-    QPoint p = topLevelWidget()->pos();
     if (e->mleSend && mleSend)
     {  
       e->mleSend->setText(mleSend->text());
@@ -1149,13 +1345,24 @@
       e->mleHistory->setText(mleHistory->text());
       e->mleHistory->GotoEnd();
     }
-    e->move(p);
 
-    emit signal_msgtypechanged(this, e);
+    if (!parent)
+    {
+      QPoint p = topLevelWidget()->pos();
+      e->move(p);
+    }
 
-    QTimer::singleShot( 10, e, SLOT( show() ) );
+    emit signal_msgtypechanged(this, e);
 
-    QTimer::singleShot( 100, this, SLOT( close() ) );
+    if (!parent)
+    {
+      QTimer::singleShot(10, e, SLOT(show()));
+      QTimer::singleShot(100, this, SLOT(close()));
+    }
+#if QT_VERSION >= 300
+    else
+      mainwin->userEventTabDlg->replaceTab(this, e);
+#endif
   }
 }
 
@@ -1168,7 +1375,13 @@
 {
        if (b)
        {
-               tmpWidgetWidth = width();
+#if QT_VERSION >= 300
+               if (mainwin->userEventTabDlg &&
+                   mainwin->userEventTabDlg->tabIsSelected(this))
+                  tmpWidgetWidth = mainwin->userEventTabDlg->width();
+               else
+#endif
+                 tmpWidgetWidth = width();
                if (grpMR == NULL)
                {
                        grpMR = new QVGroupBox(this);
@@ -1194,15 +1407,33 @@
                        // resize the widget to it's origin width.
                        // This is a workaroung and not perfect, but resize() does not
                        // work as expected. Maybe we find a better solution for this 
in future.
-                       QSize tmpMaxSize = maximumSize();
-                       if (tmpWidgetWidth == 0)
-                               setFixedWidth(width() - grpMRWidth);
+#if QT_VERSION >= 300
+                       if (mainwin->userEventTabDlg &&
+                           mainwin->userEventTabDlg->tabIsSelected(this))
+                       {
+                         QSize tmpMaxSize = mainwin->userEventTabDlg->maximumSize();
+                         if (tmpWidgetWidth == 0)
+                           
mainwin->userEventTabDlg->setFixedWidth(mainwin->userEventTabDlg->width() - 
grpMRWidth);
+                         else
+                         {
+                           mainwin->userEventTabDlg->setFixedWidth(tmpWidgetWidth);
+                            tmpWidgetWidth = 0;
+                         }
+                          mainwin->userEventTabDlg->setMaximumSize(tmpMaxSize);
+                       }
                        else
+#endif
                        {
-                               setFixedWidth(tmpWidgetWidth);
-                               tmpWidgetWidth = 0;
+                         QSize tmpMaxSize = maximumSize();
+                         if (tmpWidgetWidth == 0)
+                            setFixedWidth(width() - grpMRWidth);
+                         else
+                         {
+                            setFixedWidth(tmpWidgetWidth);
+                           tmpWidgetWidth = 0;
+                         }
+                         setMaximumSize(tmpMaxSize);
                        }
-                       setMaximumSize(tmpMaxSize);
                }
   }
 }
@@ -1237,6 +1468,11 @@
     m_sProgressMsg += via_server ? tr("via server") : tr("direct");
     m_sProgressMsg += "...";
     QString title = m_sBaseTitle + " [" + m_sProgressMsg + "]";
+#if QT_VERSION >= 300
+    if (mainwin->userEventTabDlg &&
+       mainwin->userEventTabDlg->tabIsSelected(this))
+      mainwin->userEventTabDlg->setCaption(title);
+#endif
     setCaption(title);
     setCursor(waitCursor);
     btnSend->setEnabled(false);
@@ -1261,7 +1497,14 @@
 {
   if (e == NULL)
   {
-    setCaption(m_sBaseTitle + " [" + m_sProgressMsg + tr("error") + "]");
+    QString title = m_sBaseTitle + " [" + m_sProgressMsg + tr("error") + "]";
+#if QT_VERSION >= 300
+    if (mainwin->userEventTabDlg &&
+       mainwin->userEventTabDlg->tabIsSelected(this))
+      mainwin->userEventTabDlg->setCaption(title);
+#endif
+    setCaption(title);
+
     return;
   }
 
@@ -1304,6 +1547,11 @@
     break;
   }
   title = m_sBaseTitle + " [" + m_sProgressMsg + result + "]";
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(title);
+#endif
   setCaption(title);
 
   setCursor(arrowCursor);
@@ -1524,10 +1772,21 @@
 
   if (!icqEventTag)
   {
-    close();
+#if QT_VERSION >= 300
+    if (mainwin->userEventTabDlg &&
+       mainwin->userEventTabDlg->tabExists(this))
+      mainwin->userEventTabDlg->removeTab(this);
+    else
+#endif
+      close();
     return;
   }
 
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   server->CancelEvent(icqEventTag);
   icqEventTag = 0;
@@ -1604,6 +1863,11 @@
   mleSend->setFocus ();
 
   m_sBaseTitle += tr(" - Message");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(0);
 }
@@ -1750,6 +2014,11 @@
   h_lay->addWidget(edtItem);
 
   m_sBaseTitle += tr(" - URL");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(1);
 }
@@ -1853,6 +2122,11 @@
   h_lay->addWidget(btnEdit);
 
   m_sBaseTitle += tr(" - File Transfer");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(3);
 }
@@ -2014,6 +2288,11 @@
   h_lay->addWidget(btnBrowse);
 
   m_sBaseTitle += tr(" - Chat Request");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(2);
 }
@@ -2124,6 +2403,11 @@
   lay->addWidget(lstContacts);
 
   m_sBaseTitle += tr(" - Contact List");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(4);
 }
@@ -2249,6 +2533,11 @@
   }
 
   m_sBaseTitle += tr(" - SMS");
+#if QT_VERSION >= 300
+  if (mainwin->userEventTabDlg &&
+      mainwin->userEventTabDlg->tabIsSelected(this))
+    mainwin->userEventTabDlg->setCaption(m_sBaseTitle);
+#endif
   setCaption(m_sBaseTitle);
   cmbSendType->setCurrentItem(5);
 }
Index: usereventdlg.h
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/usereventdlg.h,v
retrieving revision 1.47
diff -u -r1.47 usereventdlg.h
--- usereventdlg.h      15 Mar 2003 01:52:14 -0000      1.47
+++ usereventdlg.h      3 Apr 2003 21:05:13 -0000
@@ -25,6 +25,7 @@
 #include "licq_color.h"
 #include "licq_filetransfer.h"
 
+class QTabWidget;
 class QBoxLayout;
 class QGroupBox;
 class QVGroupBox;
@@ -54,6 +55,36 @@
 class MLView;
 
 /* ----------------------------------------------------------------------------- */
+#if QT_VERSION >= 300
+class UserEventTabDlg : public QWidget
+{
+  Q_OBJECT
+public:
+  UserEventTabDlg(QWidget *parent = 0, const char *name = 0);
+  ~UserEventTabDlg();
+
+  void addTab(UserEventCommon *tab, int index = -1);
+  void removeTab(QWidget *tab);
+  void selectTab(QWidget *tab);
+  void replaceTab(QWidget *oldTab, UserEventCommon *newTab);
+  bool tabIsSelected(QWidget *tab);
+  bool tabExists(QWidget *tab);
+  void updateTabLabel(ICQUser *u);
+
+private:
+  QTabWidget *tabw;
+
+public slots:
+  void updateTitle(QWidget *tab);
+  void clearEvents(QWidget *tab);
+  void moveLeft();
+  void moveRight();
+
+signals:
+  void signal_done();
+};
+#endif
+/* ----------------------------------------------------------------------------- */
 
 class UserEventCommon : public QWidget
 {
@@ -199,7 +230,7 @@
   void changeEventType(int);
   void cancelSend();
   void massMessageToggled(bool);
-  void slot_resettitle() { setCaption(m_sBaseTitle); }
+  void slot_resettitle();
   void slot_SetForegroundICQColor();
   void slot_SetBackgroundICQColor();
   void trySecure();

Reply via email to