[vlc-devel] commit: Qt4: fix build with Qt < 4.5 (Jakob Leben )
git version control
git at videolan.org
Mon Nov 9 23:24:40 CET 2009
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Mon Nov 9 23:23:15 2009 +0100| [17786c59b1dc0f2b965b79721e0b4ec49c12612a] | committer: Jakob Leben
Qt4: fix build with Qt < 4.5
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=17786c59b1dc0f2b965b79721e0b4ec49c12612a
---
modules/gui/qt4/util/customwidgets.cpp | 27 ++++++++++++++++++---------
modules/gui/qt4/util/customwidgets.hpp | 4 +++-
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index e90f2b0..2e50199 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -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 ) );
}
/***************************************************************************
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index fce9359..690e1f2 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -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;
};
/*****************************************************************
More information about the vlc-devel
mailing list