[vlc-devel] [PATCH 2/2] Qt4: add a type-based icon to the recents menu

Ludovic Fauvet etix at videolan.org
Mon Nov 28 12:16:46 CET 2011


---
 modules/gui/qt4/input_manager.cpp |   21 +++++++++++++++++++++
 modules/gui/qt4/input_manager.hpp |    2 ++
 modules/gui/qt4/menus.cpp         |    4 +++-
 3 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 1146478..69c1803 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -38,6 +38,7 @@
 #include <vlc_aout_intf.h>
 
 #include <QApplication>
+#include <QIcon>
 
 #include <assert.h>
 
@@ -937,6 +938,26 @@ void InputManager::AtoBLoop( float, int64_t i_time, int )
     }
 }
 
+const QIcon InputManager::inputTypeIcon( const QString &mrl )
+{
+    switch( input_item_GuessType( qtu( mrl ) ) )
+    {
+        case ITEM_TYPE_FILE:
+            return QIcon( ":/type/file-asym" );
+        case ITEM_TYPE_DIRECTORY:
+            return QIcon( ":/type/folder-grey" );
+        case ITEM_TYPE_NET:
+            return QIcon( ":/type/network" );
+        case ITEM_TYPE_CARD:
+            return QIcon( ":/type/capture-card" );
+        case ITEM_TYPE_CDDA:
+        case ITEM_TYPE_DISC:
+            return QIcon( ":/type/disc" );
+        default:
+            return QIcon();
+    }
+}
+
 /**********************************************************************
  * MainInputManager implementation. Wrap an input manager and
  * take care of updating the main playlist input.
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index a03801a..cd1e740 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -37,6 +37,7 @@
 #include <QObject>
 #include <QEvent>
 
+class QIcon;
 
 enum {
     PositionUpdate_Type = QEvent::User + IMEventType + 1,
@@ -143,6 +144,7 @@ public:
 
     QString getName() { return oldName; }
     static const QString decodeArtURL( input_item_t *p_item );
+    static const QIcon inputTypeIcon( const QString &mrl );
 
 private:
     intf_thread_t  *p_intf;
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index f85e515..5509ad9 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -38,6 +38,7 @@
 #include <vlc_intf_strings.h>
 #include <vlc_vout.h>                             /* vout_thread_t */
 #include <vlc_aout.h>                             /* audio_output_t */
+#include <vlc_input_item.h>
 
 #include "menus.hpp"
 
@@ -1529,7 +1530,8 @@ void QVLCMenu::updateRecents( intf_thread_t *p_intf )
                                                           Qt::ElideLeft, 400 ),
                         rmrl->signalMapper, SLOT( map() ),
                         i < 9 ? QString( "Ctrl+%1" ).arg( i + 1 ) : "" );
-                rmrl->signalMapper->setMapping( action, l.at( i ) );
+                action->setIcon( InputManager::inputTypeIcon( mrl ) );
+                rmrl->signalMapper->setMapping( action, mrl );
             }
 
             recentsMenu->addSeparator();
-- 
1.7.7.4




More information about the vlc-devel mailing list