diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 8c848adfae..1133e34421 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -238,8 +238,9 @@ void EffectModel::reload() { loadEffects(); } -void EffectModel::effectStatus(const QModelIndex &index, bool effectState) { - setData(index, effectState, EffectModel::EffectStatusRole); +void EffectModel::effectStatus(int rowIndex, bool effectState) { + QModelIndex currentIndex = createIndex(rowIndex, 0); + setData(currentIndex, effectState, EffectModel::EffectStatusRole); } void EffectModel::syncConfig() { @@ -277,6 +278,8 @@ EffectFilterModel::EffectFilterModel(QObject *parent) :QSortFilterProxyModel(parent), m_effectModel(0) { + m_effectModel = new EffectModel(this); + setSourceModel(m_effectModel); } EffectModel *EffectFilterModel::effectModel() const { @@ -334,10 +337,29 @@ bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &sour return false; } +void EffectFilterModel::effectStatus(int rowIndex, bool effectState) { + m_effectModel->effectStatus(rowIndex, effectState); +} + +QString EffectFilterModel::findImage(const QString &imagePath, int size) { + m_effectModel->findImage(imagePath, size); +} + +void EffectFilterModel::reload() { + m_effectModel->reload(); +} + +void EffectFilterModel::syncConfig() { + m_effectModel->syncConfig(); +} + +void EffectFilterModel::enableWidnowManagement(bool enabled) { + m_effectModel->enableWidnowManagement(enabled); +} + EffectView::EffectView(QWindow *parent) : QQuickView(parent) { - qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectModel"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "Compositing"); diff --git a/kcmkwin/kwincompositing/model.h b/kcmkwin/kwincompositing/model.h index 9c994b0531..efdfb592d0 100644 --- a/kcmkwin/kwincompositing/model.h +++ b/kcmkwin/kwincompositing/model.h @@ -74,11 +74,11 @@ public: virtual QHash< int, QByteArray > roleNames() const override; - Q_INVOKABLE void effectStatus(const QModelIndex &index, bool effectState); - Q_INVOKABLE QString findImage(const QString &imagePath, int size = 128); - Q_INVOKABLE void reload(); - Q_INVOKABLE void syncConfig(); - Q_INVOKABLE void enableWidnowManagement(bool enabled); + void effectStatus(int rowIndex, bool effectState); + QString findImage(const QString &imagePath, int size = 128); + void reload(); + void syncConfig(); + void enableWidnowManagement(bool enabled); private: void loadEffects(); @@ -86,6 +86,7 @@ private: void handleWindowManagement(int row, bool enabled); int findRowByServiceName(const QString &serviceName); QList m_effectsList; + }; class EffectView : public QQuickView { @@ -108,6 +109,12 @@ public: EffectModel *effectModel() const; const QString &filter() const; + Q_INVOKABLE void effectStatus(int rowIndex, bool effectState); + Q_INVOKABLE QString findImage(const QString &imagePath, int size = 128); + Q_INVOKABLE void reload(); + Q_INVOKABLE void syncConfig(); + Q_INVOKABLE void enableWidnowManagement(bool enabled); + public Q_SLOTS: void setEffectModel(EffectModel *effectModel); void setFilter(const QString &filter); diff --git a/kcmkwin/kwincompositing/qml/Effect.qml b/kcmkwin/kwincompositing/qml/Effect.qml index 06420b4c47..2d07b60f19 100644 --- a/kcmkwin/kwincompositing/qml/Effect.qml +++ b/kcmkwin/kwincompositing/qml/Effect.qml @@ -73,7 +73,7 @@ Component { onCheckedChanged: { windowManagement.checked = isWindowManagementEnabled(); - effectModel.effectStatus(effectView.model.modelIndex(index),checked); + searchModel.effectState(index, checked); } } @@ -118,13 +118,18 @@ Component { id: configureButton anchors.left: effectItem.right visible: effectConfig.effectUiConfigExists(model.ServiceNameRole) - iconSource: effectModel.findImage("actions/configure.png") width: 50 height: 25 enabled: myCheckBox.checked onClicked: { effectConfig.openConfig(model.NameRole); } + + Component.onCompleted: { + searchModel.image('actions/configure.png') + iconSource = searchModel.imagePath; + } + } Button { @@ -132,12 +137,16 @@ Component { anchors.left: configureButton.right width: 50 height: 25 - iconSource: effectModel.findImage("status/dialog-information.png"); onClicked: { animationAbout.running = true; animationAboutSpacing.running = true; } + + Component.onCompleted: { + searchModel.image('status/dialog-information.png') + iconSource = searchModel.imagePath; + } } EffectConfig { diff --git a/kcmkwin/kwincompositing/qml/EffectView.qml b/kcmkwin/kwincompositing/qml/EffectView.qml index a46cfe2252..f85ce7dc0c 100644 --- a/kcmkwin/kwincompositing/qml/EffectView.qml +++ b/kcmkwin/kwincompositing/qml/EffectView.qml @@ -24,9 +24,6 @@ import QtQuick.Layouts 1.0 import org.kde.kwin.kwincompositing 1.0 Item { - EffectModel { - id: effectModel - } Component { id: sectionHeading @@ -54,7 +51,7 @@ Item { anchors.left: col.right anchors.top: parent.top anchors.topMargin: col.height/2 - onClicked: effectModel.enableWidnowManagement(windowManagement.checked) + onClicked: searchModel.enableWidnowManagement(windowManagement.checked) } ComboBox { @@ -94,9 +91,19 @@ Item { } EffectFilterModel { - id:searchModel + id: searchModel filter: searchField.text - model: effectModel + property string imagePath + signal image(string path) + signal effectState(int rowIndex, bool enabled) + + onImage: { + imagePath = searchModel.findImage(path); + } + + onEffectState: { + searchModel.effectStatus(rowIndex, enabled); + } } ScrollView { @@ -136,8 +143,8 @@ Item { } onClicked: { - effectModel.syncConfig(); - effectModel.reload(); + searchModel.syncConfig(); + searchModel.reload(); apply.enabled = false; compositing.syncConfig(openGLType.currentIndex, graphicsSystem.currentIndex); }