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/defaultdockicon.cpp

    r5837 r6058  
    4848 
    4949DefaultDockIcon::DefaultDockIcon(QMenu* menu) 
    50   : DockIcon(menu) 
     50  : DockIcon() 
    5151{ 
     52  myIcon = new DockIconWidget(menu); 
     53  relayDockIconSignals(); 
    5254  updateConfig(); 
    53 } 
    54  
    55 DefaultDockIcon::~DefaultDockIcon() 
    56 { 
    57   delete pix; 
    5855} 
    5956 
     
    6259  myFortyEight = Config::General::instance()->defaultIconFortyEight(); 
    6360 
    64   delete myIcon; 
     61  QPixmap* pic = new QPixmap(myFortyEight ? back48_xpm : back64_xpm); 
     62  QBitmap bmp = QBitmap(myFortyEight ? mask48_xpm : mask64_xpm); 
     63  pic->setMask(bmp); 
     64  myIcon->setFace(pic); 
     65  delete pic; 
    6566 
    66   if (myFortyEight) 
    67   { 
    68     pix = new QPixmap(back48_xpm); 
    69     QBitmap b; 
    70     b = QPixmap(mask48_xpm); 
    71     pix->setMask(b); 
    72     myIcon = new DockIconWidget(pix, this); 
    73   } 
    74   else 
    75   { 
    76     pix = new QPixmap(back64_xpm); 
    77     QBitmap b; 
    78     b = QPixmap(mask64_xpm); 
    79     pix->setMask(b); 
    80     myIcon = new DockIconWidget(pix, this); 
    81   } 
    82   X11Init(); 
     67  updateStatusIcon(); 
     68  updateIconMessages(myNewMsg, mySysMsg); 
    8369} 
    8470 
     
    8773  DockIcon::updateStatusIcon(); 
    8874 
     75  if (!myFortyEight && myNewMsg == 0 && mySysMsg == 0) 
     76    drawIcon64(myStatusIcon); 
     77 
    8978  QPixmap m; 
    90   switch (myStatus) 
    91   { 
    92     case ICQ_STATUS_ONLINE: m = QPixmap(online_xpm); break; 
    93     case ICQ_STATUS_AWAY: m = QPixmap(away_xpm); break; 
    94     case ICQ_STATUS_NA: m = QPixmap(na_xpm); break; 
    95     case ICQ_STATUS_OCCUPIED: m = QPixmap(occupied_xpm); break; 
    96     case ICQ_STATUS_DND: m = QPixmap(dnd_xpm); break; 
    97     case ICQ_STATUS_FREEFORCHAT: m = QPixmap(ffc_xpm); break; 
    98     case ICQ_STATUS_OFFLINE: m = QPixmap(offline_xpm); break; 
    99   } 
    10079  if (myInvisible) 
    10180    m = QPixmap(invisible_xpm); 
     81  else 
     82    switch (myStatus) 
     83    { 
     84      case ICQ_STATUS_ONLINE: m = QPixmap(online_xpm); break; 
     85      case ICQ_STATUS_AWAY: m = QPixmap(away_xpm); break; 
     86      case ICQ_STATUS_NA: m = QPixmap(na_xpm); break; 
     87      case ICQ_STATUS_OCCUPIED: m = QPixmap(occupied_xpm); break; 
     88      case ICQ_STATUS_DND: m = QPixmap(dnd_xpm); break; 
     89      case ICQ_STATUS_FREEFORCHAT: m = QPixmap(ffc_xpm); break; 
     90      case ICQ_STATUS_OFFLINE: m = QPixmap(offline_xpm); break; 
     91    } 
    10292 
    103   QPainter painter(myIcon->vis); 
    104   if (!myFortyEight) 
    105   { 
    106     painter.drawPixmap(0, 44, m); 
    107     // Draw the little icon if no new messages 
    108     if (myNewMsg == 0 && mySysMsg == 0) 
    109     { 
    110       QPixmap* p = &myStatusIcon; 
    111       painter.fillRect(31, 6, 27, 16, QColor(0,0,0)); 
    112       if (p != NULL) 
    113       { 
    114         int w = p->width() > 27 ? 27 : p->width(); 
    115         int h = p->height() > 16 ? 16 : p->height(); 
    116         int x = 45 - (w / 2); 
    117         int y = 14 - (h / 2); 
    118         painter.drawPixmap(x, y, *p, 0, 0, w, h); 
    119       } 
    120     } 
    121   } 
    122   else 
    123     painter.drawPixmap(0, 27, m); 
     93  QPixmap* face = myIcon->face(); 
     94  QPainter painter(face); 
     95  painter.drawPixmap(0, myFortyEight ? 27 : 44, m); 
    12496  painter.end(); 
    12597 
    126   myIcon->repaint(); 
    127   repaint(); 
    128 } 
    129  
    130 void DefaultDockIcon::splitDigits(int num, int& low, int &high) 
    131 { 
    132   if (num > 99) 
    133   { 
    134     low = 9; 
    135     high = 9; 
    136   } 
    137   else 
    138   { 
    139     low = num % 10; 
    140     high = num / 10; 
    141   } 
     98  myIcon->setFace(face); 
     99  delete face; 
    142100} 
    143101 
    144102void DefaultDockIcon::updateIconMessages(int newMsg, int sysMsg) 
    145103{ 
    146   QPainter p(myIcon->vis); 
    147   int d1, d10; 
     104  DockIcon::updateIconMessages(newMsg, sysMsg); 
    148105 
    149   // set the new msg digits 
    150   splitDigits(newMsg, d1, d10); 
     106  int low, high; 
    151107 
    152   if (!myFortyEight) 
    153   { 
    154     p.drawPixmap(44, 26, digits[d10]); 
    155     p.drawPixmap(50, 26, digits[d1]); 
    156   } 
    157   else 
    158   { 
    159     p.drawPixmap(44, 9, digits[d10]); 
    160     p.drawPixmap(50, 9, digits[d1]); 
    161   } 
     108#define SPLIT(num) \ 
     109  (num) = qMin(num, 99); \ 
     110  low = (num) % 10; \ 
     111  high = (num) / 10; 
    162112 
    163   // set the system msg digits 
    164   splitDigits(sysMsg, d1, d10); 
     113  QPixmap* face = myIcon->face(); 
     114  QPainter p(face); 
    165115 
    166   if (!myFortyEight) 
    167   { 
    168     p.drawPixmap(44, 38, digits[d10]); 
    169     p.drawPixmap(50, 38, digits[d1]); 
    170   } 
    171   else 
    172   { 
    173     p.drawPixmap(44, 21, digits[d10]); 
    174     p.drawPixmap(50, 21, digits[d1]); 
    175   } 
     116  SPLIT(newMsg); 
     117  p.drawPixmap(44, myFortyEight ? 8 : 26, digits[high]); 
     118  p.drawPixmap(50, myFortyEight ? 8 : 26, digits[low]); 
     119 
     120  SPLIT(sysMsg); 
     121  p.drawPixmap(44, myFortyEight ? 20 : 38, digits[high]); 
     122  p.drawPixmap(50, myFortyEight ? 20 : 38, digits[low]); 
     123 
    176124  p.end(); 
    177125 
    178   // Base class will trigger updateEventIcon to actually paint the icon 
    179   DockIcon::updateIconMessages(newMsg, sysMsg); 
     126  myIcon->setFace(face); 
     127  delete face; 
    180128} 
    181129 
    182130void DefaultDockIcon::updateEventIcon() 
    183131{ 
    184   if (!myFortyEight) 
    185   { 
    186     QPainter p(myIcon->vis); 
     132  DockIcon::updateEventIcon(); 
    187133 
    188     // Draw the little icon now 
    189     QPixmap* m = NULL; 
    190     if (mySysMsg > 0 || myNewMsg > 0) 
    191       m = &myEventIcon; 
    192     else 
    193       m = &myStatusIcon; 
    194     p.fillRect(31, 6, 27, 16, QColor(0,0,0)); 
    195     if (m != NULL) 
    196     { 
    197       int w = m->width() > 27 ? 27 : m->width(); 
    198       int h = m->height() > 16 ? 16 : m->height(); 
    199       int x = 45 - (w / 2); 
    200       int y = 14 - (h / 2); 
    201       p.drawPixmap(x, y, *m, 0, 0, w, h); 
    202     } 
     134  if (myFortyEight) 
     135    return; 
    203136 
    204     p.end(); 
    205   } 
     137  drawIcon64((mySysMsg > 0 || myNewMsg > 0) ? myEventIcon : myStatusIcon); 
     138} 
    206139 
    207   myIcon->repaint(); 
    208   repaint(); 
     140void DefaultDockIcon::drawIcon64(QPixmap* icon) 
     141{ 
     142  if (icon == NULL || icon->isNull()) 
     143    return; 
     144 
     145  QPixmap* face = myIcon->face(); 
     146  QPainter p(face); 
     147 
     148  // Clear the icon area 
     149  p.fillRect(31, 6, 27, 16, Qt::black); 
     150 
     151  // Calculate drawing coordinates 
     152  int w = qMin(icon->width(), 27); 
     153  int h = qMin(icon->height(), 16); 
     154  int x = 45 - (w / 2); 
     155  int y = 14 - (h / 2); 
     156 
     157  p.drawPixmap(x, y, *icon, 0, 0, w, h); 
     158  p.end(); 
     159 
     160  myIcon->setFace(face); 
     161  delete face; 
    209162}