From 6fd589aa7da33913642c7f2ec3a648259787b699 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 13 Jun 2013 20:11:16 +0200 Subject: [PATCH] Added option for adding extra path for icon themes loading. --- CMakeLists.txt | 7 +++++-- src/core/settings.h | 8 +++----- src/gui/systemtrayicon.cpp | 2 +- src/gui/systemtrayicon.h | 4 ++-- src/gui/themefactory.cpp | 13 ++++++++++++- src/gui/themefactory.h | 3 +++ src/main.cpp | 4 ++++ 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 831abd5fe..a790893c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,9 @@ set(CMAKE_VERBOSE_MAKEFILE ON) endif(CMAKE_BUILD_TYPE STREQUAL "release" OR CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RELEASE") +# Force Qt to use string builders. +add_definitions(-DQT_USE_QSTRINGBUILDER) + # Check for C++ 11 features availability. # See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") @@ -153,6 +156,7 @@ set(APP_SOURCES # GUI sources. src/gui/formmain.cpp src/gui/systemtrayicon.cpp + src/gui/themefactory.cpp # CORE sources. src/core/debugging.cpp @@ -173,8 +177,7 @@ set(APP_HEADERS # GUI headers. src/gui/formmain.h - src/gui/systemtrayicon.cpp - src/gui/themefactory.cpp + src/gui/systemtrayicon.h # CORE headers. ) diff --git a/src/core/settings.h b/src/core/settings.h index 0fe1e204a..52243ab65 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -6,8 +6,6 @@ class Settings : public QSettings { private: - // We use QPointer instead of QScopedPointer - // because of late s_instance usage in QApplication::aboutToQuit() listeners. static QPointer s_instance; public: @@ -27,12 +25,12 @@ class Settings : public QSettings { const QString &key, const QVariant &value); - // Synchronises settings. - QSettings::Status checkSettings(); - protected: // Creates settings file in correct location. static QSettings::Status setupSettings(); + + // Synchronises settings. + QSettings::Status checkSettings(); }; #endif // SETTINGS_H diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 3b7579a09..409929aa2 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -1,4 +1,4 @@ -#include "systemtrayicon.h" +#include "gui/systemtrayicon.h" SystemTrayIcon::SystemTrayIcon(QObject *parent) : QSystemTrayIcon(parent) { diff --git a/src/gui/systemtrayicon.h b/src/gui/systemtrayicon.h index e6c96ab1e..d070c308d 100644 --- a/src/gui/systemtrayicon.h +++ b/src/gui/systemtrayicon.h @@ -3,8 +3,8 @@ #include -class SystemTrayIcon : public QSystemTrayIcon -{ + +class SystemTrayIcon : public QSystemTrayIcon { Q_OBJECT public: explicit SystemTrayIcon(QObject *parent = 0); diff --git a/src/gui/themefactory.cpp b/src/gui/themefactory.cpp index 69b84ab15..83b890143 100644 --- a/src/gui/themefactory.cpp +++ b/src/gui/themefactory.cpp @@ -1,5 +1,16 @@ -#include "themefactory.h" +#include +#include + +#include "gui/themefactory.h" +#include "core/defs.h" ThemeFactory::ThemeFactory() { } + +void ThemeFactory::setupSearchPaths() { + QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << APP_THEME_PATH); + + qDebug("Available icon theme paths: %s.", + qPrintable(QIcon::themeSearchPaths().join(", "))); +} diff --git a/src/gui/themefactory.h b/src/gui/themefactory.h index 5895f4c09..db74618d3 100644 --- a/src/gui/themefactory.h +++ b/src/gui/themefactory.h @@ -5,6 +5,9 @@ class ThemeFactory { private: ThemeFactory(); + + public: + static void setupSearchPaths(); }; #endif // THEMEFACTORY_H diff --git a/src/main.cpp b/src/main.cpp index 328eb816c..42cb02682 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include "core/defs.h" #include "core/debugging.h" #include "core/settings.h" +#include "gui/themefactory.h" #include "gui/formmain.h" #include "qtsingleapplication/qtsingleapplication.h" @@ -51,6 +52,9 @@ int main(int argc, char *argv[]) { QApplication::addLibraryPath(APP_PLUGIN_PATH); #endif + // Add an extra path for non-system icon themes. + ThemeFactory::setupSearchPaths(); + // These settings needs to be set before any QSettings object. QtSingleApplication::setApplicationName(APP_NAME); QtSingleApplication::setApplicationVersion(APP_VERSION);