import QtQuick 2.0
Rectangle {
id: root
property int itemHeight: 25
property string effectSource: ""
signal clicked
QtObject {
id: d
property Item selectedItem
}
ListModel {
id: sources
ListElement { name: "No effect"; source: "EffectPassThrough.qml" }
ListElement { name: "Billboard"; source: "EffectBillboard.qml" }
ListElement { name: "Black & white"; source: "EffectBlackAndWhite.qml" }
ListElement { name: "Blur"; source: "EffectGaussianBlur.qml" }
ListElement { name: "Edge detection"; source: "EffectSobelEdgeDetection1.qml" }
ListElement { name: "Emboss"; source: "EffectEmboss.qml" }
ListElement { name: "Glow"; source: "EffectGlow.qml" }
ListElement { name: "Isolate"; source: "EffectIsolate.qml" }
ListElement { name: "Magnify"; source: "EffectMagnify.qml" }
ListElement { name: "Page curl"; source: "EffectPageCurl.qml" }
ListElement { name: "Pixelate"; source: "EffectPixelate.qml" }
ListElement { name: "Posterize"; source: "EffectPosterize.qml" }
ListElement { name: "Ripple"; source: "EffectRipple.qml" }
ListElement { name: "Sepia"; source: "EffectSepia.qml" }
ListElement { name: "Sharpen"; source: "EffectSharpen.qml" }
ListElement { name: "Shockwave"; source: "EffectShockwave.qml" }
ListElement { name: "Tilt shift"; source: "EffectTiltShift.qml" }
ListElement { name: "Toon"; source: "EffectToon.qml" }
ListElement { name: "Warhol"; source: "EffectWarhol.qml" }
ListElement { name: "Wobble"; source: "EffectWobble.qml" }
ListElement { name: "Vignette"; source: "EffectVignette.qml" }
}
Component {
id: sourceDelegate
Item {
id: sourceDelegateItem
width: root.width
height: itemHeight
Button {
id: sourceSelectorItem
anchors.centerIn: parent
width: 0.9 * parent.width
height: 0.8 * itemHeight
text: name
onClicked: {
if (d.selectedItem)
d.selectedItem.state = "baseState"
d.selectedItem = sourceDelegateItem
d.selectedItem.state = "selected"
effectSource = source
root.clicked()
}
}
states: [
State {
name: "selected"
PropertyChanges {
target: sourceSelectorItem
bgColor: "#ff8888"
}
}
]
Component.onCompleted: {
if (name == "No effect") {
state = "selected"
d.selectedItem = sourceDelegateItem
}
}
transitions: [
Transition {
from: "*"
to: "*"
ColorAnimation {
properties: "color"
easing.type: Easing.OutQuart
duration: 500
}
}
]
}
}
Flickable {
anchors.fill: parent
contentHeight: (itemHeight * sources.count) + layout.anchors.topMargin + layout.spacing
clip: true
Column {
id: layout
anchors {
fill: parent
topMargin: 10
}
Repeater {
model: sources
delegate: sourceDelegate
}
}
}
}