[vlc-devel] [PATCH] Load icons on runtime

Christopher Kankare christopher.kankare at gmail.com
Sun Nov 29 21:14:48 CET 2009


So, here is the patch. Hopefully it's good enough..

---
 modules/gui/qt4/main_interface.cpp |   17 ++++++++++++++++-
 modules/gui/qt4/qt4.cpp            |   18 ++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/main_interface.cpp 
b/modules/gui/qt4/main_interface.cpp
index a967e06..f07193d 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -57,6 +57,7 @@
 #include <QLabel>
 #include <QGroupBox>
 #include <QPushButton>
+#include <QFile>
 
 #ifdef WIN32
  #include <vlc_windows_interfaces.h>
@@ -1113,7 +1114,21 @@ void MainInterface::createSystray()
     if( QDate::currentDate().dayOfYear() >= 354 )
         iconVLC =  QIcon( ":/logo/vlc128-christmas.png" );
     else
-        iconVLC =  QIcon( ":/logo/vlc128.png" );
+    {
+        #ifdef WIN32
+            iconVLC =  QIcon( ":/logo/vlc128.png" );
+        #else
+            char *psz_icon = NULL;
+        if (asprintf( &psz_icon, "%s" DIR_SEP "vlc128x128.png" , 
config_GetUserDir( VLC_DATA_DIR ) ) == -1)
+                psz_icon = NULL;
+            if (QFile::exists( psz_icon ) )
+                iconVLC =  QIcon( psz_icon );
+            else
+                iconVLC =  QIcon( ":/logo/vlc128.png" );
+            free( psz_icon );
+        #endif
+    }
+
     sysTray = new QSystemTrayIcon( iconVLC, this );
     sysTray->setToolTip( qtr( "VLC media player" ));
 
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index f42f87d..f4276c6 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -33,6 +33,7 @@
 #include <QMutex>
 #include <QMutexLocker>
 #include <QWaitCondition>
+#include <QFile>
 
 #include "qt4.hpp"
 
@@ -384,9 +385,22 @@ static void *Thread( void *obj )
 
     /* Icon setting */
     if( QDate::currentDate().dayOfYear() >= 352 ) /* One Week before 
Xmas */
-        app.setWindowIcon( QIcon(vlc_christmas_xpm) );
+        app.setWindowIcon( QIcon( vlc_christmas_xpm ) );
     else
-        app.setWindowIcon( QIcon(vlc_xpm) );
+    {
+        #ifdef WIN32
+            app.setWindowIcon( QIcon( vlc_xpm ) );
+        #else
+            char *psz_icon = NULL;
+        if (asprintf( &psz_icon, "%s" DIR_SEP "vlc32x32.png" , 
config_GetUserDir( VLC_DATA_DIR ) ) == -1)
+                psz_icon = NULL;
+            if (QFile::exists( psz_icon ) )
+            app.setWindowIcon( QIcon( psz_icon ) );
+            else
+                app.setWindowIcon( QIcon( vlc_xpm ) );
+            free( psz_icon );
+        #endif       
+    }
 
     /* Initialize timers and the Dialog Provider */
     DialogsProvider::getInstance( p_intf );
-- 

Christopher Kankare



More information about the vlc-devel mailing list