31 #include "miscellaneous/iconfactory.h"
33 #include "miscellaneous/application.h"
34 #include "miscellaneous/settings.h"
39 QPointer<IconFactory> IconFactory::s_instance;
41 IconFactory::IconFactory(QObject *parent) : QObject(parent) {
44 IconFactory::~IconFactory() {
45 qDebug(
"Destroying IconFactory instance.");
49 if (s_instance.isNull()) {
57 QIcon::setThemeSearchPaths(QStringList() << APP_THEME_PATH);
58 qDebug(
"Available icon theme paths: %s.",
59 qPrintable(QIcon::themeSearchPaths().replaceInStrings(QRegExp(
"^|$"),
66 qApp->settings()->setValue(APP_CFG_GUI,
"icon_theme", theme_name);
71 QString theme_name_from_settings = qApp->settings()->value(APP_CFG_GUI,
73 APP_THEME_DEFAULT).toString();
75 if (m_currentIconTheme == theme_name_from_settings) {
76 qDebug(
"Icon theme '%s' already loaded.",
77 qPrintable(theme_name_from_settings));
82 qDebug(
"Installed icon themes are: %s.",
83 qPrintable(QStringList(installed_themes).replaceInStrings(QRegExp(
"^|$"),
86 if (installed_themes.contains(theme_name_from_settings)) {
88 qDebug(
"Loading icon theme '%s'.", qPrintable(theme_name_from_settings));
89 m_currentIconTheme = theme_name_from_settings;
94 qDebug(
"Icon theme '%s' cannot be loaded because it is not installed. "
95 "No icon theme is loaded now.",
96 qPrintable(theme_name_from_settings));
97 m_currentIconTheme = APP_NO_THEME;
102 QStringList icon_theme_names;
103 icon_theme_names << APP_NO_THEME;
106 QStringList icon_themes_paths = QIcon::themeSearchPaths();
107 icon_themes_paths.removeDuplicates();
109 foreach (
const QString &icon_path, icon_themes_paths) {
110 QDir icon_dir(icon_path);
113 foreach (
const QString &icon_theme_path, icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
114 QDir::Readable | QDir::CaseSensitive |
117 icon_theme_names << icon_theme_path;
121 icon_theme_names.removeDuplicates();
122 return icon_theme_names;
void setCurrentIconTheme(const QString &theme_name)
Sets icon theme with given name as the active one and loads it.
void setupSearchPaths()
Adds custom application path to be search for icons.
void loadCurrentIconTheme()
Loads name of selected icon theme (from settings) for the application and activates it...
Icon theme manipulator and provider.
QStringList installedIconThemes() const
Access to list of icon themes.
static IconFactory * instance()
Singleton getter.