Friendiqa v0.2

This commit is contained in:
LubuWest 2018-02-19 22:36:00 +01:00
commit a3be940192
123 changed files with 9156 additions and 2455 deletions

View file

@ -1,3 +1,34 @@
// This file is part of Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
//
// 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 <http://www.gnu.org/licenses/>.
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/js/service.js" as Service
@ -15,28 +46,24 @@ Rectangle{
property var group_deny:login.permissions[3]
property int imageNo: 0
function attachImage(url){
var attachIndex=attachImageURLs.indexOf(url);
if(attachIndex>-1){
imageUploadModel.append({"imageUrl":url.toString(),"description":""})
}
else{imageUploadModel.remove(attachImage)}
}
function uploadSelectedImage(inumber){
xhr.url= login.server + "/api/friendica/photo/create.json";
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.clearParams();
xhr.setParam("desc",imageUploadModel.get(inumber).description);
xhr.setParam("album", album.currentText);
if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
//if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
//if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
//if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
//if (contact_deny.length>0) {xhr.setParam("contact_deny", Helperjs.cleanArray(contact_deny))};
xhr.setImageFileParam("media", imageUploadModel.get(inumber).imageUrl );
xhr.post();
}
function attachImage(url){
imageUploadModel.append({"imageUrl":url,"description":""})
}
z:2
border.color: "grey"
width: parent.width-4*mm
@ -48,8 +75,7 @@ Rectangle{
Connections{
target:xhr
onError:{print(data)}//if (data=="image"){Helperjs.showMessage()}}
onSuccess:{//print("Bild hochgeladen "+data+" aktuelleBild "+imageNo);
print(imageNo+" "+imageUploadModel.count);
onSuccess:{
imageNo=imageNo+1;
if(imageNo<imageUploadModel.count){
uploadSelectedImage(imageNo);
@ -71,14 +97,14 @@ Rectangle{
anchors.rightMargin: 1*mm
spacing:mm
BlueButton{
id:permButton
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
onClicked: {
var component = Qt.createComponent("qrc:/qml/genericqml/PermissionDialog.qml");
var permissions = component.createObject(imageDialog,{"x":mm,"y":7*mm});
}
}
// BlueButton{
// id:permButton
// text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
// onClicked: {
// var component = Qt.createComponent("qrc:/qml/genericqml/PermissionDialog.qml");
// var permissions = component.createObject(imageDialog,{"x":mm,"y":40*mm});
// }
// }
BlueButton{
id:closeButton
@ -106,11 +132,12 @@ Rectangle{
id: imageUploadView
x:23*mm
y:17*mm
width: imageDialog.width-2*mm
width: imageDialog.width-25*mm
height: 25*mm
model: imageUploadModel
delegate: imageDelegate
footer: imageFooter
clip:true
orientation: ListView.Horizontal
spacing: mm
}
@ -133,8 +160,10 @@ Rectangle{
MouseArea{
anchors.fill: parent
onClicked:{
attachImageURLs.splice(attachImageURLs.indexOf(imageUrl,1))
attachImage(imageUrl)}
imageUploadModel.remove(index)
// attachImageURLs.splice(attachImageURLs.indexOf(imageUrl,1))
// attachImage(imageUrl)
}
}
}
@ -164,9 +193,11 @@ Rectangle{
MouseArea{
anchors.fill: parent
onClicked:{
var defaultDirectory="file://"+osSettings.attachImageDir;
var component = Qt.createComponent("qrc:/qml/genericqml/ImageDialog.qml");
var imagedialog = component.createObject(imageDialog,{"directory": defaultDirectory, "multiSelection": true});}
var imagePicker = Qt.createQmlObject('import QtQuick 2.0; import "qrc:/qml/genericqml";'+
osSettings.imagePickQml+'{multiple : false;onReady: {attachImageURLs.push(imageUrl);'+
'attachImage(imageUrl)}}',imageDialog,"imagePicker");
imagePicker.pickImage()
}
}
}
}
@ -196,7 +227,7 @@ Rectangle{
//imageBusy.running=true;
if(album.currentText==""){Helperjs.showMessage(qsTr("Error"),qsTr(" No album name given"), imageDialog)}
else{newimageProgress.visible=true;
if (attachImageURLs.length>0){
if (imageUploadModel.count>0){
uploadSelectedImage(0)
}}
}
@ -209,13 +240,12 @@ Rectangle{
anchors.right:buttonRow.left
anchors.rightMargin:mm
visible: false
value: imageNo/attachImageURLs.length
value: imageNo/imageUploadModel.count
}
Component.onCompleted:{
albumModel.append({"text":""});
try{Helperjs.readField("album",db,"imageData",login.username,function(storedAlbums){
//print(JSON.stringify(storedAlbums))
for (var n in storedAlbums){
albumModel.append({"text":storedAlbums[n]})}
})}