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

Christopher Kankare christopher.kankare at gmail.com
Tue Nov 24 04:57:32 CET 2009


 Some code to load icons on runtime rather than include them in the executable, so now people can change icons to match their themes.

---
 modules/gui/qt4/main_interface.cpp |   17 +++++++++++++----
 modules/gui/qt4/qt4.cpp            |   16 ++++++++++++----
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index a967e06..f1eb54c 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1109,11 +1109,20 @@ void MainInterface::showCryptedLabel( bool b_show )
  **/
 void MainInterface::createSystray()
 {
-    QIcon iconVLC;
-    if( QDate::currentDate().dayOfYear() >= 354 )
-        iconVLC =  QIcon( ":/logo/vlc128-christmas.png" );
+    char *psz_icon = NULL;
+    if( QDate::currentDate().dayOfYear() >= 352 ) /* One Week before Xmas */
+    {
+        if( asprintf( &psz_icon, "%s" DIR_SEP "vlc128x128-christmas.png" , config_GetDataDir() ) == -1 )
+            psz_icon = NULL;
+    }
     else
-        iconVLC =  QIcon( ":/logo/vlc128.png" );
+    {
+	if( asprintf( &psz_icon, "%s" DIR_SEP "vlc128x128.png" , config_GetDataDir() ) == -1 )
+            psz_icon = NULL;
+    }
+
+    iconVLC = ( QIcon( psz_icon ) );
+    free( psz_icon );
     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..4eb3c4d 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -47,8 +47,6 @@
  #include <X11/Xlib.h>
 #endif
 
-#include "../../../share/vlc32x32.xpm"
-#include "../../../share/vlc32x32-christmas.xpm"
 #include <vlc_plugin.h>
 
 #ifdef WIN32
@@ -383,10 +381,20 @@ static void *Thread( void *obj )
             QSettings::UserScope, "vlc", "vlc-qt-interface" );
 
     /* Icon setting */
+    char *psz_icon = NULL;
     if( QDate::currentDate().dayOfYear() >= 352 ) /* One Week before Xmas */
-        app.setWindowIcon( QIcon(vlc_christmas_xpm) );
+    {
+        if( asprintf( &psz_icon, "%s" DIR_SEP "vlc32x32-christmas.png" , config_GetDataDir() ) == -1 )
+            psz_icon = NULL;
+    }
     else
-        app.setWindowIcon( QIcon(vlc_xpm) );
+    {
+	if( asprintf( &psz_icon, "%s" DIR_SEP "vlc32x32.png" , config_GetDataDir() ) == -1 )
+            psz_icon = NULL;
+    }
+
+    app.setWindowIcon( QIcon( psz_icon ) );
+    free( psz_icon );
 
     /* Initialize timers and the Dialog Provider */
     DialogsProvider::getInstance( p_intf );
-- 
1.6.3.3




More information about the vlc-devel mailing list