ListModel {
ListElement {
}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
}
ListModel {
ListElement {
}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
ListElement {}
}
To copy to clipboard, switch view to plain text mode
Rectangle {
id: page
width: 400; height: 70*9
color: "black"
property color col: "lightsteelblue"
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.tint(root.col, "#20FFFFFF") }
GradientStop { position: 0.1; color: Qt.tint(root.col, "#20AAAAAA") }
GradientStop { position: 0.9; color: Qt.tint(root.col, "#20666666") }
GradientStop { position: 1.0; color: Qt.tint(root.col, "#20000000") }
}
function saturate(x) {
return Math.min(Math.max(x, 0), 1)
}
function sliderToColor(x) {
return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
saturate(Math.min(6 * x, 4 - 6 * x)),
saturate(Math.min(6 * x - 2, 6 - 6 * x)))
}
Component {
id: recipeDelegate
Item {
id: recipe
property string cc: "green"
property real detailsOpacity : 0
width: listView.width
height: 70
MouseArea {
anchors.fill: parent
onClicked: recipe.state = 'Details';
}
ShaderEffectSource {
id: theSource
sourceItem: theItem
hideSource: true
Image {
id: theItem
width: 311
height: 65
source: "content/img.png"
}
}
ShaderEffect {
x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
property variant source: theSource
fragmentShader:
"uniform sampler2D source;" +
"varying highp vec2 qt_TexCoord0;" +
"void main() {" +
" gl_FragColor = texture2D(source, qt_TexCoord0);" +
" gl_FragColor.r = 0.5;" +
"}"
}
Rectangle {
id: background
x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
color: "#00000000"
border.color: "orange"
radius: 5
}
// A button to close the detailed view, i.e. set the state back to default ('').
TextButton {
y: 10
anchors { right: background.right; rightMargin: 10 }
opacity: recipe.detailsOpacity
text: "Close"
onClicked: recipe.state = '';
}
states: State {
name: "Details"
PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible
PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view
// Move the list so that this item is at the top.
PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
PropertyChanges { target: recipe.ListView.view; }
// Disallow flicking while we're in detailed view
PropertyChanges { target: recipe.ListView.view; interactive: false }
}
transitions: Transition {
// Make the state changes smooth
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
}
}
}
}
// The actual list
ListView {
id: listView
anchors.fill: parent
model: RecipesModel {}
delegate: recipeDelegate
}
}
Rectangle {
id: page
width: 400; height: 70*9
color: "black"
property color col: "lightsteelblue"
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.tint(root.col, "#20FFFFFF") }
GradientStop { position: 0.1; color: Qt.tint(root.col, "#20AAAAAA") }
GradientStop { position: 0.9; color: Qt.tint(root.col, "#20666666") }
GradientStop { position: 1.0; color: Qt.tint(root.col, "#20000000") }
}
function saturate(x) {
return Math.min(Math.max(x, 0), 1)
}
function sliderToColor(x) {
return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
saturate(Math.min(6 * x, 4 - 6 * x)),
saturate(Math.min(6 * x - 2, 6 - 6 * x)))
}
Component {
id: recipeDelegate
Item {
id: recipe
property string cc: "green"
property real detailsOpacity : 0
width: listView.width
height: 70
MouseArea {
anchors.fill: parent
onClicked: recipe.state = 'Details';
}
ShaderEffectSource {
id: theSource
sourceItem: theItem
hideSource: true
Image {
id: theItem
width: 311
height: 65
source: "content/img.png"
}
}
ShaderEffect {
x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
property variant source: theSource
fragmentShader:
"uniform sampler2D source;" +
"varying highp vec2 qt_TexCoord0;" +
"void main() {" +
" gl_FragColor = texture2D(source, qt_TexCoord0);" +
" gl_FragColor.r = 0.5;" +
"}"
}
Rectangle {
id: background
x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
color: "#00000000"
border.color: "orange"
radius: 5
}
// A button to close the detailed view, i.e. set the state back to default ('').
TextButton {
y: 10
anchors { right: background.right; rightMargin: 10 }
opacity: recipe.detailsOpacity
text: "Close"
onClicked: recipe.state = '';
}
states: State {
name: "Details"
PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible
PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view
// Move the list so that this item is at the top.
PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
PropertyChanges { target: recipe.ListView.view; }
// Disallow flicking while we're in detailed view
PropertyChanges { target: recipe.ListView.view; interactive: false }
}
transitions: Transition {
// Make the state changes smooth
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
}
}
}
}
// The actual list
ListView {
id: listView
anchors.fill: parent
model: RecipesModel {}
delegate: recipeDelegate
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks