[vlc-devel] commit: Qt: more details on the icon view. (Ludovic Fauvet )
git version control
git at videolan.org
Tue Jan 26 15:51:06 CET 2010
vlc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Tue Jan 26 14:26:46 2010 +0100| [bf7822fe956f24303563b040156f6c4abaf75df6] | committer: Jean-Baptiste Kempf
Qt: more details on the icon view.
Add album name and break long lines.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf7822fe956f24303563b040156f6c4abaf75df6
---
modules/gui/qt4/components/playlist/icon_view.cpp | 25 ++++++++++++++++----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp
index da4bf85..f07b25f 100644
--- a/modules/gui/qt4/components/playlist/icon_view.cpp
+++ b/modules/gui/qt4/components/playlist/icon_view.cpp
@@ -25,16 +25,17 @@
#include "components/playlist/playlist_model.hpp"
#include "input_manager.hpp"
+#include <QApplication>
#include <QPainter>
#include <QRect>
#include <QStyleOptionViewItem>
-#include <QApplication>
+#include <QFontMetrics>
#include "assert.h"
#define RECT_SIZE 100
#define ART_SIZE 64
-#define OFFSET (100-64)/2
+#define OFFSET (RECT_SIZE-64)/2
#define ITEMS_SPACING 10
#define ART_RADIUS 5
@@ -77,12 +78,26 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
painter->drawPixmap( artRect, pix );
painter->setClipping( false );
- painter->setFont( QFont( "Verdana", 7 ) );
+ QColor text = qApp->palette().text().color();
+ QString title = qfu( input_item_GetTitleFbName( currentItem->inputItem() ) );
+ QString artist = qfu( input_item_GetArtist( currentItem->inputItem() ) );
+
+ painter->setPen( text );
+ painter->setFont( QFont( "Verdana", 7, QFont::Bold ) );
+ QFontMetrics fm = painter->fontMetrics();
+ QRect titleRect = option.rect.adjusted( 1, ART_SIZE + 4, 0, -1 );
+ titleRect.setHeight( fm.height() + 2 );
- QRect textRect = option.rect.adjusted( 1, ART_SIZE + 2, -1, -1 );
- painter->drawText( textRect, qfu( input_item_GetTitleFbName( currentItem->inputItem() ) ),
+ painter->drawText( titleRect, fm.elidedText( title, Qt::ElideRight, titleRect.width() ),
QTextOption( Qt::AlignCenter ) );
+ painter->setPen( text.lighter( 240 ) );
+ painter->setFont( QFont( "Verdana", 7 ) );
+ fm = painter->fontMetrics();
+ QRect artistRect = option.rect.adjusted( 1, ART_SIZE + 4 + titleRect.height(), -1, -1 );
+
+ painter->drawText( artistRect, fm.elidedText( artist, Qt::ElideRight, artistRect.width() ),
+ QTextOption( Qt::AlignCenter ) );
}
QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
More information about the vlc-devel
mailing list