diff --git a/kcmkwin/kwindecoration/kcm.h b/kcmkwin/kwindecoration/kcm.h --- a/kcmkwin/kwindecoration/kcm.h +++ b/kcmkwin/kwindecoration/kcm.h @@ -57,6 +57,8 @@ void defaults() override; void load() override; void save() override; + //what index is in the model the theme saved as current? needed to move the view at the proper index right at startup + int savedIndex() const; protected: void showEvent(QShowEvent *ev) override; diff --git a/kcmkwin/kwindecoration/kcm.cpp b/kcmkwin/kwindecoration/kcm.cpp --- a/kcmkwin/kwindecoration/kcm.cpp +++ b/kcmkwin/kwindecoration/kcm.cpp @@ -99,6 +99,7 @@ m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel); updateColors(); + m_quickView->rootContext()->setContextProperty("savedIndex", savedIndex()); m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 3); // 3 is normal m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons); m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons); @@ -299,16 +300,20 @@ return buttonsFromString(config.readEntry(key, buttonsToString(defaultValue))); } +int ConfigurationModule::savedIndex() const +{ + const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); + const QString plugin = config.readEntry("library", s_defaultPlugin); + const QString theme = config.readEntry("theme", s_defaultTheme); + return m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); +} + void ConfigurationModule::load() { s_loading = true; const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); const QString plugin = config.readEntry("library", s_defaultPlugin); const QString theme = config.readEntry("theme", s_defaultTheme); - const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)); - if (auto listView = m_quickView->rootObject()->findChild("listView")) { - listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); - } m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); diff --git a/kcmkwin/kwindecoration/qml/Previews.qml b/kcmkwin/kwindecoration/qml/Previews.qml --- a/kcmkwin/kwindecoration/qml/Previews.qml +++ b/kcmkwin/kwindecoration/qml/Previews.qml @@ -32,6 +32,11 @@ model: decorationsModel cellWidth: 20 * units.gridUnit cellHeight: cellWidth / 1.6 + onContentHeightChanged: { + gridView.currentIndex = savedIndex; + gridView.positionViewAtIndex(gridView.currentIndex, GridView.Visible); + } + Rectangle { z: -1 anchors.fill: parent