140 lines
4.9 KiB
QML
140 lines
4.9 KiB
QML
import QtQuick 2.0
|
|
import QtQuick.Dialogs 1.2
|
|
import QtQuick.Controls 1.4
|
|
import QtQml.Models 2.1
|
|
import "qrc:/js/service.js" as Service
|
|
import "qrc:/js/helper.js" as Helperjs
|
|
import "qrc:/qml"
|
|
|
|
Rectangle {
|
|
id:fotorectangle
|
|
y:1
|
|
width:root.width-mm
|
|
height:root.height-5*mm
|
|
color: '#fff'
|
|
property var newImages:[]
|
|
property int currentImageNo: 0
|
|
//onLoginChanged:{var msg = {'model': photogroupModel,'albums':[],'firstalbum':0,'foreignPicture':false};
|
|
// photoWorker.sendMessage(msg);
|
|
//}
|
|
onNewImagesChanged:{
|
|
if(newImages.length>0){
|
|
Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle);
|
|
newImagesProgress.visible=true //download first image
|
|
}}
|
|
onCurrentImageNoChanged:{
|
|
if(currentImageNo<newImages.length){Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle)};
|
|
if(currentImageNo==newImages.length){newImagesProgress.visible=false;showOwnFotos();
|
|
newImages=[];currentImageNo=0}
|
|
// download next image if photoplaceholder is finished saving
|
|
}
|
|
|
|
|
|
ProgressBar{
|
|
id: newImagesProgress
|
|
width: 15*mm
|
|
height: updatePhotolist.height
|
|
anchors.top: parent.top
|
|
anchors.right:updatePhotolist.left
|
|
anchors.rightMargin:mm
|
|
visible: false
|
|
value: currentImageNo/newImages.length
|
|
}
|
|
|
|
Button{
|
|
id: updatePhotolist
|
|
anchors.top: parent.top
|
|
anchors.right:showFotos.left
|
|
anchors.rightMargin:mm
|
|
text: qsTr("Update")
|
|
onClicked: {
|
|
Service.requestList(root.login,root.db, fotostab,function(obj){
|
|
newImages=obj;
|
|
})}}
|
|
|
|
Button{
|
|
id: showFotos
|
|
anchors.top: parent.top
|
|
anchors.right: parent.right
|
|
anchors.rightMargin:2*mm
|
|
text: qsTr("Show")
|
|
onClicked: {showOwnFotos()}
|
|
}
|
|
|
|
DelegateModel{
|
|
id: visualphotoModel
|
|
delegate: PhotogroupComponent{}
|
|
model: photogroupModel
|
|
}
|
|
|
|
ListModel{
|
|
id: photogroupModel
|
|
}
|
|
|
|
GridView {
|
|
id: albumgridview
|
|
cellWidth: 17*mm
|
|
cellHeight: 17*mm
|
|
x: mm;y:8*mm
|
|
width: parent.width-2*mm; height: parent.height-9*mm
|
|
clip: true
|
|
model: visualphotoModel.parts.album
|
|
footer:
|
|
Rectangle{
|
|
border.color: "#EEEEEE"
|
|
border.width: 1
|
|
width:12*mm
|
|
height:6*mm
|
|
Text{
|
|
font.pixelSize: 1.5*mm
|
|
anchors.centerIn: parent
|
|
text:qsTr("More")
|
|
}
|
|
MouseArea{anchors.fill:parent
|
|
onClicked:{
|
|
var lastalbum_id=photogroupModel.get(photogroupModel.count-1);
|
|
if(photogroupModel.get(photogroupModel.count-1).foreignPictures==false){Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
|
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':lastalbum_id+1,'foreignPicture':true};
|
|
photoWorker.sendMessage(msg); })}
|
|
else { Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
|
var msg = { 'model': photogroupModel,'albums':albums,'foreignPicture': false,'firstalbum':lastalbum_id+1};
|
|
photoWorker.sendMessage(msg)})}
|
|
}}}
|
|
}
|
|
|
|
Rectangle { id: photoBackground; color: 'light grey'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
|
|
|
|
ListView { anchors.fill: parent; model: visualphotoModel.parts.browser; interactive: false }
|
|
|
|
Button {
|
|
id: backButton
|
|
text: qsTr("Back")
|
|
x: parent.width - backButton.width - 3*mm
|
|
y: -backButton.height - 4*mm
|
|
onClicked: {photoBackground.opacity=0}
|
|
// visible: Qt.platform.os !== "android"
|
|
}
|
|
|
|
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
|
|
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
|
|
|
|
function showOwnFotos(){
|
|
try {photogroupModel.clear()}catch (e){print(e)}
|
|
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
|
if (albums[0]) {
|
|
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
|
photoWorker.sendMessage(msg);
|
|
};
|
|
})
|
|
}
|
|
|
|
function onFriendsFotos(friend){print("Friend "+friend.url);
|
|
try {photogroupModel.clear()}catch (e){print(e)}
|
|
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
|
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
|
photoWorker.sendMessage(msg);
|
|
})
|
|
}
|
|
|
|
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
|
}
|