diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -38,6 +38,7 @@ Q_OBJECT Q_PROPERTY(QStandardItemModel *lookAndFeelModel READ lookAndFeelModel CONSTANT) Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged) + Q_PROPERTY(int selectedPluginIndex READ selectedPluginIndex NOTIFY selectedPluginIndexChanged) Q_PROPERTY(bool applyColors READ applyColors WRITE setApplyColors NOTIFY applyColorsChanged) Q_PROPERTY(bool applyWidgetStyle READ applyWidgetStyle WRITE setApplyWidgetStyle NOTIFY applyWidgetStyleChanged) @@ -74,6 +75,8 @@ QString selectedPlugin() const; void setSelectedPlugin(const QString &plugin); + int selectedPluginIndex() const; + //Setters of the various theme pieces void setWidgetStyle(const QString &style); void setColors(const QString &scheme, const QString &colorFile); @@ -117,6 +120,7 @@ void applyWindowSwitcherChanged(); void applyDesktopSwitcherChanged(); void resetDefaultLayoutChanged(); + void selectedPluginIndexChanged(); private: QDir cursorThemeDir(const QString &theme, const int depth); diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -134,12 +134,23 @@ const bool firstTime = m_selectedPlugin.isNull(); m_selectedPlugin = plugin; emit selectedPluginChanged(); + emit selectedPluginIndexChanged(); if (!firstTime) { setNeedsSave(true); } } +int KCMLookandFeel::selectedPluginIndex() const +{ + for (int i = 0; i < m_model->rowCount(); ++i) { + if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == m_selectedPlugin) { + return i; + } + } + return -1; +} + QList KCMLookandFeel::availablePackages(const QString &component) { QList packages; diff --git a/kcms/lookandfeel/package/contents/ui/main.qml b/kcms/lookandfeel/package/contents/ui/main.qml --- a/kcms/lookandfeel/package/contents/ui/main.qml +++ b/kcms/lookandfeel/package/contents/ui/main.qml @@ -51,9 +51,14 @@ cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (units.gridUnit*12)), 3)) cellHeight: cellWidth / 1.6 + onCountChanged: { + grid.currentIndex = kcm.selectedPluginIndex; + grid.positionViewAtIndex(grid.currentIndex, GridView.Visible) + } delegate: Item { width: grid.cellWidth height: grid.cellHeight + Rectangle { anchors { fill: parent @@ -63,15 +68,10 @@ target: kcm onSelectedPluginChanged: { if (kcm.selectedPlugin == model.pluginName) { - makeCurrentTimer.pendingIndex = index + grid.currentIndex = index } } } - Component.onCompleted: { - if (kcm.selectedPlugin == model.pluginName) { - makeCurrentTimer.pendingIndex = index - } - } QIconItem { id: icon anchors.centerIn: parent @@ -167,16 +167,6 @@ } } } - Timer { - id: makeCurrentTimer - interval: 100 - repeat: false - property int pendingIndex - onPendingIndexChanged: makeCurrentTimer.restart() - onTriggered: { - grid.currentIndex = pendingIndex - } - } } } QtControls.Label {