2017-06-16 17:45:04 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
import QtMultimedia 5.0
|
|
|
|
|
|
|
|
|
|
|
|
Item {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: holder
|
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
property ListModel model
|
|
|
|
property double wRatio : 16/9
|
|
|
|
property double hRatio : 9/16
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2022-11-30 18:50:50 +03:00
|
|
|
property bool debug: true
|
2017-06-16 17:45:04 +03:00
|
|
|
width: width
|
|
|
|
height: height
|
|
|
|
Component.onCompleted: {
|
2022-11-30 18:50:50 +03:00
|
|
|
console.log("MB: " + JSON.stringify(model.get(0)))
|
2017-06-16 17:45:04 +03:00
|
|
|
if (model && model.count && model.get(0).type === "video") {
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log("Mediablock")
|
|
|
|
//console.log(JSON.stringify(model.get(0).type))
|
2020-07-06 11:28:42 +03:00
|
|
|
while (model.count>1) {
|
2017-06-16 17:45:04 +03:00
|
|
|
model.remove(model.count-1)
|
|
|
|
}
|
|
|
|
}
|
2017-06-22 15:49:39 +03:00
|
|
|
var count = 0
|
|
|
|
if (model && model.count)
|
|
|
|
count = model.count
|
|
|
|
switch(count){
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
case 1:
|
|
|
|
placeholder1.width = holder.width
|
|
|
|
placeholder1.height = placeholder1.width*hRatio
|
|
|
|
placeholder1.visible = true;
|
|
|
|
holder.height = placeholder1.height
|
|
|
|
break;
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
case 2:
|
2020-06-18 19:40:24 +03:00
|
|
|
placeholder1.visible = true
|
|
|
|
placeholder2.visible = true
|
2017-06-16 17:45:04 +03:00
|
|
|
placeholder1.width = (holder.width-Theme.paddingSmall)/2
|
|
|
|
placeholder1.height = placeholder1.width
|
|
|
|
placeholder2.width = placeholder1.width
|
|
|
|
placeholder2.height = placeholder1.width
|
|
|
|
placeholder2.x = placeholder1.width + placeholder2.x + Theme.paddingSmall
|
|
|
|
holder.height = placeholder1.height
|
|
|
|
break;
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
case 3:
|
2020-06-18 19:40:24 +03:00
|
|
|
placeholder1.visible = true
|
|
|
|
placeholder2.visible = true
|
|
|
|
placeholder3.visible = true
|
|
|
|
placeholder4.visible = false
|
2017-06-16 17:45:04 +03:00
|
|
|
|
|
|
|
placeholder1.width = holder.width - Theme.paddingSmall - Theme.itemSizeLarge;
|
|
|
|
placeholder1.height = Theme.itemSizeLarge*2+Theme.paddingSmall
|
2017-07-04 02:07:39 +03:00
|
|
|
holder.height = placeholder1.height
|
2017-06-16 17:45:04 +03:00
|
|
|
|
|
|
|
placeholder2.width = Theme.itemSizeLarge;
|
2017-07-04 02:07:39 +03:00
|
|
|
placeholder3.height = placeholder3.width = placeholder2.height = placeholder2.width
|
|
|
|
placeholder3.x = placeholder2.x = placeholder1.x + placeholder1.width + Theme.paddingSmall;
|
|
|
|
placeholder3.y = placeholder2.y + placeholder2.height + Theme.paddingSmall;
|
2017-06-16 17:45:04 +03:00
|
|
|
break;
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
case 4:
|
2020-06-18 19:40:24 +03:00
|
|
|
placeholder1.visible = true
|
|
|
|
placeholder2.visible = true
|
|
|
|
placeholder3.visible = true
|
|
|
|
placeholder4.visible = true
|
2017-06-16 17:45:04 +03:00
|
|
|
|
|
|
|
placeholder1.width = placeholder2.width = placeholder3.width = placeholder4.width = (holder.width - 3*Theme.paddingSmall)/4
|
|
|
|
placeholder1.height = placeholder2.height = placeholder3.height = placeholder4.height = Theme.itemSizeLarge*2+Theme.paddingSmall
|
2020-06-18 19:40:24 +03:00
|
|
|
placeholder2.x = 1*(placeholder1.width)+ 1*Theme.paddingSmall
|
|
|
|
placeholder3.x = 2*(placeholder1.width)+ 2*Theme.paddingSmall
|
|
|
|
placeholder4.x = 3*(placeholder1.width)+ 3*Theme.paddingSmall
|
2017-06-16 17:45:04 +03:00
|
|
|
|
2020-06-16 17:09:28 +03:00
|
|
|
holder.height = placeholder1.height
|
2017-06-16 17:45:04 +03:00
|
|
|
break;
|
2020-06-16 17:09:28 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
default:
|
|
|
|
holder.height = 0
|
2017-07-04 02:07:39 +03:00
|
|
|
placeholder1.visible = placeholder2.visible = placeholder3.visible = placeholder4.visible = false;
|
2017-06-16 17:45:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
MyMedia {
|
2017-06-16 17:45:04 +03:00
|
|
|
id: placeholder1
|
|
|
|
width: 2
|
|
|
|
height: 1
|
|
|
|
opacity: pressed ? 0.6 : 1
|
|
|
|
visible: {
|
|
|
|
if (model && model.count){
|
|
|
|
type = model.get(0).type
|
|
|
|
previewURL = model.get(0).preview_url
|
|
|
|
mediaURL = model.get(0).url
|
2022-11-30 18:50:50 +03:00
|
|
|
url = model.get(0).url
|
|
|
|
if(debug) console.log( model.get(0).url )
|
2020-06-16 17:09:28 +03:00
|
|
|
height = Theme.itemSizeLarge
|
2017-06-16 17:45:04 +03:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
height = 0
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
MyMedia {
|
2017-06-16 17:45:04 +03:00
|
|
|
id: placeholder2
|
|
|
|
width: 2
|
|
|
|
height: 1
|
|
|
|
opacity: pressed ? 0.6 : 1
|
|
|
|
visible: {
|
|
|
|
if (model && model.count && model.get(1)){
|
|
|
|
type = model.get(1).type
|
|
|
|
previewURL = model.get(1).preview_url
|
|
|
|
mediaURL = model.get(1).url
|
2022-11-30 18:50:50 +03:00
|
|
|
url = model.get(0).url
|
|
|
|
if(debug) console.log( model.get(1).url )
|
2020-06-16 17:09:28 +03:00
|
|
|
height = Theme.itemSizeLarge
|
2017-06-16 17:45:04 +03:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
height = 0
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
MyMedia {
|
2017-06-16 17:45:04 +03:00
|
|
|
id: placeholder3
|
|
|
|
width: 2
|
|
|
|
height: 1
|
|
|
|
opacity: pressed ? 0.6 : 1
|
|
|
|
visible: {
|
|
|
|
if (model && model.count && model.get(2)){
|
|
|
|
type = model.get(2).type
|
|
|
|
previewURL = model.get(2).preview_url
|
|
|
|
mediaURL = model.get(2).url
|
2022-11-30 18:50:50 +03:00
|
|
|
url = model.get(0).url
|
2020-06-16 17:09:28 +03:00
|
|
|
height = Theme.itemSizeLarge
|
2017-06-16 17:45:04 +03:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
height = 0
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
MyMedia {
|
2017-06-16 17:45:04 +03:00
|
|
|
id: placeholder4
|
|
|
|
width: 2
|
|
|
|
height: 1
|
|
|
|
opacity: pressed ? 0.6 : 1
|
|
|
|
visible: {
|
|
|
|
if (model && model.count && model.get(3)){
|
|
|
|
type = model.get(3).type
|
|
|
|
previewURL = model.get(3).preview_url
|
|
|
|
mediaURL = model.get(3).url
|
2022-11-30 18:50:50 +03:00
|
|
|
url = model.get(0).url
|
2020-06-16 17:09:28 +03:00
|
|
|
height = Theme.itemSizeLarge
|
2017-06-16 17:45:04 +03:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
height = 0
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|