Show
Ignore:
Timestamp:
01/24/08 21:40:25 (10 months ago)
Author:
eugene
Message:

Major docking fix.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/qt-gui_qt4/src/dockicons/dockicon.cpp

    r5990 r6058  
    2323#include "config.h" 
    2424 
    25 #include <QBitmap> 
    26 #include <QCloseEvent> 
    27 #include <QMenu> 
    28 #include <QMouseEvent> 
    29 #include <QPainter> 
    30  
    31 #ifdef Q_WS_X11 
    32 #include <QX11Info> 
    33 #include <X11/Xlib.h> 
    34 #include <X11/Xutil.h> 
    35 #undef Status 
    36 #endif 
    37  
    3825#include <licq_user.h> 
    3926 
     
    4229 
    4330#include "helpers/licqstrings.h" 
    44 #include "helpers/support.h" 
    4531 
    4632#include "dockiconwidget.h" 
     
    4935/* TRANSLATOR LicqQtGui::DockIcon */ 
    5036 
    51 DockIcon::DockIcon(QMenu* menu) 
    52   : QWidget(NULL), 
    53     myMenu(menu), 
     37DockIcon::DockIcon() 
     38  : QObject(), 
    5439    myIcon(NULL), 
    5540    myNewMsg(0), 
     
    5843    myInvisible(false) 
    5944{ 
    60   Support::setWidgetProps(this, "Wharf"); 
    61   setWindowFlags(Qt::Window); 
    62   setWindowTitle("LicqWharf"); 
    63   setBackgroundRole(QPalette::NoRole); 
    64  
    6545  // Get icon set updates 
    6646  connect(IconManager::instance(), SIGNAL(statusIconsChanged()), SLOT(updateStatusIcon())); 
     
    6949  // Get configuration updates 
    7050  connect(Config::General::instance(), SIGNAL(dockChanged()), SLOT(updateConfig())); 
     51 
     52  unsigned short sysMsg = 0; 
     53 
     54  FOR_EACH_OWNER_START(LOCK_R) 
     55  { 
     56    sysMsg += pOwner->NewMessages(); 
     57  } 
     58  FOR_EACH_OWNER_END 
     59 
     60  unsigned short newMsg = ICQUser::getNumUserEvents() - sysMsg; 
     61 
     62  updateIconMessages(newMsg, sysMsg); 
     63  updateIconStatus(); 
    7164} 
    7265 
     
    7467{ 
    7568  delete myIcon; 
    76 } 
    77  
    78 void DockIcon::X11Init() 
    79 { 
    80   // set the hints 
    81 #if defined(Q_WS_X11) && !defined(USE_KDE) 
    82   Display* dsp = x11Info().display();  // get the display 
    83   WId win = winId();     // get the window 
    84  
    85   XSizeHints sizeHints; 
    86   sizeHints.flags = USPosition; 
    87   sizeHints.x = 0; 
    88   sizeHints.y = 0; 
    89   XSetWMNormalHints(dsp, win, &sizeHints); 
    90  
    91   XWMHints* hints = XAllocWMHints();  // hints 
    92   hints->initial_state = WithdrawnState; 
    93   hints->icon_x = 0; 
    94   hints->icon_y = 0; 
    95   hints->icon_window = myIcon->winId(); 
    96   hints->window_group = win;  // set the window hint 
    97   hints->flags = WindowGroupHint | IconWindowHint | IconPositionHint | StateHint; // set the window group hint 
    98   XSetWMHints(dsp, win, hints);  // set the window hints for WM to use. 
    99   XFree(hints); 
    100  
    101   XMapWindow(dsp, myIcon->winId()); 
    102   XMapWindow(dsp, win); 
    103   XSync(dsp, False); 
    104  
    105 #endif /* defined(Q_WS_X11) && !defined(USE_KDE) */ 
    106  
    107   resize(myIcon->size()); 
    108   setMask(myIcon->mask()); 
    109   move(-100, -100); 
    110   updateToolTip(); 
    111   show(); 
    112 #if defined(Q_WS_X11) && !defined(USE_KDE) 
    113   XWithdrawWindow(dsp, win, XScreenNumberOfScreen(DefaultScreenOfDisplay(dsp))); 
    114 #endif /* defined(Q_WS_X11) && !defined(USE_KDE) */ 
    11569} 
    11670 
     
    12478  { 
    12579    OwnerList* ol = gUserManager.LockOwnerList(LOCK_R); 
    126     for (OwnerList::iterator i = ol->begin(); i != ol->end(); i++) 
    127     { 
    128       o = *i; 
    129       o->Lock(LOCK_R); 
    130       break; 
    131     } 
     80    o = ol->front(); 
     81    o->Lock(LOCK_R); 
    13282    gUserManager.UnlockOwnerList(); 
    13383  } 
     
    159109void DockIcon::updateStatusIcon() 
    160110{ 
    161   myStatusIcon = IconManager::instance()->iconForStatus(myFullStatus, myId, myPpid); 
     111  myStatusIcon = const_cast<QPixmap*> 
     112    (&IconManager::instance()->iconForStatus(myFullStatus, myId, myPpid)); 
    162113} 
    163114 
     
    174125{ 
    175126  if (mySysMsg > 0) 
    176     myEventIcon = IconManager::instance()->getIcon(IconManager::ReqAuthorizeMessageIcon); 
     127    myEventIcon = const_cast<QPixmap*> 
     128      (&IconManager::instance()->getIcon(IconManager::ReqAuthorizeMessageIcon)); 
    177129  else if (myNewMsg > 0) 
    178     myEventIcon = IconManager::instance()->getIcon(IconManager::StandardMessageIcon); 
     130    myEventIcon = const_cast<QPixmap*> 
     131      (&IconManager::instance()->getIcon(IconManager::StandardMessageIcon)); 
    179132  else 
    180     myEventIcon = QPixmap(); 
     133    myEventIcon = NULL; 
    181134} 
    182135 
     
    201154    myIcon->setToolTip(s); 
    202155  else 
    203     setToolTip(s); 
     156    emit newToolTip(s); 
    204157} 
    205158 
    206 void DockIcon::closeEvent(QCloseEvent* event) 
     159void DockIcon::relayDockIconSignals() 
    207160{ 
    208   event->ignore(); 
     161  if (myIcon == NULL) 
     162    return; 
     163 
     164  connect(myIcon, SIGNAL(clicked()), SIGNAL(clicked())); 
     165  connect(myIcon, SIGNAL(middleClicked()), SIGNAL(middleClicked())); 
    209166} 
    210  
    211 void DockIcon::mousePressEvent(QMouseEvent* event) 
    212 { 
    213   switch (event->button()) 
    214   { 
    215     case Qt::LeftButton: 
    216       emit clicked(); 
    217       break; 
    218  
    219     case Qt::MidButton: 
    220       emit middleClicked(); 
    221       break; 
    222  
    223     case Qt::RightButton: 
    224       myMenu->popup(event->globalPos()); 
    225       break; 
    226  
    227     default: 
    228       break; 
    229   } 
    230 } 
    231  
    232 void DockIcon::paintEvent(QPaintEvent* /* event */) 
    233 { 
    234   QPainter painter(this); 
    235   myIcon->drawIcon(painter); 
    236   painter.end(); 
    237 }