From: Manuel Nickschas Date: Sat, 27 Sep 2008 11:39:56 +0000 (+0200) Subject: Provide a fallback in case XDG_DATA_DIRS is not set X-Git-Tag: 0.3.1~237 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=57d9abdd9cb8506a12f4a2dbb96fd8d840c380c8;hp=1514aaae673660c7a3e2a82545b8c3947ea3f9b7 Provide a fallback in case XDG_DATA_DIRS is not set This works only on UNIX. On other platforms, you probably should build-in the icons anyway, or tell me if there are (standard locations for) icon themes at all... --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e28d90fb..8462db8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) - cmake_policy(SET CMP0005 NEW) endif(COMMAND cmake_policy) # Use our own (well, and KDE's) version of some modules @@ -61,8 +60,6 @@ set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps) set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons) set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications) -add_definitions(-DPREFIX=${CMAKE_INSTALL_PREFIX}) - # Enable various flags on gcc if(CMAKE_COMPILER_IS_GNUCXX) # Let's just hope that all gccs support these options and skip the tests... diff --git a/src/uisupport/iconloader.cpp b/src/uisupport/iconloader.cpp index 688d0b11..d5dbade0 100644 --- a/src/uisupport/iconloader.cpp +++ b/src/uisupport/iconloader.cpp @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include #include #include #include @@ -50,7 +51,19 @@ void IconLoader::setTheme(const QString &theme) { _themedIconDirNames.clear(); _plainIconDirNames.clear(); QString path; - QStringList dataDirNames = QString(qgetenv("XDG_DATA_DIRS")).split(':'); + QStringList dataDirNames = QString(qgetenv("XDG_DATA_DIRS")).split(':', QString::SkipEmptyParts); + +// Provide a fallback +# ifdef Q_OS_UNIX + if(dataDirNames.isEmpty()) dataDirNames.append("/usr/share"); + // on UNIX, we always check our install prefix + QString appDir = QCoreApplication::applicationDirPath(); + int binpos = appDir.lastIndexOf("/bin"); + if(binpos >= 0) { + appDir.replace(binpos, 4, "/share"); + if(!dataDirNames.contains(appDir)) dataDirNames.append(appDir); + } +# endif // System theme in $data/icons/$theme foreach(QString dir, dataDirNames) {