Logo Search packages:      
Sourcecode: kmess version File versions  Download package

void Emoticon::update (  ) 

Update the internal emoticon data

Standard emoticons are searched in both the current theme's folder and in the KMess' default folder; custom emoticons only in the path which has been specified at creation. This means that custom emoticons get updated, but only their file type may really change.

Definition at line 323 of file emoticon.cpp.

References Account::getEmoticonStyle().

Referenced by Emoticon(), EmoticonTheme::EmoticonTheme(), setPictureName(), and EmoticonTheme::updateTheme().

{
  QImage         emoticonData;
  QString        emoticonPath;
  QStringList    allowedTypes;
  KStandardDirs *dirs = KGlobal::dirs();

  // These are the allowed types for emoticon pictures. Add more to support more formats.
  // Search in the KDE API Docs for "QImageIO" class to find out which formats are supported, and how to add more.
  allowedTypes << "png" << "gif" << "mng" << "jpg";

  if( isCustomEmoticon_ )
  {
    emoticonPath = pictureDirectory_;
  }
  else
  {
    emoticonPath = CurrentAccount::instance()->getEmoticonStyle();
  }

  // For each iteration:
  // - with a standard emoticon, will check both folders (current and default theme);
  // - with a custom emoticon, will skip the check in the default theme folder, since they simply can't be there.
  QStringList::Iterator itType = allowedTypes.begin();
  do
  {
    if( isCustomEmoticon_ )
    {
      picturePath_ = emoticonPath + pictureName_ + "." + *itType;
    }
    else
    {
      picturePath_ = dirs->findResource( "emoticons", emoticonPath + "/" + pictureName_ + "." + *itType );

      if( ! picturePath_.isNull() && KStandardDirs::exists( picturePath_ ) )
      {
        break;
      }

      // Search in Kmess' default theme folder
      picturePath_ = dirs->findResource( "emoticons", "KMess-new/" + originalPictureName_ + "." + *itType );
    }

    if( ! picturePath_.isNull() && KStandardDirs::exists( picturePath_ ) )
    {
      break;
    }

    ++itType;
  }
  while( itType != allowedTypes.end() );

  // Fail if the path isn't valid, or if the emoticon can't be loaded
  if( picturePath_.isEmpty() || ! emoticonData.load( picturePath_ ) || emoticonData.isNull() )
  {
#ifdef KMESSDEBUG_EMOTICONS_GENERAL
    kdDebug() << "Emoticon::updatePath() - Update failed: " << originalPictureName_ << " (" << (isCustomEmoticon_?"custom":"standard") << ")" << endl;
#endif
    valid_ = false;
    return;
  }

  valid_ = true;

  // Find the dimensions of the image, to make it render nicer.
  width_  = emoticonData.width();
  height_ = emoticonData.height();

  emit changed();
}


Generated by  Doxygen 1.6.0   Back to index