1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/***************************************************************************
* copyright : (C) 2006 by Pascal Brachet *
* *
* 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 <QApplication>
#include "playerbutton.h"
PlayerButton::PlayerButton( QWidget *parent )
: QLabel( parent )
{
state = true;
}
void PlayerButton::setImages( QString name )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
if (qApp->devicePixelRatio()==2)
{
this->pixEnabled.load(":/images/"+name+"_enabled@2x.png");
this->pixEnabled.setDevicePixelRatio(qApp->devicePixelRatio());
this->pixHover.load(":/images/"+name+"_enabled@2x.png");
this->pixHover.setDevicePixelRatio(qApp->devicePixelRatio());
this->pixDisabled.load(":/images/"+name+"_disabled@2x.png");
this->pixDisabled.setDevicePixelRatio(qApp->devicePixelRatio());
}
else
{
this->pixEnabled.load(":/images/"+name+"_enabled.png");
this->pixHover.load(":/images/"+name+"_enabled.png");
this->pixDisabled.load(":/images/"+name+"_disabled.png");
}
#else
this->pixEnabled.load(":/images/"+name+"_enabled.png");
this->pixHover.load(":/images/"+name+"_enabled.png");
this->pixDisabled.load(":/images/"+name+"_disabled.png");
#endif
this->setPixmap(this->pixEnabled);
}
void PlayerButton::setEnabled( bool enabled )
{
state = enabled;
this->setPixmap( enabled ? this->pixEnabled : this->pixDisabled );
}
void PlayerButton::mouseReleaseEvent( QMouseEvent * e )
{
emit clicked();
}
void PlayerButton::enterEvent( QEvent * e )
{
//if (state) this->setPixmap( pixHover );
}
void PlayerButton::leaveEvent( QEvent *e )
{
//setEnabled( state );
}
|