X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fcustombutton.cpp;fp=Client%2Fcustombutton.cpp;h=6045bbcd66ef621fc79d460e645a049ed6b9e4c1;hp=39072673261f98bfc969b810a40432d2b6d1b0aa;hb=59a7180931986f4d9420f6b4f1beb85f078fd309;hpb=eb8665a8c4b6a15a9d5a9f5b348432293d171ae6 diff --git a/Client/custombutton.cpp b/Client/custombutton.cpp index 3907267..6045bbc 100644 --- a/Client/custombutton.cpp +++ b/Client/custombutton.cpp @@ -1,26 +1,26 @@ /* * Custom button class for customized button. * - * @author Jukka Kurttila - * @copyright (c) 2010 Speed Freak team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @author Jukka Kurttila + * @author Toni Jussila + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ #include "custombutton.h" - #include #include /** - *Constructor of this class. + * Constructor of this class. */ CustomButton::CustomButton(QWidget *parent, QIcon *icon) : QWidget(parent) { bPressed = false; - //Get size of the icon + // Get size of the icon QList list = icon->availableSizes(QIcon::Normal,QIcon::On); - //If icon is empty, do not create pixmaps and leave + // If icon is empty, do not create pixmaps and leave if(list.isEmpty()) return; QSize size = list.first(); @@ -30,8 +30,9 @@ CustomButton::CustomButton(QWidget *parent, QIcon *icon) : QWidget(parent) pict2 = new QPixmap(icon->pixmap(size.width(),size.height(),QIcon::Normal,QIcon::Off)); } } + /** - *Destructor of this class. + * Destructor of this class. */ CustomButton::~CustomButton() { @@ -41,6 +42,9 @@ CustomButton::~CustomButton() delete pict2; } +/** + * + */ void CustomButton::paintEvent(QPaintEvent *) { QPainter painter(this); @@ -50,30 +54,48 @@ void CustomButton::paintEvent(QPaintEvent *) else painter.drawPixmap(0,0,*pict1); - //Debug print - //painter.drawText(50,50,"y: "+QString::number(mY)); + // Debug print + // painter.drawText(50,50,"y: "+QString::number(mY)); } + +/** + * Mouse press event. + * + * @param QMouseEvent me + */ void CustomButton::mousePressEvent(QMouseEvent* me) { bPressed = true; repaint(); } + +/** + * Mouse release event. + * + * @param QMouseEvent me + */ void CustomButton::mouseReleaseEvent(QMouseEvent* me) { mX = me->x(); mY = me->y(); - //Emit open dialog signal if mouse is still over button + // Emit open dialog signal if mouse is still over button if( mY < this->height() && mY > 0 && mX < this->width() && mX > 0 ) emit OpenDialog(); bPressed = false; repaint(); } + +/** + * Mouse move event. + * + * @param QMouseEvent me + */ void CustomButton::mouseMoveEvent(QMouseEvent* me) { mX = me->x(); mY = me->y(); - //Is mouse moved outside button? + // Is mouse moved outside button? if( mY > this->height() || mY < 0 || mX > this->width() || mX < 0 ) bPressed = false; else