Drop the Apply button from the EffectView

We have an Apply and OK button in the KCModule, so we don't need one
in the view. A change signal is introduced and passed from the individual
items upwards, so that we can connect to it from the C++ side.
This commit is contained in:
Martin Gräßlin 2013-12-02 11:22:57 +01:00
parent 7372a7f784
commit befb2b8e8a
3 changed files with 162 additions and 144 deletions

View file

@ -24,138 +24,131 @@ import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import org.kde.kwin.kwincompositing 1.0
Component {
id: effectDelegate
Item {
id: item
width: parent.width
height: 40
Item {
id: item
width: parent.width
height: 40
signal changed()
property alias checked: effectStatusCheckBox.checked
Rectangle {
id: background
color: item.ListView.isCurrentItem ? effectView.backgroundActiveColor : index % 2 ? effectView.backgroundNormalColor : effectView.backgroundAlternateColor
anchors.fill : parent
Rectangle {
id: background
color: item.ListView.isCurrentItem ? effectView.backgroundActiveColor : index % 2 ? effectView.backgroundNormalColor : effectView.backgroundAlternateColor
anchors.fill : parent
RowLayout {
id: rowEffect
anchors.fill: parent
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;
}
}
function isWindowManagementEnabled() {
if (model.ServiceNameRole == "kwin4_effect_dialogparent") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
} else if (model.ServiceNameRole == "kwin4_effect_desktopgrid") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
} else if (model.ServiceNameRole == "kwin4_effect_presentwindows") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
}
return windowManagementEnabled;
}
id: effectStatusCheckBox
property bool windowManagementEnabled;
checked: model.EffectStatusRole
exclusiveGroup: isDesktopSwitching() ? desktopSwitching : null
onClicked: {
apply.enabled = true;
}
onCheckedChanged: {
windowManagement.checked = isWindowManagementEnabled();
searchModel.effectState(index, checked);
RowLayout {
id: rowEffect
anchors.fill: parent
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;
}
}
function isWindowManagementEnabled() {
if (model.ServiceNameRole == "kwin4_effect_dialogparent") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
} else if (model.ServiceNameRole == "kwin4_effect_desktopgrid") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
} else if (model.ServiceNameRole == "kwin4_effect_presentwindows") {
windowManagementEnabled = effectStatusCheckBox.checked;
return windowManagementEnabled = effectStatusCheckBox.checked && windowManagementEnabled;
}
return windowManagementEnabled;
}
Item {
id: effectItem
width: effectView.width - effectStatusCheckBox.width - aboutButton.width - configureButton.width
height: 40
anchors.left: effectStatusCheckBox.right
Column {
id: col
Text {
text: model.NameRole
}
Text {
id: desc
function wrapDescription() {
if (wrapMode == Text.NoWrap) {
wrapMode = Text.WordWrap;
elide = Text.ElideNone;
} else {
wrapMode = Text.NoWrap;
elide = Text.ElideRight;
}
id: effectStatusCheckBox
property bool windowManagementEnabled;
checked: model.EffectStatusRole
exclusiveGroup: isDesktopSwitching() ? desktopSwitching : null
onCheckedChanged: item.changed()
}
Item {
id: effectItem
width: effectView.width - effectStatusCheckBox.width - aboutButton.width - configureButton.width
height: 40
anchors.left: effectStatusCheckBox.right
Column {
id: col
Text {
text: model.NameRole
}
Text {
id: desc
function wrapDescription() {
if (wrapMode == Text.NoWrap) {
wrapMode = Text.WordWrap;
elide = Text.ElideNone;
} else {
wrapMode = Text.NoWrap;
elide = Text.ElideRight;
}
text: model.DescriptionRole
width: effectView.width - 100
elide: Text.ElideRight
}
Item {
id:aboutItem
anchors.top: desc.bottom
anchors.topMargin: 20
visible: false
Text {
text: "Author: " + model.AuthorNameRole + "\n" + "License: " + model.LicenseRole
font.bold: true
}
PropertyAnimation {id: animationAbout; target: aboutItem; property: "visible"; to: !aboutItem.visible}
PropertyAnimation {id: animationAboutSpacing; target: item; property: "height"; to: item.height == 40 ? item.height + 100 : 40}
}
text: model.DescriptionRole
width: effectView.width - 100
elide: Text.ElideRight
}
MouseArea {
id: area
width: effectView.width - effectStatusCheckBox.width
height: effectView.height
onClicked: {
effectView.currentIndex = index;
Item {
id:aboutItem
anchors.top: desc.bottom
anchors.topMargin: 20
visible: false
Text {
text: "Author: " + model.AuthorNameRole + "\n" + "License: " + model.LicenseRole
font.bold: true
}
PropertyAnimation {id: animationAbout; target: aboutItem; property: "visible"; to: !aboutItem.visible}
PropertyAnimation {id: animationAboutSpacing; target: item; property: "height"; to: item.height == 40 ? item.height + 100 : 40}
}
}
Button {
id: configureButton
anchors.right: aboutButton.left
visible: effectConfig.effectUiConfigExists(model.ServiceNameRole)
enabled: effectStatusCheckBox.checked
iconName: "configure"
MouseArea {
id: area
width: effectView.width - effectStatusCheckBox.width
height: effectView.height
onClicked: {
effectConfig.openConfig(model.NameRole);
effectView.currentIndex = index;
}
}
}
Button {
id: aboutButton
anchors.right: parent.right
iconName: "dialog-information"
onClicked: {
animationAbout.running = true;
animationAboutSpacing.running = true;
desc.wrapDescription();
}
Button {
id: configureButton
anchors.right: aboutButton.left
visible: effectConfig.effectUiConfigExists(model.ServiceNameRole)
enabled: effectStatusCheckBox.checked
iconName: "configure"
onClicked: {
effectConfig.openConfig(model.NameRole);
}
}
EffectConfig {
id: effectConfig
Button {
id: aboutButton
anchors.right: parent.right
iconName: "dialog-information"
onClicked: {
animationAbout.running = true;
animationAboutSpacing.running = true;
desc.wrapDescription();
}
}
} //end Row
} //end Rectangle
} //end item
}
EffectConfig {
id: effectConfig
}
} //end Row
} //end Rectangle
} //end item

View file

@ -25,6 +25,7 @@ import org.kde.kwin.kwincompositing 1.0
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
signal changed
Component {
id: sectionHeading
@ -67,7 +68,6 @@ Item {
anchors.top: windowManagement.bottom
anchors.left: col.right
onCurrentIndexChanged: {
apply.enabled = true;
glScaleFilter.visible = currentIndex != 3;
xrScaleFilter.visible = currentIndex == 3;
glColorCorrection.enabled = currentIndex !=3 && glColorCorrection !=4;
@ -94,10 +94,6 @@ Item {
top: animationText.bottom
left: col.right
}
onValueChanged: {
apply.enabled = true;
}
}
Label {
@ -120,7 +116,6 @@ Item {
left: col.right
right: parent.right
}
onCurrentIndexChanged: apply.enabled = true;
}
Label {
@ -142,7 +137,6 @@ Item {
top: scaleFilterText.bottom
left: col.right
}
onCurrentIndexChanged: apply.enabled = true;
}
ComboBox {
@ -155,7 +149,6 @@ Item {
left: glScaleFilter.visible ? glScaleFilter.right : col.right
right: parent.right
}
onCurrentIndexChanged: apply.enabled = true;
}
CheckBox {
@ -164,7 +157,6 @@ Item {
checked: compositing.unredirectFullscreen
anchors.left: col.right
anchors.top: xrScaleFilter.bottom
onClicked: apply.enabled = true
}
Label {
@ -186,7 +178,6 @@ Item {
left: col.right
right: parent.right
}
onCurrentIndexChanged: apply.enabled = true;
}
CheckBox {
@ -198,7 +189,6 @@ Item {
top: glSwapStrategy.bottom
left: col.right
}
onClicked: apply.enabled = true
}
ColumnLayout {
@ -233,6 +223,7 @@ Item {
EffectFilterModel {
id: searchModel
objectName: "filterModel"
filter: searchField.text
signal effectState(int rowIndex, bool enabled)
@ -249,7 +240,7 @@ Item {
anchors {
top: searchField.bottom
left: parent.left
bottom: apply.top
bottom: parent.bottom
}
ListView {
id: effectView
@ -259,7 +250,17 @@ Item {
Layout.fillWidth: true
anchors.fill: parent
model: searchModel
delegate: Effect{}
delegate: Effect{
id: effectDelegate
Connections {
id: effectStateConnection
target: null
onChanged: searchModel.effectState(index, checked)
}
Component.onCompleted: {
effectStateConnection.target = effectDelegate
}
}
section.property: "CategoryRole"
section.delegate: sectionHeading
@ -272,22 +273,42 @@ Item {
//ListView, otherwise it will not work
}
Button {
id: apply
text: i18n("Apply")
enabled: false
anchors {
bottom: parent.bottom
}
onClicked: {
searchModel.syncConfig();
apply.enabled = false;
compositingType.syncConfig(openGLType.currentIndex, animationSpeed.value, windowThumbnail.currentIndex, glScaleFilter.currentIndex, xrScaleFilter.currentIndex == 1,
unredirectFullScreen.checked, glSwapStrategy.currentIndex, glColorCorrection.checked);
}
}
}//End ColumnLayout
}//End RowLayout
Connections {
target: searchModel
onEffectState: changed()
}
Connections {
target: openGLType
onCurrentIndexChanged: changed()
}
Connections {
target: animationSpeed
onValueChanged: changed()
}
Connections {
target: windowThumbnail
onCurrentIndexChanged: changed()
}
Connections {
target: glScaleFilter
onCurrentIndexChanged: changed()
}
Connections {
target: xrScaleFilter
onCurrentIndexChanged: changed()
}
Connections {
target: unredirectFullScreen
onCheckedChanged: changed()
}
Connections {
target: glSwapStrategy
onCurrentIndexChanged: changed()
}
Connections {
target: glColorCorrection
onCheckedChanged: changed()
}
}//End item

View file

@ -30,6 +30,7 @@ Rectangle {
height: 480
color: engine.backgroundViewColor()
property bool openGLBrokeState: true
signal changed
Item {
id: openGLError
@ -61,6 +62,9 @@ Rectangle {
id: view
anchors.fill: parent
visible: false
onChanged: {
window.changed()
}
}
Compositing {