Logo Search packages:      
Sourcecode: kmess version File versions

emoticonbutton.cpp

/***************************************************************************
                          emoticonbutton.cpp  -  description
                             -------------------
    begin                : Mon May 6 2002
    copyright            : (C) 2002 by Mike K. Bennett
    email                : mkb137b@hotmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "emoticonbutton.h"

#include <qcolor.h>
#include <qpalette.h>
#include <qpixmap.h>
#include <qregexp.h>
#include <qstyle.h>
#include <qtooltip.h>

#include <kdebug.h>

#include "../emoticon.h"
#include "../kmessdebug.h"

EmoticonButton::EmoticonButton(const Emoticon *emoticon, QWidget *parent, const char *name )
 : QToolButton(parent,name),
   emoticon_(emoticon)
{
  QString emoticonFile = emoticon_->getFilePath();

#ifdef KMESSDEBUG_EMOTICONBUTTON
  kdDebug() << "EmoticonButton: file is at " << emoticonFile;
#endif

  // Set the pixmap
  QPixmap emoticonPixmap(emoticonFile);
  setPixmap( emoticonPixmap );
  resize( 32, 32 );

  // Set other properties.
  setAutoRaise(true);  // flat, only show border on mouse over
  setUsesTextLabel(false);
//  setUsesBigPixmap(true);

  // Add a tooltip, if present
  if( emoticon_->hasTooltip() )
  {
    QToolTip::add( this, emoticon_->getTooltip() );
  }

  // Connect the button's own clicked signal to the clicked slot
  connect( this, SIGNAL(     clicked() ),
           this, SLOT  ( slotClicked() ) );
  // Connect to the emoticon to receive updates.
  connect( emoticon, SIGNAL(   changedFilePath() ),
           this,     SLOT  ( slotPixmapChanged() ) );
}



EmoticonButton::~EmoticonButton()
{
}



// The button was clicked.
void EmoticonButton::slotClicked()
{
  emit insertEmoticon( emoticon_->getText() );
}


// The pixmap changed
void EmoticonButton::slotPixmapChanged()
{
  QPixmap emoticonPixmap( emoticon_->getFilePath() );
  setPixmap( emoticonPixmap );
}


#include "emoticonbutton.moc"

Generated by  Doxygen 1.6.0   Back to index