diff --git a/kcms/desktoptheme/kcm.h b/kcms/desktoptheme/kcm.h --- a/kcms/desktoptheme/kcm.h +++ b/kcms/desktoptheme/kcm.h @@ -58,6 +58,8 @@ Q_INVOKABLE void applyPlasmaTheme(QQuickItem *item, const QString &themeName); + Q_INVOKABLE int indexOf(const QString &themeName) const; + Q_SIGNALS: void selectedPluginChanged(const QString &plugin); void showInfoMessage(const QString &infoMessage); diff --git a/kcms/desktoptheme/kcm.cpp b/kcms/desktoptheme/kcm.cpp --- a/kcms/desktoptheme/kcm.cpp +++ b/kcms/desktoptheme/kcm.cpp @@ -164,6 +164,16 @@ } } +Q_INVOKABLE int KCMDesktopTheme::indexOf(const QString &themeName) const +{ + for (int i = 0; i < m_model->rowCount(); ++i) { + if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == themeName) { + return i; + } + } + return -1; +} + void KCMDesktopTheme::load() { m_pendingRemoval.clear(); diff --git a/kcms/desktoptheme/package/contents/ui/main.qml b/kcms/desktoptheme/package/contents/ui/main.qml --- a/kcms/desktoptheme/package/contents/ui/main.qml +++ b/kcms/desktoptheme/package/contents/ui/main.qml @@ -48,6 +48,11 @@ cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (units.gridUnit * 12)), 3)) cellHeight: cellWidth / 1.6 + onCountChanged: { + grid.currentIndex = kcm.indexOf(kcm.selectedPlugin); + grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) + } + delegate: Item { property bool isLocal : model.isLocal property string pluginName : model.pluginName @@ -165,7 +170,7 @@ enabled: grid.currentItem && grid.currentItem.isLocal onClicked: { kcm.removeTheme(grid.currentItem.pluginName); - updateSelectedPluginTimer.restart(); + kcm.selectedPlugin = grid.currentItem.pluginName } } @@ -188,12 +193,6 @@ } Timer { - id: updateSelectedPluginTimer - interval: 100 - onTriggered: kcm.selectedPlugin = grid.currentItem.pluginName - } - - Timer { id: hideInfoMessageTimer interval: 20 * 1000 onTriggered: {