diff --git a/kcms/icons/iconsizecategorymodel.h b/kcms/icons/iconsizecategorymodel.h --- a/kcms/icons/iconsizecategorymodel.h +++ b/kcms/icons/iconsizecategorymodel.h @@ -25,6 +25,7 @@ QString configKey; QString display; QString configSection; + int kIconloaderGroup; }; Q_DECLARE_TYPEINFO(IconSizeCategoryModelData, Q_MOVABLE_TYPE); @@ -39,7 +40,8 @@ enum Roles { ConfigKeyRole = Qt::UserRole + 1, - ConfigSectionRole + ConfigSectionRole, + KIconLoaderGroupRole, }; int rowCount(const QModelIndex &parent = QModelIndex()) const override; diff --git a/kcms/icons/iconsizecategorymodel.cpp b/kcms/icons/iconsizecategorymodel.cpp --- a/kcms/icons/iconsizecategorymodel.cpp +++ b/kcms/icons/iconsizecategorymodel.cpp @@ -18,16 +18,17 @@ #include "iconsizecategorymodel.h" #include +#include IconSizeCategoryModel::IconSizeCategoryModel(QObject *parent) : QAbstractListModel(parent) , m_data({ - {QStringLiteral("desktopSize"), I18N_NOOP("Desktop"), QStringLiteral("Desktop")}, - {QStringLiteral("toolbarSize"), I18N_NOOP("Toolbar"), QStringLiteral("Toolbar")}, - {QStringLiteral("mainToolbarSize"), I18N_NOOP("Main Toolbar"), QStringLiteral("MainToolbar")}, - {QStringLiteral("smallSize"), I18N_NOOP("Small Icons"), QStringLiteral("Small")}, - {QStringLiteral("panelSize"), I18N_NOOP("Panel"), QStringLiteral("Panel")}, - {QStringLiteral("dialogSize"), I18N_NOOP("Dialogs"), QStringLiteral("Dialog")} + {QStringLiteral("desktopSize"), I18N_NOOP("Desktop"), QStringLiteral("Desktop"), KIconLoader::Desktop}, + {QStringLiteral("toolbarSize"), I18N_NOOP("Toolbar"), QStringLiteral("Toolbar"), KIconLoader::Toolbar}, + {QStringLiteral("mainToolbarSize"), I18N_NOOP("Main Toolbar"), QStringLiteral("MainToolbar"), KIconLoader::MainToolbar}, + {QStringLiteral("smallSize"), I18N_NOOP("Small Icons"), QStringLiteral("Small"), KIconLoader::Small}, + {QStringLiteral("panelSize"), I18N_NOOP("Panel"), QStringLiteral("Panel"), KIconLoader::Panel}, + {QStringLiteral("dialogSize"), I18N_NOOP("Dialogs"), QStringLiteral("Dialog"), KIconLoader::Dialog} }) { } @@ -58,6 +59,8 @@ return item.configKey; case ConfigSectionRole: return item.configSection; + case KIconLoaderGroupRole: + return item.kIconloaderGroup; } return QVariant(); @@ -68,5 +71,6 @@ QHash roleNames = QAbstractListModel::roleNames(); roleNames[ConfigKeyRole] = QByteArrayLiteral("configKey"); roleNames[ConfigSectionRole] = QByteArrayLiteral("configSectionRole"); + roleNames[KIconLoaderGroupRole] = QByteArrayLiteral("KIconLoaderGroup"); return roleNames; } diff --git a/kcms/icons/main.cpp b/kcms/icons/main.cpp --- a/kcms/icons/main.cpp +++ b/kcms/icons/main.cpp @@ -140,15 +140,28 @@ { bool needToExportToKDE4 = m_settings->isSaveNeeded(); + // keep track of Group of icons size that has changed + QList notifyList; + for (int i = 0; i < m_iconSizeCategoryModel->rowCount(); ++i) { + const QModelIndex index = m_iconSizeCategoryModel->index(i, 0); + const QString key = index.data(IconSizeCategoryModel::ConfigKeyRole).toString(); + if (m_settings->findItem(key)->isSaveNeeded()) { + notifyList << index.data(IconSizeCategoryModel::KIconLoaderGroupRole).toInt(); + } + } + ManagedConfigModule::save(); if (needToExportToKDE4) { exportToKDE4(); } processPendingDeletions(); - KIconLoader::global()->newIconLoader(); + // Notify the group(s) where icon sizes have changed + for (auto group : qAsConst(notifyList)) { + KIconLoader::emitChange(KIconLoader::Group(group)); + } } bool IconModule::isSaveNeeded() const @@ -286,10 +299,8 @@ QFile::remove(path); } - //message kde4 apps that icon theme is changed + //message kde4 apps that icon theme has changed for (int i = 0; i < KIconLoader::LastGroup; i++) { - KIconLoader::emitChange(KIconLoader::Group(i)); - QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"), QStringLiteral("notifyChange"));