1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 03:10:12 +02:00

* Added setOpacity method to ClickableLabel.

This commit is contained in:
Christian Muehlhaeuser
2014-08-20 08:22:42 +02:00
parent acbb8c5df8
commit 9c01ae995f
2 changed files with 11 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ ClickableLabel::ClickableLabel( QWidget* parent )
: QLabel( parent ) : QLabel( parent )
, m_pressed( false ) , m_pressed( false )
, m_moved( false ) , m_moved( false )
, m_opacity( 0.5 )
{ {
setCursor( Qt::PointingHandCursor ); setCursor( Qt::PointingHandCursor );
} }
@@ -38,6 +39,12 @@ ClickableLabel::~ClickableLabel()
} }
void ClickableLabel::setOpacity( float opacity )
{
m_opacity = opacity;
}
void void
ClickableLabel::mousePressEvent( QMouseEvent* event ) ClickableLabel::mousePressEvent( QMouseEvent* event )
{ {
@@ -85,6 +92,6 @@ void
ClickableLabel::paintEvent( QPaintEvent* event ) ClickableLabel::paintEvent( QPaintEvent* event )
{ {
QPainter painter( this ); QPainter painter( this );
painter.setOpacity( 0.5 ); painter.setOpacity( m_opacity );
painter.drawText( contentsRect(), text() ); painter.drawText( contentsRect(), text() );
} }

View File

@@ -35,6 +35,8 @@ public:
ClickableLabel( QWidget* parent ); ClickableLabel( QWidget* parent );
virtual ~ClickableLabel(); virtual ~ClickableLabel();
void setOpacity( float opacity );
signals: signals:
void clicked(); void clicked();
void resized( const QPoint& delta ); void resized( const QPoint& delta );
@@ -51,6 +53,7 @@ private:
bool m_pressed; bool m_pressed;
bool m_moved; bool m_moved;
QTime m_time; QTime m_time;
float m_opacity;
}; };
#endif // CLICKABLELABEL_H #endif // CLICKABLELABEL_H