Version 0.002 with working Permissions

This commit is contained in:
LubuWest 2016-12-04 18:28:52 +01:00
commit 15e2e8f60a
62 changed files with 924 additions and 1277 deletions

View file

@ -1,44 +0,0 @@
import QtQuick 2.0
import QtMultimedia 5.0
import QtQuick.Controls 1.2
Item {
Rectangle {
VideoOutput {
anchors.fill: parent
source: localCamera
}
Camera {
id: localCamera
}
Button {
id: shotButton
width: 200; height: 75
text: "Take Photo"
onClicked: {
localCamera.imageCapture.capture();
} }
Connections {
target: localCamera.imageCapture
onImageSaved: {
photofile= imagePaths.append({"path": path})
listView.positionViewAtEnd(); }
}
Image {
id: photoFromCamera
anchors.fill: parent
fillMode: Image.PreserveAspectFit
source: photo
}
Button {
text: "Upload"
onClicked:{
var login=Service.readActiveConfig(db);
img.src=file;
Service.Upload(login,file)
}
}
}
}

View file

@ -1,137 +0,0 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
Item {
id: contactComponent
property var createdAtDate: new Date(contact.created_at)
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Label {
id: namelabel
x: 1
width: wrapper.width-4
height: 3*mm
text: contact.screen_name
elide:Text.ElideRight
anchors.topMargin: 0
anchors.left: photoImage.left
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
//print("State: "+ friendComponent.state);
contactComponent.state="large"}
}
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
opacity: 0
Flickable{
id:namelabelflickable
width: root.width-10*mm
height:friendsTabView.height-55*mm
boundsBehavior:Flickable.StopAtBounds
flickableDirection:Flickable.VerticalFlick
contentWidth:width
contentHeight: namelabeltext.height
clip:true
Text{
id:namelabeltext
//anchors.top: parent.top
width: namelabelflickable.width
height: implicitHeight
font.pixelSize: 3*mm
textFormat:Text.RichText
wrapMode: Text.Wrap
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
}
Row{
anchors.top: namelabelflickable.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:contact.location=="Friendica"? 1:0
onClicked:{contactComponent.state="";
root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(contact) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{contactComponent.state="";
root.currentIndex=0;
newstab.active=true;
root.messageSignal(contact.id) ;
}
}
Button{
id:dmbutton
visible: contact.following=="true"?true:false
text: "DM"
onClicked:{contactComponent.state="";
root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(contact.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{contactComponent.state=""}
}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
PropertyChanges { target: contactComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
]
}

View file

@ -1,133 +0,0 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import "qrc:/js/service.js" as Service
import "qrc:/js/layout.js" as Layoutjs
Item {
id: friendComponent
property date createdAtDate: new Date(friend.created_at)
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:"file://"+ friend.profile_image
}
Label {
id: namelabel
x: 1
width: wrapper.width-4
height: 3*mm
text: friend.screen_name
anchors.topMargin: 0
anchors.left: photoImage.left
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
//print("State: "+ friendComponent.state);
friendComponent.state="large"}
}
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
opacity: 0
Flickable{
id:namelabelflickable
width: root.width-10*mm
height:wrapper.height-27*mm-3
boundsBehavior:Flickable.StopAtBounds
flickableDirection:Flickable.VerticalFlick
contentWidth:width
contentHeight: namelabeltext.height
clip:true
Text{
id:namelabeltext
//anchors.top: parent.top
width: namelabelflickable.width
height: implicitHeight
font.pixelSize: 3*mm
textFormat:Text.RichText
wrapMode: Text.Wrap
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(friend.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+friend.location+"<br> <b>"+qsTr("Posts")+":</b> "+friend.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ friend.url+"'>"+friend.url+"</a><br> <b>"+
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
}
Row{
anchors.top: namelabelflickable.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:friend.location=="Friendica"? 1:0
onClicked:{root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(friend) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{root.currentIndex=0;
newstab.active=true;
root.messageSignal(friend.id) ;
}
}
Button{
id:dmbutton
visible: friend.following=="true"?true:false
text: "DM"
onClicked:{root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(friend.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{friendComponent.state=""}
}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
PropertyChanges { target: friendComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-14*mm}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:friendComponent.GridView.view;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
]
}

View file

@ -1,126 +0,0 @@
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
Rectangle{
id:permissionDialog
width: 80*mm
height:root.height/3
Text{
x:0.5*mm
y:0.5*mm
text: "Contacts"
}
ListView {
id: contactView
x:0.5*mm
y:5.5*mm
width: 39*mm
height:permissionDialog.height-14*mm
clip: true
spacing: 0
model: contactModel
delegate: contactItem
}
ListModel{id: contactModel}
Component{
id:contactItem
Rectangle{
id:contactitemRect
width:contactView.width
height: 5*mm
property string contactstatus:""
color: "light blue"
border.color:"grey"
Text{
color:"grey"
text:contact.screen_name
}
onContactstatusChanged:
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
MouseArea{
anchors.fill: parent}
}
}
Text{
x:20*mm
y:0.5*mm
text: "Groups"
}
ListView {
id: groupView
x:20*mm
y:5.5*mm
width: 19*mm
height:permissionDialog-8*mm
clip: true
spacing: 0
model: groupModel
delegate: groupItem
}
ListModel{id: groupModel}
Component{
id:groupItem
Rectangle{
id:groupitemRect
width:groupView.width
height: 5*mm
property string groupstatus:""
color: "white"
border.color:"grey"
Text{
color:"grey"
text:group.groupname
}
onGroupstatusChanged:
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
MouseArea{
anchors.fill: parent
onClicked:{
if(groupModel.get(index).groupstatus=="neutral"){
groupModel.setProperty(index,"groupstatus","positive")}
else if (groupModel.get(index).groupstatus=="positive"){
groupModel.setProperty(index,"groupstatus","negative")}
else{groupModel.setProperty(index,"groupstatus","neutral")}
}}
}
}
Button{
anchors.horizontalCenter: parent.hoizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin:1
text:qsTr("Done")
onClicked:{var group_allow=[];
for (var i=0;i<groupModel.count;i++)
{if (groupModel.get(i).groupstatus=="positive"){
group_allow.append(groupModel.get(i).groupname)
}
}
print("groups"+JSON.stringify(group_allow))
permissionDialog.destroy();
}
}
Component.onCompleted:{
print("permissiondialog completed");
Helperjs.readData(db,"contacts",login.username,function(contacts){
for (var name in contacts){
print("contact: "+JSON.stringify(contacts[name]));
contactModel.append({"contact":contacts[name]})
}},"isFriend",1);
Helperjs.readData(db,"groups",login.username,function(owngroups){
for (var number in owngroups){
groupModel.append({"group":owngroup[number]})
}});
}
}

View file

@ -1,48 +0,0 @@
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
Item {
Rectangle{
property string photofile:"../images/Update.png"
color: "grey"
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.pictures
selectMultiple: true
onAccepted: {
photofile=fileDialog.fileUrls[0];
console.log("You chose: " + fileDialog.fileUrls)
// img.src=file;
}
onRejected: {
console.log("Canceled")
}
}
Component.onCompleted: {fileDialog.open()}
Image {
id: photoFromFilesystem
x: 20;y:50
height: 200
fillMode: Image.PreserveAspectFit
source: photofile
onStatusChanged:{
if (photoFromFilesystem.status == Image.Ready) {
Layoutjs.showFriends(db)
}
}
Button {
text: "Upload"
onClicked:{
var login=Service.readActiveConfig(db);
Service.uploadMedia(login,photofile, function(returnvalue){print("Upload return"+returnvalue)})
}}
}
}
}

View file

@ -4,7 +4,7 @@ import QtQuick.Controls 1.2
import "qrc:/js/service.js" as Service
import "qrc:/js/layout.js" as Layoutjs
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml"
import "qrc:/qml/configqml"
StackView{
id: configStack
@ -192,7 +192,9 @@ onCurrentIndexChanged:{
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
var serverString=obj;
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
usermodel.append({text:username.text});
Helperjs.readField("username",root.db,"config","",function(users){
if(users.indexOf(username.text)==-1){usermodel.append({text:username.text})}});
isActiveField.text="yes"
//reset values
root.login=userconfig;
root.contactlist=[];
@ -232,7 +234,7 @@ onCurrentIndexChanged:{
x: root.width/2+14*mm; y: mm; width: 5*mm; height: 5*mm;
text: "?"
onClicked:{
configStack.push({item:"qrc:/qml/InfoBox.qml"});
configStack.push({item:"qrc:/qml/configqml/InfoBox.qml"});
}
}

View file

@ -0,0 +1,65 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import "qrc:/js/layout.js" as Layoutjs
Item {
id: contactComponent
property var createdAtDate: new Date(contact.created_at)
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Label {
id: namelabel
x: 1
width: wrapper.width-4
height: 3*mm
text: contact.screen_name
elide:Text.ElideRight
anchors.topMargin: 0
anchors.left: photoImage.left
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
contactComponent.state="large";
var component = Qt.createComponent("qrc:/qml/contactqml/ContactDetailsComponent.qml");
if (component.status== Component.Ready){
var contactDetails = component.createObject(wrapper,{"contact": contact})}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
PropertyChanges { target: contactComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
}
]
}

View file

@ -0,0 +1,77 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
//opacity: 0
Flickable{
id:namelabelflickable
width: root.width-10*mm
height:friendsTabView.height-55*mm
boundsBehavior:Flickable.StopAtBounds
flickableDirection:Flickable.VerticalFlick
contentWidth:width
contentHeight: namelabeltext.height
clip:true
Text{
id:namelabeltext
width: namelabelflickable.width
height: implicitHeight
font.pixelSize: 3*mm
textFormat:Text.RichText
wrapMode: Text.Wrap
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
}
Row{
anchors.top: namelabelflickable.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:contact.location=="Friendica"? 1:0
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(contact) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=0;
newstab.active=true;
root.messageSignal(contact.id) ;
}
}
Button{
id:dmbutton
visible: contact.following=="true"?true:false
text: "DM"
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(contact.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{contactComponent.state="";detailsrectangle.destroy()}
}
}
}

View file

@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.4
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/news.js" as Newsjs
import "qrc:/qml"
import "qrc:/qml/contactqml"
Rectangle {
y:1

View file

@ -16,10 +16,10 @@ import "qrc:/qml"
TabView{
id:root
tabPosition: Qt.BottomEdge
width: 400//Screen.desktopAvailableWidth
height: 400// Screen.desktopAvailableHeight
width: 500//Screen.desktopAvailableWidth
height: 500// Screen.desktopAvailableHeight
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
property var db: ["Friendiqa", "1.0", "Stores Friendica data", 100000000]
property var login: Service.readActiveConfig(db)
property var contactlist: []
property real mm: Screen.pixelDensity
@ -44,7 +44,7 @@ TabView{
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
}
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
//print("Current contact"+JSON.stringify(newContacts[currentContact])+newContacts.length);
if(currentContact<newContacts.length){
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
@ -67,22 +67,23 @@ TabView{
}
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
if (isFriend==1){
var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
// if (isFriend==1){
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
xhr.setFilename(imagename);
xhr.download();
}
//}
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
var result;
db.transaction( function(tx) {
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
result = tx.executeSql('SELECT * from contacts where username="'+root.login.username+'" AND id = '+contact.id); // check for news id
if(result.rows.length === 1) {// use update
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where username="'+root.login.username+'" AND id='+contact.id);
} else {// use insert
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
});
if (isFriend!=1){root.currentContact=root.currentContact+1}
//if (isFriend!=1){root.currentContact=root.currentContact+1}
}
Connections{
@ -91,7 +92,14 @@ TabView{
}
Connections{
target:xhr
onError:{print("Error"+data)}
onError:{print("Error"+data);
var database=LocalStorage.openDatabaseSync(root.db[0],root.db[1],root.db[2],root.db[3]);
var result;
database.transaction( function(tx) {
print("Error for "+JSON.stringify(newContacts[currentContact]));
//print('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
result = tx.executeSql('UPDATE contacts SET profile_image="" where username="'+root.login.username+'" AND id = '+newContacts[currentContact].id);
root.currentContact=root.currentContact+1})}
}
Component.onCompleted: {
if (login==""){Service.initDatabase(db)}
@ -121,24 +129,24 @@ style: TabViewStyle {
title: qsTr("News")
id: newstab
property string newstabStatus:"news"
source: "qrc:/qml/NewsTab.qml"
source: "qrc:/qml/newsqml/NewsTab.qml"
}
Tab{
title: qsTr("Contacts")
id: friendstab
source: "qrc:/qml/FriendsTab.qml"
source: "qrc:/qml/contactqml/FriendsTab.qml"
}
Tab{
title: qsTr("Photos")
id: fotostab
source: "qrc:/qml/PhotoTab.qml"
source: "qrc:/qml/photoqml/PhotoTab.qml"
}
Tab{
title: qsTr("Config")
source: "qrc:/qml/ConfigTab.qml"
source: "qrc:/qml/configqml/ConfigTab.qml"
}
}

View file

@ -17,20 +17,23 @@ Item{
property int directmessage: 0;
property var contacts: []
property var groups: []
property string contact_allow:""
property string contact_deny:""
property string group_allow:""
property string group_deny:""
property var contact_allow:[]
property var contact_deny:[]
property var group_allow:[]
property var group_deny:[]
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
xhr.url= login.server + "/api/statuses/update.xml";
xhr.setLogin(login.username+":"+Qt.atob(login.password));
print("login: "+login.username+":"+Qt.atob(login.password));
xhr.clearParams();
xhr.setParam("source", "Friendiqa");
xhr.setParam("status", status);
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentid)};
if (parentId!="") {xhr.setParam("in_reply_to_status_id", parentId)};
if (title!=="") {xhr.setParam("title", title)};
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 (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )};
xhr.post();
}
@ -63,7 +66,7 @@ Item{
width: parent.width
height: 30*mm
wrapMode: TextEdit.Wrap
textFormat: TextEdit.RichText
textFormat: TextEdit.PlainText
}
Row{
@ -118,12 +121,11 @@ Item{
Row{
spacing:2
Button{
visible: (directmessage==1)?false:true
text:qsTr("Permissions")
onClicked: {
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
var sprite = component.createObject(messageColumn);
if (sprite == null) { // Error Handling
console.log("Error creating object"); }
var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml");
var permissions = component.createObject(messageColumn);
}}
Button {
id: attachButton
@ -169,7 +171,9 @@ Item{
}
}
}
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
stackView.pop(); event.accepted = true;
}}
FileDialog {
id: imageAttachmentDialog
title: "Please choose a picture"

View file

@ -22,7 +22,7 @@ Item {
function onDirectMessage(friend){
print(root.login.server);
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
}
function cleanNews(database){
@ -43,9 +43,16 @@ Item {
id: newsStack
anchors.fill:parent
focus: true
Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
Keys.onReleased: {if (event.key === Qt.Key_Back && stackView.depth > 1) {
stackView.pop(); event.accepted = true;
}
}
else if(event.key === Qt.Key_Back &&newstabStatus=="conversation"){
newstabStatus="news"
newsModel.clear();
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
showNews(dbnews)
})}
}
initialItem:Rectangle {
y:1
color: "white"
@ -68,10 +75,9 @@ Item {
else if (currentIndex==1){
newsBusy.running=true;
Newsjs.requestFavorites(root.login,db,root,function(news){
JSON.stringify("Favorites: "+news);
Newsjs.storeNews(root.login,root.db,news,root,function(){
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
showNews(newsarray)
});
}
@ -89,7 +95,7 @@ Item {
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject});
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
},"isFriend",1);
}
}
@ -166,9 +172,9 @@ Item {
}
BusyIndicator{
id: newsBusy
anchors.centerIn:update
//anchors.right: update.left
//anchors.top:parent.top
anchors.horizontalCenter: newsView.horizontalCenter
anchors.top:parent.top
anchors.topMargin: 2*mm
width:7*mm
height: 7*mm
}

View file

@ -29,7 +29,7 @@ Item {
Image {
id:profileImage
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
source: (newsitemobject.user.profile_image!="")? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
x:1
width: 7*mm
height: 7*mm
@ -91,12 +91,6 @@ Item {
}}
}
checked:(newsitemobject.favorited>0)
Text{
anchors.left: parent.right
color: "grey"
font.pixelSize: 1.5*mm
text: (newsitemobject.favorited>0)? newsitemobject.favorited+qsTr(" Favorites"):""
}
onClicked:{
if(favoritedCheckbox.checkedState==Qt.Checked)
{Newsjs.favorite(login,true,newsitemobject.status_id,root)}
@ -125,6 +119,7 @@ Item {
Rectangle{
width: 4*mm
height: 3*mm
visible:(newsitemobject.in_reply_to_status_id!="")?true:false
Text{
id:conversationsymbol
color: "grey"
@ -138,17 +133,18 @@ Item {
newsBusy.running=true;
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
for (var i=0;i<newContacts.length;i++){
root.updateContactInDB(root.login,root.db,0,newContacts[i])
}
Newsjs.storeNews(root.login,root.db,news,root,function(){
var currentTime= new Date();
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
newsModel.clear();
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
newsWorker.sendMessage(msg);
newsBusy.running=false
});
}
root.updateContactInDB(root.login,root.db,0,newContacts[i])
}
Newsjs.storeNews(root.login,root.db,news,root,function(){
var currentTime= new Date();
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
newsModel.clear();
newstab.newstabStatus="conversation";
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
newsWorker.sendMessage(msg);
newsBusy.running=false
})
}
)})
}}
}}
@ -192,6 +188,7 @@ Item {
CheckBox{id:likeCheckbox
height:3*mm
width:8*mm
visible: (newsitemobject.messagetype==0)? true:false
checked:(friendica_activities.self.liked)?true:false
style: CheckBoxStyle {
background: Rectangle {
@ -218,6 +215,7 @@ Item {
CheckBox{id: dislikeCheckbox
height:3*mm
width:8*mm
visible: (newsitemobject.messagetype==0)? true:false
checked: (friendica_activities.self.disliked)?true:false
style: CheckBoxStyle {
background: Rectangle {
@ -267,7 +265,9 @@ Item {
MenuItem {
text: qsTr("Reply")
onTriggered: {
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
var directmessage=0;
if (newsitemobject.messagetype==1){ directmessage=1}
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login,"directmessage":directmessage}});
}
}
MenuItem {
@ -325,7 +325,7 @@ Menu{
MenuItem {
text: qsTr("Delete")
onTriggered: {
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
print("Deleted "+reply);
newsModel.remove(index);
})

View file

@ -0,0 +1,156 @@
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
Rectangle{
id:permissionDialog
x: mm
width: messageColumn.width-5*mm
height:root.height/3
Text{
x:0.5*mm
y:0.5*mm
text: "Contacts"
}
ListView {
id: contactView
x:0.5*mm
y:5.5*mm
width: permissionDialog.width/2-2*mm
height: permissionDialog.height-14*mm
clip: true
spacing: 1
model: contactModel
delegate: contactItem
}
ListModel{id: contactModel}
Component{
id:contactItem
Rectangle{
id:contactitemRect
width:contactView.width
height: 5*mm
property string contactstatus:"neutral"
onContactstatusChanged:
{if(contactstatus=="positive"){contactitemRect.color="light green"}
else if (contactstatus=="negative"){contactitemRect.color= "light red"}
else{contactitemRect.color= "white"}}
color: "white"
border.color:"grey"
Text{
color:"grey"
text:contact.screen_name
}
MouseArea{
anchors.fill: parent
onClicked:{
if(contactModel.get(index).contactstatus=="neutral"){
contactModel.set(index,{"contactstatus":"positive"});
contactstatus="positive"
}
else if (contactModel.get(index).contactstatus=="positive"){
contactModel.set(index,{"contactstatus":"negative"})
contactstatus="negative"
}
else{contactModel.set(index,{"contactstatus":"neutral"});
contactstatus="neutral";
}
}}
}
}
Text{
x:contactView.width+2*mm
y:0.5*mm
text: "Groups"
}
ListView {
id: groupView
x:contactView.width+2*mm
y:5.5*mm
width: permissionDialog.width/2-2*mm
height: permissionDialog.height-14*mm
clip: true
spacing: 1
model: groupModel
delegate: groupItem
}
ListModel{id: groupModel}
Component{
id:groupItem
Rectangle{
id:groupitemRect
width:groupView.width
height: 5*mm
property string groupstatus:"neutral"
onGroupstatusChanged:
{if(groupstatus=="positive"){groupitemRect.color="light green"}
else if (groupstatus=="negative"){groupitemRect.color= "light red"}
else{groupitemRect.color= "white"}}
color: "white"
border.color:"grey"
Text{
color:"grey"
text:group.groupname
}
MouseArea{
anchors.fill: parent
onClicked:{
if(groupModel.get(index).groupstatus=="neutral"){
groupModel.set(index,{"groupstatus":"positive"});
groupstatus="positive"}
else if (groupModel.get(index).groupstatus=="positive"){
groupModel.set(index,{"groupstatus":"negative"});
groupstatus="negative"}
else{groupModel.set(index,{"groupstatus":"neutral"})
groupstatus="neutral"}
}}
}
}
Button{
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin:1
text:qsTr("Done")
onClicked:{//var group_allow=[];var group_deny=[];
for (var i=0;i<groupModel.count;i++)
{if (groupModel.get(i).groupstatus=="positive"){
group_allow.push(groupModel.get(i).group.gid)
}
if (groupModel.get(i).groupstatus=="negative"){
group_deny.push(groupModel.get(i).group.gid)
}
}
for (var j=0;j<contactModel.count;j++)
{//print("contact: "+JSON.stringify(contactModel.get(j).contact));
if (contactModel.get(j).contactstatus=="positive"){
print(JSON.stringify(contact_allow));
contact_allow.push(contactModel.get(j).contact.cid)
}
if (contactModel.get(j).contactstatus=="negative"){
contact_deny.push(contactModel.get(j).contact.cid)
}
}
//print("contacts: "+Helperjs.cleanArray(contact_allow))
permissionDialog.destroy();
}
}
Component.onCompleted:{
Helperjs.readData(db,"contacts",login.username,function(contacts){
for (var name in contacts){
contactModel.append({"contact":contacts[name],"contactstatus":"neutral"})
}},"isFriend",1);
Helperjs.readData(db,"groups",login.username,function(owngroups){
for (var number in owngroups){
groupModel.append({"group":owngroups[number],"groupstatus":"neutral"})
}});
}
}

View file

@ -4,7 +4,7 @@ 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"
import "qrc:/qml/photoqml"
Rectangle {
id:fotorectangle