2 * Custom button class for customized button.
4 * @author Jukka Kurttila <jktla@suomi24.fi>
5 * @author Toni Jussila <toni.jussila@fudeco.com>
6 * @copyright (c) 2010 Speed Freak team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 #include "custombutton.h"
15 * Constructor of this class.
17 CustomButton::CustomButton(QWidget *parent, QIcon *icon) : QWidget(parent)
20 // Get size of the icon
21 QList<QSize> list = icon->availableSizes(QIcon::Normal,QIcon::On);
23 // If icon is empty, do not create pixmaps and leave
26 QSize size = list.first();
29 pict1 = new QPixmap(icon->pixmap(size.width(),size.height(),QIcon::Normal,QIcon::On));
30 pict2 = new QPixmap(icon->pixmap(size.width(),size.height(),QIcon::Normal,QIcon::Off));
35 * Destructor of this class.
37 CustomButton::~CustomButton()
48 void CustomButton::paintEvent(QPaintEvent *)
50 QPainter painter(this);
53 painter.drawPixmap(0,0,*pict2);
55 painter.drawPixmap(0,0,*pict1);
58 // painter.drawText(50,50,"y: "+QString::number(mY));
64 * @param QMouseEvent me
66 void CustomButton::mousePressEvent(QMouseEvent* me)
73 * Mouse release event.
75 * @param QMouseEvent me
77 void CustomButton::mouseReleaseEvent(QMouseEvent* me)
81 // Emit open dialog signal if mouse is still over button
82 if( mY < this->height() && mY > 0 && mX < this->width() && mX > 0 )
92 * @param QMouseEvent me
94 void CustomButton::mouseMoveEvent(QMouseEvent* me)
98 // Is mouse moved outside button?
99 if( mY > this->height() || mY < 0 || mX > this->width() || mX < 0 )