[kcmkwin/kwindecoration] Set current decoration index on start

Summary:
Fixes the preselected decoration style on module load.

Also:
* Prevent the module state to be set to modified on resize.
* Fix QML errors in logs.

Reviewers: davidedmundson

Reviewed By: davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17775
This commit is contained in:
Valerio Pilo 2019-01-03 15:26:21 +01:00
parent ac45977e9e
commit ef1692eea6
2 changed files with 18 additions and 8 deletions

View file

@ -106,6 +106,7 @@ ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &ar
m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons);
m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons);
m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons);
m_quickView->rootContext()->setContextProperty("initialThemeIndex", -1);
m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont));
m_quickView->setResizeMode(QQuickView::SizeRootObjectToView);
@ -113,7 +114,7 @@ ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &ar
if (m_quickView->status() == QQuickView::Ready) {
auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView");
if (listView) {
connect(listView, SIGNAL(currentIndexChanged()), this, SLOT(changed()));
connect(listView, SIGNAL(userChangedSelection()), this, SLOT(changed()));
}
}
@ -313,7 +314,7 @@ void ConfigurationModule::load()
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);
m_quickView->rootContext()->setContextProperty("initialThemeIndex", themeIndex);
// buttons
const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{

View file

@ -28,16 +28,17 @@ ScrollView {
GridView {
id: gridView
objectName: "listView"
signal userChangedSelection()
model: decorationsModel
cellWidth: 20 * units.gridUnit
cellHeight: cellWidth / 1.6
highlightFollowsCurrentItem: true
onContentHeightChanged: {
if (gridView.currentIndex == -1) {
gridView.currentIndex = savedIndex;
if (gridView.currentIndex == -1 && initialThemeIndex != -1) {
gridView.currentIndex = initialThemeIndex
}
gridView.positionViewAtIndex(gridView.currentIndex, GridView.Visible);
gridView.positionViewAtIndex(gridView.currentIndex, GridView.Visible)
}
Rectangle {
z: -1
anchors.fill: parent
@ -63,11 +64,17 @@ ScrollView {
bridge: bridgeItem.bridge
borderSizesIndex: gridView.borderSizesIndex
}
Component.onCompleted: {
if (gridView.currentIndex == -1 && initialThemeIndex != -1) {
gridView.currentIndex = initialThemeIndex
}
}
MouseArea {
hoverEnabled: false
anchors.fill: parent
onClicked: {
gridView.currentIndex = index;
gridView.currentIndex = index
gridView.userChangedSelection()
}
}
ColumnLayout {
@ -107,7 +114,8 @@ ScrollView {
hoverEnabled: false
anchors.fill: parent
onClicked: {
gridView.currentIndex = index;
gridView.currentIndex = index
gridView.userChangedSelection()
}
}
Layout.fillWidth: true
@ -138,6 +146,7 @@ ScrollView {
text: i18n("Configure %1...", decorationPreviews.themeName)
onClicked: {
gridView.currentIndex = index
gridView.userChangedSelection()
bridgeItem.bridge.configure()
}
}