Commit 17786c59 authored by jpd's avatar jpd
Browse files

Qt4: fix build with Qt < 4.5

parent 75dcb251
......@@ -147,21 +147,32 @@ void SearchLineEdit::updateText( const QString& text )
}
QVLCIconLabel::QVLCIconLabel( const QIcon& i, QWidget *p )
: QLabel( p ), icon( i )
: QLabel( p ), icon( i ), iconMode( QIcon::Normal )
{
setPixmap( icon.pixmap( pixmapSize( QIcon::Normal ), QIcon::Normal ) );
updatePixmap();
}
void QVLCIconLabel::setIcon( const QIcon& i )
{ icon = i; }
{
icon = i;
updatePixmap();
}
void QVLCIconLabel::resizeEvent( QResizeEvent * event )
{
updatePixmap();
}
void QVLCIconLabel::enterEvent( QEvent * )
{
setPixmap( icon.pixmap( pixmapSize( QIcon::Active ), QIcon::Active ) );
iconMode = QIcon::Active;
updatePixmap();
}
void QVLCIconLabel::leaveEvent( QEvent * )
{
setPixmap( icon.pixmap( pixmapSize( QIcon::Normal ), QIcon::Normal ) );
iconMode = QIcon::Normal;
updatePixmap();
}
void QVLCIconLabel::mouseReleaseEvent( QMouseEvent * )
......@@ -169,11 +180,9 @@ void QVLCIconLabel::mouseReleaseEvent( QMouseEvent * )
emit clicked();
}
QSize QVLCIconLabel::pixmapSize( QIcon::Mode mode, QIcon::State state )
void QVLCIconLabel::updatePixmap()
{
QList<QSize> sizes = icon.availableSizes( mode, state );
if( sizes.isEmpty() ) sizes = icon.availableSizes();
return ( !sizes.isEmpty() ? sizes[0] : QSize() );
setPixmap( icon.pixmap( size(), iconMode ) );
}
/***************************************************************************
......
......@@ -88,9 +88,11 @@ protected:
virtual void enterEvent( QEvent * );
virtual void leaveEvent( QEvent * );
virtual void mouseReleaseEvent( QMouseEvent * );
virtual void resizeEvent( QResizeEvent * );
private:
inline QSize pixmapSize( QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off );
inline void updatePixmap( );
QIcon icon;
QIcon::Mode iconMode;
};
/*****************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment