EffectModel is no more being exposed to the QML
Instead of the EffectModel we are using the FilterProxyModel
This commit is contained in:
parent
d9fcc9f9d5
commit
1f509b7c30
4 changed files with 64 additions and 19 deletions
|
@ -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<EffectModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectModel");
|
||||
qmlRegisterType<EffectConfig>("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig");
|
||||
qmlRegisterType<EffectFilterModel>("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel");
|
||||
qmlRegisterType<Compositing>("org.kde.kwin.kwincompositing", 1, 0, "Compositing");
|
||||
|
|
|
@ -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<EffectData> 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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue