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

void ChatView::slotAddNewEmoticon (  )  [private, slot]

Open a dialog to add a new custom emoticon seen in the chat

Definition at line 631 of file chatview.cpp.

References CurrentAccount::getContactByHandle(), EmoticonManager::instance(), and AddEmoticonDialog::preSelect().

{
  if( ! chatViewClickedUrl_.isValid() || chatViewClickedUrl_.protocol() != "kmess" || chatViewClickedUrl_.host() != "emoticon" )
  {
#ifdef KMESSDEBUG_CHATVIEW
    kDebug() << "Ignoring request for invalid URL: " << chatViewClickedUrl_;
#endif

    return;
  }

/*
 * KMess' internal emoticon addition URLs are in the form
 * <code>kmess://emoticon/contactHandle/urlEncodedShortcut/urlEncodedPicturePath</code>
 */

  QString path( chatViewClickedUrl_.path().mid( 1 ) );  // remove first /

#ifdef KMESSTEST
  KMESS_ASSERT( ! path.isEmpty() );
#endif

  // Reset the url
  chatViewClickedUrl_.clear();

  QString handle  ( path.section( "/", 0, 0 ) );   // First parameter: contact handle
  QString shortcut( path.section( "/", 1, 1 ) );   // Second parameter: emoticon shortcut
  QString picture ( path.section( "/", 2    ) );   // Third parameter: emoticon picture path

  const ContactBase *contact = CurrentAccount::instance()->getContactByHandle( handle );
  if( contact == 0 )
  {
#ifdef KMESSDEBUG_CHATVIEW
    kDebug() << "Contact handle not found: " << handle;
#endif

    return;
  }

  // URL-Decode the encoded strings
  picture  = KUrl::fromPercentEncoding( picture.toAscii()  );
  shortcut = KUrl::fromPercentEncoding( shortcut.toUtf8() );

#ifdef KMESSDEBUG_CHATVIEW
  kDebug() << "Showing Add Emoticon dialog - shortcut=" << shortcut << " picture=" << picture;
#endif

  // Finally, show the dialog, preselecting the picture file and shortcut
  AddEmoticonDialog *addDialog = new AddEmoticonDialog( EmoticonManager::instance()->getTheme( true ), chatMessageView_->view() );

  connect( addDialog,        SIGNAL( addedEmoticon(QString) ),
           chatMessageView_, SLOT  ( addedEmoticon(QString) ) );

  addDialog->preSelect( picture, shortcut );

}


Generated by  Doxygen 1.6.0   Back to index