Add ExclusiveGroup support to the checkboxes of the ListView.
Only ONE of the following effects can be active at the same time. *kwin4_effect_slideEnabled *kwin4_effect_cubeslideEnabled *kwin4_effect_fadedesktopEnabledicc-effect-5.14.5
parent
3ab4e1a84a
commit
609c4c5470
|
@ -123,6 +123,15 @@ bool EffectModel::setData(const QModelIndex& index, const QVariant& value, int r
|
||||||
|
|
||||||
if (role == EffectModel::EffectStatusRole) {
|
if (role == EffectModel::EffectStatusRole) {
|
||||||
m_effectsList[index.row()].effectStatus = value.toBool();
|
m_effectsList[index.row()].effectStatus = value.toBool();
|
||||||
|
|
||||||
|
const QString effectServiceName = m_effectsList[index.row()].serviceName;
|
||||||
|
if (effectServiceName == "kwin4_effect_slide") {
|
||||||
|
handleDesktopSwitching(index.row());
|
||||||
|
} else if (effectServiceName == "kwin4_effect_fadedesktop") {
|
||||||
|
handleDesktopSwitching(index.row());
|
||||||
|
} else if (effectServiceName == "kwin4_effect_cubeslide") {
|
||||||
|
handleDesktopSwitching(index.row());
|
||||||
|
}
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +155,7 @@ void EffectModel::loadEffects() {
|
||||||
effect.license = plugin.license();
|
effect.license = plugin.license();
|
||||||
effect.version = plugin.version();
|
effect.version = plugin.version();
|
||||||
effect.category = plugin.category();
|
effect.category = plugin.category();
|
||||||
effect.serviceName = serviceName(effect.name);
|
effect.serviceName = plugin.property("X-KDE-PluginInfo-Name").toString();
|
||||||
effect.effectStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", false);
|
effect.effectStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", false);
|
||||||
|
|
||||||
if (effect.effectStatus) {
|
if (effect.effectStatus) {
|
||||||
|
@ -165,12 +174,27 @@ void EffectModel::loadEffects() {
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EffectModel::serviceName(const QString &effectName) {
|
void EffectModel::handleDesktopSwitching(int row) {
|
||||||
//The effect name is something like "Show Fps" and
|
//Q: Why do we need the handleDesktopSwitching?
|
||||||
//we want something like "showfps"
|
//A: Because of the setData, when we enable the effect
|
||||||
return "kwin4_effect_" + effectName.toLower().remove(" ");
|
//and then we scroll, our model is being updated,
|
||||||
|
//so the setData is being called again, and as a result
|
||||||
|
//of that we have multiple effects enabled for the desktop switching.
|
||||||
|
const QString currentEffect = m_effectsList[row].serviceName;
|
||||||
|
for (int it = 0; it < m_effectsList.size(); it++) {
|
||||||
|
EffectData effect = m_effectsList.at(it);
|
||||||
|
|
||||||
|
if (effect.serviceName == "kwin4_effect_slide" && currentEffect != effect.serviceName && effect.effectStatus) {
|
||||||
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
||||||
|
} else if (effect.serviceName == "kwin4_effect_cubeslide" && currentEffect != effect.serviceName && effect.effectStatus) {
|
||||||
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
||||||
|
}else if (effect.serviceName == "kwin4_effect_fadedesktop" && currentEffect != effect.serviceName && effect.effectStatus) {
|
||||||
|
m_effectsList[it].effectStatus = !m_effectsList[it].effectStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EffectModel::effectListContains(const QString &effectFilter, int source_row) {
|
bool EffectModel::effectListContains(const QString &effectFilter, int source_row) {
|
||||||
EffectData effect;
|
EffectData effect;
|
||||||
effect = m_effectsList.at(source_row);
|
effect = m_effectsList.at(source_row);
|
||||||
|
|
|
@ -78,6 +78,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadEffects();
|
void loadEffects();
|
||||||
|
void handleDesktopSwitching(int row);
|
||||||
QList<EffectData> m_effectsList;
|
QList<EffectData> m_effectsList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ Component {
|
||||||
id: item
|
id: item
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 40
|
height: 40
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: background
|
id: background
|
||||||
color: item.ListView.isCurrentItem ? "#448" : index % 2 ? "#eee" : "#fff"
|
color: item.ListView.isCurrentItem ? "#448" : index % 2 ? "#eee" : "#fff"
|
||||||
|
@ -37,15 +38,27 @@ Component {
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
CheckBox {
|
CheckBox {
|
||||||
|
function isDesktopSwitching() {
|
||||||
|
if (model.ServiceNameRole == "kwin4_effect_slide") {
|
||||||
|
return true;
|
||||||
|
} else if (model.ServiceNameRole == "kwin4_effect_fadedesktop") {
|
||||||
|
return true;
|
||||||
|
} else if (model.ServiceNameRole == "kwin4_effect_cubeslide") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
id: myCheckBox
|
id: myCheckBox
|
||||||
checked: model.EffectStatusRole
|
checked: model.EffectStatusRole
|
||||||
|
exclusiveGroup: isDesktopSwitching() ? desktopSwitching : null
|
||||||
onClicked: {
|
onClicked: {
|
||||||
apply.enabled = true;
|
apply.enabled = true;
|
||||||
effectModel.effectStatus(effectView.model.modelIndex(index),checked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
configureButton.enabled = myCheckBox.checked;
|
configureButton.enabled = myCheckBox.checked;
|
||||||
|
effectModel.effectStatus(effectView.model.modelIndex(index),checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,12 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExclusiveGroup {
|
||||||
|
id: desktopSwitching
|
||||||
|
//Our ExclusiveGroup must me outside of the
|
||||||
|
//ListView, otherwise it will not work
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: apply
|
id: apply
|
||||||
text: "Apply"
|
text: "Apply"
|
||||||
|
|
|
@ -71,7 +71,6 @@ Item {
|
||||||
openGLError.visible = true;
|
openGLError.visible = true;
|
||||||
} else {
|
} else {
|
||||||
openGLError.visible = false;
|
openGLError.visible = false;
|
||||||
console.log("mesa")
|
|
||||||
view.visible = true;
|
view.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue