// This file is part of Friendiqa // https://github.com/lubuwest/Friendiqa // Copyright (C) 2017 Marco R. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // In addition, as a special exception, the copyright holders give // permission to link the code of portions of this program with the // OpenSSL library under certain conditions as described in each // individual source file, and distribute linked combinations including // the two. // // You must obey the GNU General Public License in all respects for all // of the code used other than OpenSSL. If you modify file(s) with this // exception, you may extend this exception to your version of the // file(s), but you are not obligated to do so. If you do not wish to do // so, delete this exception statement from your version. If you delete // this exception statement from all source files in the program, then // also delete it here. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQml.Models 2.1 import "qrc:/js/image.js" as Imagejs import "qrc:/js/helper.js" as Helperjs import "qrc:/qml/photoqml" import "qrc:/qml/genericqml" StackView{ id: photoStack anchors.fill:parent initialItem:Rectangle { id:fotorectangle y:1 width:root.width-mm height:root.height-5*mm color: '#fff' property var newimages:[] property int currentimageno: 0 property bool remoteContact: false onNewimagesChanged:{ if(fotorectangle.newimages.length>0){ //print("newimages "+JSON.stringify(newimages)); var ownimagelist=[]; Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){ for (var i=0;i1){photoStack.pop()} if(!albumgridview.currentItem){root.currentIndex=0} if(albumgridview.currentItem.state=='fullscreen'){ albumgridview.currentItem.state = 'inGrid'} else if (albumgridview.currentItem.state == 'inGrid'){albumgridview.currentItem.state=''} else{root.currentIndex=0} } else{ try {photogroupModel.clear()}catch (e){print(e)} if (friend){ Imagejs.newRequestFriendsAlbumPictures(login,friend,fotorectangle,function(albums,remoteAuthBool){ remoteContact=remoteAuthBool; var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true,'friend':friend} photoWorker.sendMessage(msg); }) phototabstatusButton.text=friend.screen_name+qsTr("\'s images") } else { Helperjs.readField("album", root.db, "imageData",login.username,function(albums){ if (albums[0]) { var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false}; photoWorker.sendMessage(msg); } }) } } } function deletepics(method, type,id){ if(method=="delete"){Imagejs.deleteImage(db,login,type, id,filesystem,root,function(){//showFotos("") })} } function updatepic(method,type,id){ if(method=="update"){ Helperjs.readData(db,"imageData",login.username,function(url){ photoStack.push({ item:"qrc:/qml/photoqml/ImageUploadDialog.qml",properties:{attachImageURLs:[url[0].location+url[0].filename],imageId:id,currentAlbum:url[0].album} }) },"id",id)} } function uploadUrls(urls){ photoStack.push({item:"qrc:/qml/photoqml/ImageUploadDialog.qml",properties:{attachImageURLs:urls}}) } ProgressBar{ id: newImagesProgress width: 15*mm height: updatePhotolist.height anchors.top: parent.top anchors.right:uploadPhoto.left anchors.rightMargin:mm visible: false value: fotorectangle.currentimageno/fotorectangle.newimages.length } BlueButton{ id: uploadPhoto anchors.top: parent.top anchors.topMargin: 0.5*mm anchors.right:updatePhotolist.left anchors.rightMargin:mm text:"\uf0ee" onClicked: {print(root.imagePicking) photoStack.push({item:"qrc:/qml/photoqml/ImageUploadDialog.qml",properties:{}}); // var component = Qt.createComponent("qrc:/qml/photoqml/ImageUploadDialog.qml"); // var imageUpload = component.createObject(fotorectangle); }} BlueButton{ id: updatePhotolist anchors.top: parent.top anchors.topMargin: 0.5*mm anchors.right:phototabstatusButton.left anchors.rightMargin:mm text:"\uf0ed" Menu { id:photoupdatemenu MenuItem { text: qsTr("All Images") onTriggered: { Imagejs.requestList(root.login,root.db, false, fotostab,function(obj){fotorectangle.newimages=obj})} } MenuItem { text: qsTr("Only new") onTriggered: { Imagejs.requestList(root.login,root.db, true,fotostab,function(obj){fotorectangle.newimages=obj})} } } onClicked: {photoupdatemenu.popup()} } BlueButton{ id: phototabstatusButton anchors.top: parent.top anchors.topMargin: 0.5*mm anchors.right: parent.right anchors.rightMargin:2*mm text: fotostab.phototabstatus=="Images"?qsTr("Own Images"):fotostab.phototabstatus Menu { id:phototabmenu MenuItem { text: qsTr("Own Images") onTriggered: { fotostab.phototabstatus="Images"; // phototabstatusButton.text=qsTr("Own images"); showFotos(root.login,"")} } } onClicked: {phototabmenu.popup()} } 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:{print(photogroupModel.get(0).foreignPicture); var lastalbum_id=photogroupModel.count-1; if(photogroupModel.get(photogroupModel.count-1).foreignPicture==true){ Imagejs.newRequestFriendsAlbumPictures(login,photogroupModel.get(0).friend,fotorectangle,function(albums,remoteAuthBool){ remoteContact=remoteAuthBool; var msg = {'model': photogroupModel,'albums':albums,'firstalbum':lastalbum_id+1,'foreignPicture':true,'friend':photogroupModel.get(0).friend} 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 { width: parent.width; height:parent.height; model: visualphotoModel.parts.browser; interactive: false } BlueButton { id: backButton text: "\uf057" x: parent.width - backButton.width - 3*mm y: -backButton.height - 4*mm z:2 onClicked: {photoBackground.opacity=0} } ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false } WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"} Component.onCompleted: { root.fotoSignal.connect(showFotos); root.uploadSignal.connect(uploadUrls); root.changeimage.connect(deletepics); root.changeimage.connect(updatepic); if (fotostab.phototabstatus=="Images"){showFotos(root.login,"")} } } }