diff --git a/kcms/cursortheme/kcmcursortheme.h b/kcms/cursortheme/kcmcursortheme.h --- a/kcms/cursortheme/kcmcursortheme.h +++ b/kcms/cursortheme/kcmcursortheme.h @@ -147,4 +147,18 @@ QPointer m_tempCopyJob; }; +class OneTimeAction : public QObject +{ +public: + OneTimeAction(const std::function &func, QObject* parent) : QObject(parent), m_function(func) {} + + void trigger() { + m_function(); + deleteLater(); + } + +private: + std::function m_function; +}; + #endif diff --git a/kcms/cursortheme/kcmcursortheme.cpp b/kcms/cursortheme/kcmcursortheme.cpp --- a/kcms/cursortheme/kcmcursortheme.cpp +++ b/kcms/cursortheme/kcmcursortheme.cpp @@ -462,6 +462,15 @@ if (dialog.exec()) { KNS3::Entry::List list = dialog.changedEntries(); if (!list.isEmpty()) { + const CursorTheme *theme = selectedIndex().isValid() ? m_proxyModel->theme(selectedIndex()) : nullptr; + if(theme) { + QString currentTheme = theme->name(); + OneTimeAction* action = new OneTimeAction([this,currentTheme](){ + m_appliedIndex = m_proxyModel->findIndex(currentTheme); + setSelectedThemeRow(m_appliedIndex.row()); + }, this); + connect(m_model, &QAbstractItemModel::modelReset, action, &OneTimeAction::trigger); + } m_model->refreshList(); } } diff --git a/kcms/cursortheme/xcursor/thememodel.cpp b/kcms/cursortheme/xcursor/thememodel.cpp --- a/kcms/cursortheme/xcursor/thememodel.cpp +++ b/kcms/cursortheme/xcursor/thememodel.cpp @@ -64,8 +64,8 @@ beginResetModel(); qDeleteAll(list); list.clear(); - endResetModel(); insertThemes(); + endResetModel(); } QVariant CursorThemeModel::headerData(int section, Qt::Orientation orientation, int role) const