Logo Search packages:      
Sourcecode: kmess version File versions

QPixmap MsnStatus::getIcon ( const Status  status,
const Flags  flags = FlagNone 
) [static]

Returns an icon for the specified status

Additionally, you can specify a flag you want to overlay on the status icon.

Parameters:
status Status for which to create the picture
flags Optional flags to add overlays,
See also:
Flags enum
Returns:
The status icon

Definition at line 43 of file msnstatus.cpp.

References STATUS_AWAY, STATUS_AWAY_AUTOREPLY, STATUS_BE_RIGHT_BACK, STATUS_BUSY, STATUS_IDLE, STATUS_INVISIBLE, STATUS_OFFLINE, STATUS_ON_THE_PHONE, and STATUS_OUT_TO_LUNCH.

Referenced by getStatusMenu(), and KMessViewDelegate::paint().

{
  QString iconBase;
  // initially set the overlay icon to an empty string as we do not know
  // at this point if we want one.
  QString iconOverlay;

  // Set the base icon depending on the status
  switch( status )
  {
    case STATUS_ONLINE:        iconBase = "user-online";         break;
    case STATUS_BUSY:          iconBase = "user-busy";           break;
    case STATUS_AWAY:          iconBase = "user-away";           break;
    case STATUS_IDLE:          iconBase = "user-away-extended";  break;
    case STATUS_INVISIBLE:     iconBase = "user-invisible";      break;
    case STATUS_OFFLINE:       iconBase = "user-offline";        break;

    case STATUS_BE_RIGHT_BACK:
      iconBase    = "user-away";
      iconOverlay = "contact_away_overlay";
      break;

    case STATUS_AWAY_AUTOREPLY:
      iconBase    = "user-away";
      iconOverlay = "contact_invisible_overlay";
      break;

    case STATUS_ON_THE_PHONE:
      iconBase    = "user-away-extended";
      iconOverlay = "contact_phone_overlay";
      break;

    case STATUS_OUT_TO_LUNCH:
      iconBase    = "user-away-extended";
      iconOverlay = "contact_food_overlay";
      break;

    default:
      kWarning() << "Invalid status" << status << "!";
  }

  // Choose the picture's overlay, if any.
  // FIXME: there is no 'blocked' image or overlay image in the oxygen icon set
  // One may be released in time, for now use the busy overlay as it looks the part
  // in the CURRENT oxygen theme! this may change
  switch( flags )
  {
    case FlagNone:          break;
    case FlagBlocked:       iconOverlay = "contact_busy_overlay"; break;
    case FlagWebMessenger:  break;
    case FlagMobile:        break;
  }

  // Load the icon
  QPixmap icon = KIconLoader::global()->loadIcon( iconBase, KIconLoader::Small );

  // Add the overlay if needed
  if( ! iconOverlay.isEmpty() )
  {
    // Add the overlay image to our icon
    QPixmap overlayIcon  = KIconLoader::global()->loadIcon( iconOverlay, KIconLoader::Small );
    QImage  iconImage    = icon.toImage();
    QImage  overlayImage = overlayIcon.toImage();

    KIconEffect::overlay( iconImage, overlayImage );
    icon = QPixmap::fromImage( iconImage );
  }

  return icon;
}


Generated by  Doxygen 1.6.0   Back to index