Show
Ignore:
Timestamp:
03/15/08 22:51:25 (9 months ago)
Author:
eugene
Message:

Made user picture be updated in an already opened chat window.

Location:
trunk/qt4-gui/src/userevents
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/userevents/usersendcommon.cpp

    r6097 r6101  
    103103{ 
    104104  grpMR = NULL; 
     105  lblPicture = NULL; 
    105106  clearDelay = 250; 
    106107 
     
    421422  } 
    422423 
    423   QSplitter* bottom = new QSplitter(splView); 
    424  
    425   mleSend = new MLEdit(true, bottom, true); 
     424  splPicture = new QSplitter(splView); 
     425 
     426  mleSend = new MLEdit(true, splPicture, true); 
    426427  mleSend->setSizeHintLines(3); 
    427428  mleSend->setCheckSpellingEnabled(Config::Chat::instance()->checkSpelling()); 
    428429  mleSend->installEventFilter(this); // Enables send with enter 
    429430 
    430   if (Config::Chat::instance()->showUserPic()) 
    431   { 
    432     u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    433     if (u != NULL) 
    434     { 
    435       if (u->GetPicturePresent()) 
    436       { 
    437         QString picPath = QString(BASE_DIR) + USER_DIR + "/" + u->IdString() + ".pic"; 
    438         QMovie* picMovie = new QMovie(picPath); 
    439         if (picMovie->isValid()) 
    440         { 
    441           QLabel* picLabel = new QLabel(bottom); 
    442           picLabel->setMovie(picMovie); 
    443           picMovie->start(); 
    444           picLabel->setFixedWidth(picLabel->sizeHint().width()); 
    445           if (Config::Chat::instance()->showUserPicHidden()) 
    446             bottom->setSizes(QList<int>() << 1 << 0); 
    447         } 
    448       } 
    449       gUserManager.DropUser(u); 
    450     } 
    451   } 
    452  
    453431  if (Config::Chat::instance()->msgChatView()) 
    454432  { 
    455433    splView->setStretchFactor(splView->indexOf(mleHistory), 1); 
    456     splView->setStretchFactor(splView->indexOf(bottom), 0); 
     434    splView->setStretchFactor(splView->indexOf(splPicture), 0); 
    457435 
    458436    connect(mleHistory, SIGNAL(quote(const QString&)), 
     
    472450 
    473451  updateIcons(); 
     452  updatePicture(); 
    474453 
    475454  connect(mleSend, SIGNAL(ctrlEnterPressed()), btnSend, SIGNAL(clicked())); 
     
    527506  foreach (QAction* a, grpSendType->actions()) 
    528507    a->setIcon(iconForType(a->data().toInt())); 
     508} 
     509 
     510void UserSendCommon::updatePicture(ICQUser* u) 
     511{ 
     512  bool fetched = false; 
     513 
     514  if (u == NULL) 
     515  { 
     516    u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     517    fetched = true; 
     518  } 
     519  if (u == NULL) 
     520    return; 
     521 
     522  if (lblPicture != NULL) 
     523  { 
     524    delete lblPicture; 
     525    lblPicture = NULL; 
     526  } 
     527 
     528  if (Config::Chat::instance()->showUserPic() && 
     529      u->GetPicturePresent()) 
     530  { 
     531    QString picPath = QString(BASE_DIR) + USER_DIR + "/" + u->IdString() + ".pic"; 
     532    QMovie* picMovie = new QMovie(picPath); 
     533    if (picMovie->isValid()) 
     534    { 
     535      lblPicture = new QLabel(); 
     536      splPicture->insertWidget(1, lblPicture); 
     537      lblPicture->setMovie(picMovie); 
     538      picMovie->start(); 
     539      lblPicture->setFixedWidth(lblPicture->sizeHint().width()); 
     540      if (Config::Chat::instance()->showUserPicHidden()) 
     541        splPicture->setSizes(QList<int>() << 1 << 0); 
     542    } 
     543    else 
     544      delete picMovie; 
     545  } 
     546 
     547  if (fetched) 
     548    gUserManager.DropUser(u); 
    529549} 
    530550 
     
    955975      } 
    956976      break; 
     977 
     978    case USER_PICTURE: 
     979      updatePicture(u); 
    957980  } 
    958981 
  • trunk/qt4-gui/src/userevents/usersendcommon.h

    r5822 r6101  
    2727 
    2828class QGroupBox; 
     29class QLabel; 
    2930class QPushButton; 
    3031class QSplitter; 
     
    3233class CICQSignal; 
    3334class ICQEvent; 
     35class ICQUser; 
    3436 
    3537namespace LicqQtGui 
     
    7476  QActionGroup* grpSendType; 
    7577  QGroupBox* grpMR; 
     78  QLabel* lblPicture; 
    7679  QPushButton* btnClose; 
    7780  QPushButton* btnSend; 
    7881  QSplitter* splView; 
     82  QSplitter* splPicture; 
    7983  QString strTempMsg; 
    8084  QTimer* tmrSendTyping; 
     
    8387  void retrySend(ICQEvent* e, bool online, unsigned short level); 
    8488  virtual void userUpdated(CICQSignal* sig, QString id = QString::null, unsigned long ppid = 0); 
     89  void updatePicture(ICQUser* u = NULL); 
    8590  bool checkSecure(); 
    8691