File indexing completed on 2024-05-19 05:38:06

0001 /*
0002     SPDX-FileCopyrightText: 2019 Benjamin Port <benjamin.port@enioka.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <QApplication>
0008 #include <QDebug>
0009 #include <QObject>
0010 
0011 #include <KBuildSycocaProgressDialog>
0012 #include <KIconTheme>
0013 #include <KSharedDataCache>
0014 
0015 #include "iconssettings.h"
0016 
0017 IconsSettings::IconsSettings(QObject *parent)
0018     : IconsSettingsBase(parent)
0019     , m_themeDirty(false)
0020 {
0021     connect(this, &IconsSettings::configChanged, this, &IconsSettings::updateIconTheme);
0022     connect(this, &IconsSettings::ThemeChanged, this, &IconsSettings::updateThemeDirty);
0023 }
0024 
0025 IconsSettings::~IconsSettings()
0026 {
0027 }
0028 
0029 void IconsSettings::updateThemeDirty()
0030 {
0031     m_themeDirty = theme() != KIconTheme::current();
0032 }
0033 
0034 void IconsSettings::updateIconTheme()
0035 {
0036     if (m_themeDirty) {
0037         KIconTheme::reconfigure();
0038 
0039         KSharedDataCache::deleteCache(QStringLiteral("icon-cache"));
0040 
0041         for (int i = 0; i < KIconLoader::LastGroup; i++) {
0042             KIconLoader::emitChange(KIconLoader::Group(i));
0043         }
0044 
0045         KBuildSycocaProgressDialog::rebuildKSycoca(QApplication::activeWindow());
0046     }
0047 }