[vlc-devel] [PATCH] Added possibilty to resize playlist icons in icon-view.

VlcVelope 1034-135 at online.de
Sun Apr 29 20:25:30 CEST 2012


Using <Ctrl>+<MouseWheel> resizes the icons if the playlist is in icon view.

Regards,
VlcVelope
---
 modules/gui/qt4/components/playlist/views.cpp |   24 +++++++++++++++++++++++-
 modules/gui/qt4/components/playlist/views.hpp |    1 +
 2 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/views.cpp b/modules/gui/qt4/components/playlist/views.cpp
index 3e6794c..fdefa41 100644
--- a/modules/gui/qt4/components/playlist/views.cpp
+++ b/modules/gui/qt4/components/playlist/views.cpp
@@ -36,7 +36,7 @@
 #include "assert.h"
 
 /* ICON_SCALER comes currently from harrison-stetson method, so good value */
-#define ICON_SCALER         16
+int ICON_SCALER           = 16;
 #define ART_RADIUS          5
 #define SPACER              5
 
@@ -313,6 +313,28 @@ void PlIconView::dragMoveEvent ( QDragMoveEvent * event )
     QAbstractItemView::dragMoveEvent( event );
 }
 
+void PlIconView::wheelEvent ( QWheelEvent * e )
+{
+    if( e->modifiers() == Qt::ControlModifier )
+    {
+        int s = e->delta() / 8 / 15;
+        ICON_SCALER += s * 2;
+        if( ICON_SCALER < 8 )
+            ICON_SCALER = 8;
+        QFont f( currentIndex().data( Qt::FontRole ).value<QFont>() );
+        f.setBold( true );
+        QFontMetrics fm( f );
+        int textHeight = fm.height();
+        int averagewidth = fm.averageCharWidth();
+        QSize sz ( averagewidth * ICON_SCALER + 4 * SPACER,
+                averagewidth * ICON_SCALER + 4 * SPACER + 2 * textHeight + 1 );
+        setIconSize( sz );
+        e->ignore();
+        return;
+    }
+    QListView::wheelEvent( e );
+    //e->ignore();
+}
 PlListView::PlListView( PLModel *, QWidget *parent ) : QListView( parent )
 {
     setViewMode( QListView::ListMode );
diff --git a/modules/gui/qt4/components/playlist/views.hpp b/modules/gui/qt4/components/playlist/views.hpp
index 74abb1a..0cc1a8b 100644
--- a/modules/gui/qt4/components/playlist/views.hpp
+++ b/modules/gui/qt4/components/playlist/views.hpp
@@ -71,6 +71,7 @@ public:
 protected:
     virtual void startDrag ( Qt::DropActions supportedActions );
     virtual void dragMoveEvent ( QDragMoveEvent * event );
+    virtual void wheelEvent ( QWheelEvent * event );
 };
 
 class PlListView : public QListView
-- 
1.7.5.4




More information about the vlc-devel mailing list