diff --git a/src/kcolorschememanager.cpp b/src/kcolorschememanager.cpp --- a/src/kcolorschememanager.cpp +++ b/src/kcolorschememanager.cpp @@ -166,15 +166,14 @@ { KActionMenu *menu = new KActionMenu(icon, name, parent); QActionGroup *group = new QActionGroup(menu); - connect(group, &QActionGroup::triggered, [](QAction * action) { + connect(group, &QActionGroup::triggered,this, [this](QAction * action) { // hint for the style to synchronize the color scheme with the window manager/compositor - qApp->setProperty("KDE_COLOR_SCHEME_PATH", action->data()); - qApp->setPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(action->data().toString()))); + activateScheme(d->model->index(action->data().toInt())); }); for (int i = 0; i < d->model->rowCount(); ++i) { QModelIndex index = d->model->index(i); QAction *action = new QAction(index.data(Qt::DisplayRole).toString(), menu); - action->setData(index.data(Qt::UserRole)); + action->setData(index.row()); action->setActionGroup(group); action->setCheckable(true); if (index.data().toString() == selectedSchemeName) { @@ -187,7 +186,7 @@ const auto actions = group->actions(); for (QAction *action : actions) { if (action->icon().isNull()) { - action->setIcon(d->model->createPreview(action->data().toString())); + action->setIcon(d->model->createPreview(d->model->index(action->data().toInt()).data(Qt::UserRole).toString())); } } }); @@ -213,7 +212,12 @@ if (index.model() != d->model.data()) { return; } + disconnect(qApp, &QApplication::paletteChanged, this, nullptr); + d->activeSchemeIndex = index.row(); // hint for the style to synchronize the color scheme with the window manager/compositor qApp->setProperty("KDE_COLOR_SCHEME_PATH", index.data(Qt::UserRole)); qApp->setPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(index.data(Qt::UserRole).toString()))); + connect(qApp, &QApplication::paletteChanged, this, [this] { + activateScheme(d->model->index(d->activeSchemeIndex)); + }); } diff --git a/src/kcolorschememanager_p.h b/src/kcolorschememanager_p.h --- a/src/kcolorschememanager_p.h +++ b/src/kcolorschememanager_p.h @@ -50,6 +50,7 @@ KColorSchemeManagerPrivate(); QScopedPointer model; + int activeSchemeIndex; }; #endif