Added option for adding extra path for icon themes loading.

This commit is contained in:
Martin Rotter 2013-06-13 20:11:16 +02:00
parent d5157c5102
commit 6fd589aa7d
7 changed files with 30 additions and 11 deletions

View File

@ -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") 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. # Check for C++ 11 features availability.
# See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake # See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
@ -153,6 +156,7 @@ set(APP_SOURCES
# GUI sources. # GUI sources.
src/gui/formmain.cpp src/gui/formmain.cpp
src/gui/systemtrayicon.cpp src/gui/systemtrayicon.cpp
src/gui/themefactory.cpp
# CORE sources. # CORE sources.
src/core/debugging.cpp src/core/debugging.cpp
@ -173,8 +177,7 @@ set(APP_HEADERS
# GUI headers. # GUI headers.
src/gui/formmain.h src/gui/formmain.h
src/gui/systemtrayicon.cpp src/gui/systemtrayicon.h
src/gui/themefactory.cpp
# CORE headers. # CORE headers.
) )

View File

@ -6,8 +6,6 @@
class Settings : public QSettings { class Settings : public QSettings {
private: private:
// We use QPointer instead of QScopedPointer
// because of late s_instance usage in QApplication::aboutToQuit() listeners.
static QPointer<Settings> s_instance; static QPointer<Settings> s_instance;
public: public:
@ -27,12 +25,12 @@ class Settings : public QSettings {
const QString &key, const QString &key,
const QVariant &value); const QVariant &value);
// Synchronises settings.
QSettings::Status checkSettings();
protected: protected:
// Creates settings file in correct location. // Creates settings file in correct location.
static QSettings::Status setupSettings(); static QSettings::Status setupSettings();
// Synchronises settings.
QSettings::Status checkSettings();
}; };
#endif // SETTINGS_H #endif // SETTINGS_H

View File

@ -1,4 +1,4 @@
#include "systemtrayicon.h" #include "gui/systemtrayicon.h"
SystemTrayIcon::SystemTrayIcon(QObject *parent) : QSystemTrayIcon(parent) { SystemTrayIcon::SystemTrayIcon(QObject *parent) : QSystemTrayIcon(parent) {

View File

@ -3,8 +3,8 @@
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
class SystemTrayIcon : public QSystemTrayIcon
{ class SystemTrayIcon : public QSystemTrayIcon {
Q_OBJECT Q_OBJECT
public: public:
explicit SystemTrayIcon(QObject *parent = 0); explicit SystemTrayIcon(QObject *parent = 0);

View File

@ -1,5 +1,16 @@
#include "themefactory.h" #include <QIcon>
#include <QApplication>
#include "gui/themefactory.h"
#include "core/defs.h"
ThemeFactory::ThemeFactory() { ThemeFactory::ThemeFactory() {
} }
void ThemeFactory::setupSearchPaths() {
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << APP_THEME_PATH);
qDebug("Available icon theme paths: %s.",
qPrintable(QIcon::themeSearchPaths().join(", ")));
}

View File

@ -5,6 +5,9 @@
class ThemeFactory { class ThemeFactory {
private: private:
ThemeFactory(); ThemeFactory();
public:
static void setupSearchPaths();
}; };
#endif // THEMEFACTORY_H #endif // THEMEFACTORY_H

View File

@ -6,6 +6,7 @@
#include "core/defs.h" #include "core/defs.h"
#include "core/debugging.h" #include "core/debugging.h"
#include "core/settings.h" #include "core/settings.h"
#include "gui/themefactory.h"
#include "gui/formmain.h" #include "gui/formmain.h"
#include "qtsingleapplication/qtsingleapplication.h" #include "qtsingleapplication/qtsingleapplication.h"
@ -51,6 +52,9 @@ int main(int argc, char *argv[]) {
QApplication::addLibraryPath(APP_PLUGIN_PATH); QApplication::addLibraryPath(APP_PLUGIN_PATH);
#endif #endif
// Add an extra path for non-system icon themes.
ThemeFactory::setupSearchPaths();
// These settings needs to be set before any QSettings object. // These settings needs to be set before any QSettings object.
QtSingleApplication::setApplicationName(APP_NAME); QtSingleApplication::setApplicationName(APP_NAME);
QtSingleApplication::setApplicationVersion(APP_VERSION); QtSingleApplication::setApplicationVersion(APP_VERSION);