summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <kde@davidedmundson.co.uk>2017-04-13 10:54:39 (GMT)
committerDavid Edmundson <kde@davidedmundson.co.uk>2017-04-13 10:54:39 (GMT)
commit3709996f8a884e80139f14ed4c334b1b1c758bf1 (patch)
tree9ea7cb35a7f8050e93d8e96416dda765b7cbec33
parent819c64586341cf769409e4df0a1cc960257bb4be (diff)
Fix KWin decoration KCM showing correct index at startup
Summary: The KCM has a context property of the currently set theme index. This is set before the decorations model is populated, so it is currently always -1. This model is populated after the constructor but before KCModule::load(). KCModule::load is called from KCModule::showEvent so before QQuickGridView will start doing anything with delegates. This fixes the problem simply and also avoid parsing the config file multiple times. This bug was introduced in 5.9.4: Someone made a (tested) change to make sure the view scrolled to the right place on startup. I then made a (tested) commit fixing the crash on exit The author then updated his patch to my changes, but now in a way that didn't work. Test Plan: Opened system settings module with a million decorations. The correct entry was visible and highlighted. Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D5401
-rw-r--r--kcmkwin/kwindecoration/kcm.cpp12
-rw-r--r--kcmkwin/kwindecoration/kcm.h2
-rw-r--r--kcmkwin/kwindecoration/qml/Previews.qml4
3 files changed, 6 insertions, 12 deletions
diff --git a/kcmkwin/kwindecoration/kcm.cpp b/kcmkwin/kwindecoration/kcm.cpp
index 3a3c64d..3afffb1 100644
--- a/kcmkwin/kwindecoration/kcm.cpp
+++ b/kcmkwin/kwindecoration/kcm.cpp
@@ -99,7 +99,6 @@ ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &ar
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);
@@ -300,14 +299,6 @@ QVector< KDecoration2::DecorationButtonType > readDecorationButtons(const KConfi
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;
@@ -318,6 +309,9 @@ void ConfigurationModule::load()
const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal)));
m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border));
+ int themeIndex = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row();
+ m_quickView->rootContext()->setContextProperty("savedIndex", themeIndex);
+
// buttons
const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{
KDecoration2::DecorationButtonType::Menu,
diff --git a/kcmkwin/kwindecoration/kcm.h b/kcmkwin/kwindecoration/kcm.h
index 2a955fe..99fa431 100644
--- a/kcmkwin/kwindecoration/kcm.h
+++ b/kcmkwin/kwindecoration/kcm.h
@@ -57,8 +57,6 @@ public Q_SLOTS:
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/qml/Previews.qml b/kcmkwin/kwindecoration/qml/Previews.qml
index fa16ff2..cfb4172 100644
--- a/kcmkwin/kwindecoration/qml/Previews.qml
+++ b/kcmkwin/kwindecoration/qml/Previews.qml
@@ -33,7 +33,9 @@ ScrollView {
cellWidth: 20 * units.gridUnit
cellHeight: cellWidth / 1.6
onContentHeightChanged: {
- gridView.currentIndex = savedIndex;
+ if (gridView.currentIndex == -1) {
+ gridView.currentIndex = savedIndex;
+ }
gridView.positionViewAtIndex(gridView.currentIndex, GridView.Visible);
}