Version 0.004

This commit is contained in:
LubuWest 2017-05-11 22:15:34 +02:00
commit 438f8a4e4d
64 changed files with 2736 additions and 636 deletions

View file

@ -1,34 +1,106 @@
// ConversationStack with buttons
// ConversationView with button
import QtQuick 2.0
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml"
Rectangle {
id:conversationStack
id:conversationList
property var news
y:1
color: "white"
width:root.width-2*mm
height:root.height-8*mm
z:2
color: "white"
border.color: "grey"
width:root.width-5*mm
height: conversationView.height+10*mm
Connections{
target:newstab
onConversationChanged:{
if(newstab.conversation.length==0){
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy(); conversationsymbol.color="grey"
}
}
}
ListView {
id: conversationView
x:3*mm
y:8*mm
width: conversationStack.width-4*mm
height: conversationStack.height-10*mm
width: conversationList.width-4*mm
height: contentHeight
clip: true
spacing: 0
footer: footerReply
model: conversationModel
delegate: Newsitem{}
}
ListModel{id: conversationModel}
Component { id:footerReply
Rectangle{
border.color: "#EEEEEE"
border.width: 1
color:"lightgrey"
width:conversationView.width
height:Math.max(replyText.contentHeight+2*mm,6*mm)
Rectangle{
color: "white"
radius:0.5*mm
anchors.left: parent.left
anchors.leftMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
width:parent.width-12*mm
height:Math.max( replyText.contentHeight,5*mm)
WorkerScript {
id: conversationWorker
source: "qrc:/js/newsworker.js"
}
TextInput {
id: replyText
font.pixelSize: 3*mm
wrapMode: Text.Wrap
anchors.fill: parent
selectByMouse: true
}
}
BlueButton {
id: sendButton
text: "\uf1d9"
anchors.right: parent.right
anchors.rightMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
color:"white"
onClicked: { try{
var body=replyText.getText(0,replyText.length);
newsBusy.running=true;
replyText.text=""
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
if (conversationModel.get(0).newsitemobject.messagetype==0){
xhr.setParam("source", "Friendiqa");
xhr.url= login.server + "/api/statuses/update.json";
xhr.setParam("status", body);
xhr.setParam("in_reply_to_status_id", conversationModel.get(conversationModel.count-1).newsitemobject.status_id)}
else {xhr.url= login.server + "/api/direct_messages/new.json";
xhr.setParam("text", body);
xhr.setParam("screen_name",conversationModel.get(conversationModel.count-1).newsitemobject.screen_name);
xhr.setParam("replyto", conversationModel.get(conversationModel.count-1).newsitemobject.status_id)
}
xhr.post();
//replyText.text=""
} catch(e){Helperjs.showMessage("Error",e.toString(),root)}
}
}
}
}
ListModel{id: conversationModel}
WorkerScript {
id: conversationWorker
source: "qrc:/js/newsworker.js"
}
BlueButton {
id: closeButton
@ -37,10 +109,11 @@ Rectangle {
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: "\uf057"// qsTr("Close")
text: "\uf057"
onClicked: {
newstab.newstabstatus=login.newsViewType;
newsStack.pop()
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy();
conversationsymbol.color="grey"
}
}

View file

@ -42,12 +42,11 @@ Rectangle{
clip: true
model: imageModel
delegate: imageItem
}
FolderListModel{
id: imageModel
nameFilters: ["*.png", "*.jpg",".jpeg","*.JPG"]
nameFilters: ["*.png", "*.jpg",".jpeg","*.JPG","*.gif"]
sortField: FolderListModel.Time
sortReversed:false
showDotAndDotDot: true
@ -111,8 +110,9 @@ Rectangle{
directory=fileURL
}
else{
attachImageURL=fileURL;
imageDialog.destroy()
attachImageURLs.push(fileURL);
attachImage(fileURL);
imageDialog.destroy()
}
}
}

View file

@ -16,7 +16,7 @@ Flickable{
id:messageSend
property string parentId: ""
property string reply_to_user:""
property string attachImageURL: "";
property var attachImageURLs: [];
property int directmessage: 0;
property var contacts: []
property var groups: []
@ -25,11 +25,13 @@ Flickable{
property var group_allow:login.permissions[2]
property var group_deny:login.permissions[3]
onAttachImageURLChanged: {if(attachImageURL!=""){
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment; source:"'+
attachImageURL.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURL="";imageAttachment.destroy()}}}',messageColumn,"attachedImage");
console.log("You chose: " + attachImageURL)
}}
function attachImage(url){
//onAttachImageURLsChanged: {if(attachImageURL!=""){
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment'+attachImageURLs.length+'; source:"'+
url.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+url+'",1)); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
console.log("You chose: " + url)
}
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
xhr.url= login.server + "/api/statuses/update.json";
xhr.setLogin(login.username+":"+Qt.atob(login.password));
@ -42,7 +44,7 @@ Flickable{
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 )};
if (attachImageURL.length>0) {for (var image in attachImageURL){xhr.setImageFileParam("media", attachImageURL[image] )}};
xhr.post();
}
@ -122,12 +124,11 @@ Flickable{
}
}
Row{
spacing:2
BlueButton{id:permButton
visible: (directmessage==1)?false:true
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"//qsTr("Permissions")
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/newsqml/PermissionDialog.qml");
var permissions = component.createObject(messageColumn);
@ -137,14 +138,14 @@ Flickable{
text: "\uf0c6"
visible:(directmessage==0)
onClicked: {
if (attachImageURL!=""){
Helperjs.showMessage( qsTr("Error"),qsTr("Only one attachment. Remove other attachment first!"), messageColumn)}
else{print(filesystem.homePath);
var defaultDirectory="file://"+osSettings.attachImageDir;//"file:///storage/emif.open()
print(defaultDirectory);
var component = Qt.createComponent("qrc:/qml/newsqml/ImageDialog.qml");
var imagedialog = component.createObject(messageSend,{"directory": defaultDirectory});
}
if (attachImageURLs.length>0){//Server currently accepts only one attachment
Helperjs.showMessage( qsTr("Error"),qsTr("Only one attachment supported at the moment.\n Remove other attachment first!"), messageColumn)
}
else{
var defaultDirectory="file://"+osSettings.attachImageDir;
var component = Qt.createComponent("qrc:/qml/newsqml/ImageDialog.qml");
var imagedialog = component.createObject(messageSend,{"directory": defaultDirectory});
}
}
}
BlueButton{
@ -188,7 +189,7 @@ Flickable{
var title=titleField.text.replace("\"","\'");
var body=bodyField.getText(0,bodyField.length);
if (directmessage==0){
statusUpdate(title,body,messageSend.parentId,attachImageURL.toString())}
statusUpdate(title,body,messageSend.parentId,attachImageURLs)}
else {dmUpdate(title,body,"",messageSend.reply_to_user) }
newstab.newstabstatus=login.newsViewType; newsStack.pop()
}

View file

@ -13,23 +13,13 @@ Item {
}
}
Connections{
target:newstab
onConversationChanged:{
newsBusy.running=false;
newstab.newstabstatus="Conversation";
//newsStack.push({item:"qrc:/qml/newsqml/Conversation.qml",properties:{"news": conversation}})
showNews(conversation);
}
}
Connections{
target:root
onCurrentContactChanged:{
if (root.newContacts.length>0){
if(root.currentContact<root.newContacts.length){
downloadNotice.text= qsTr("Download profile image for ")+ root.newContacts[root.currentContact].name;
print(root.newContacts[root.currentContact].name)
//print(root.newContacts[root.currentContact].name)
}
}else{downloadNotice.text=""}
}
@ -62,23 +52,19 @@ Item {
newsWorker.sendMessage(msg);
}
function showConversation(timelineIndex,newsitemobject){
function showConversation(conversationIndex,newsitemobject){
newsBusy.running=true;
root.contactLoadType="conversation";
newsStack.timelineIndex= timelineIndex;
if(newsitemobject.messagetype==0){
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(ns,nc){
newsStack.conversationIndex= conversationIndex;
if(newsitemobject.messagetype==0){
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(ns,nc){
root.news=ns;root.newContacts=nc;root.currentContact=0;
})}
else{Newsjs.conversationfromdb(root.db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
root.news=newsarray;root.newContacts=[];root.currentContact=1;
})}
else{Newsjs.conversationfromdb(root.db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
root.news=newsarray;root.newContacts=[];root.currentContact=1;
})}
}
function onFriendsMessages(friend){
newstab.newstabstatus="Contact"
Newsjs.newsfromdb(db,root.login.username, function(dbnews){showNews(dbnews)},friend)
@ -92,14 +78,11 @@ Item {
StackView{
id: newsStack
anchors.fill:parent
property int timelineIndex: 0
onTimelineIndexChanged:print("timelineindex:"+ timelineIndex)
property int conversationIndex: 0
initialItem:Rectangle {
initialItem:Rectangle {
y:1
color: "white"
width:root.width-2*mm
height:root.height-8*mm
BlueButton{
id:newstabstatusButton
@ -116,26 +99,27 @@ Item {
anchors.right: parent.right
BlueButton {
id: newMessageButton
width:10*mm
text: "\uf040"
onClicked: {
var groups=[];
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject});
newstab.newstabstatus="SendMessage";
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
},"isFriend",1);
}
}
BlueButton {
id: quitButton
width:10*mm
text: "\uf08b"
onClicked: {Service.cleanNews(root.db,function(){Qt.quit() })}
}
BlueButton {
id: newMessageButton
width:10*mm
text: "\uf040"
onClicked: {
var groups=[];
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject
});
newstab.newstabstatus="SendMessage";
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
},"isFriend",1);
}
}
BlueButton {
id: quitButton
width:10*mm
text: "\uf08b"
onClicked: {Service.cleanNews(root.db,function(){Qt.quit() })}
}
BlueButton {
id: update
text: "\uf021"
onClicked: {
@ -176,7 +160,7 @@ Item {
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
newsWorker.sendMessage(msg);
},false,lastnews_id)}
if(newstab.newstabstatus=="Tree"){
if(newstab.newstabstatus=="Conversations"){
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
Newsjs.chatsfromdb(root.db,root.login.username, function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
@ -191,83 +175,35 @@ Item {
}
}
Component { id:footerReply
Rectangle{
border.color: "#EEEEEE"
border.width: 1
color:"lightgrey"
width:newsView.width
height:Math.max(replyText.contentHeight+2*mm,6*mm)
Rectangle{
color: "white"
radius:0.5*mm
anchors.left: parent.left
anchors.leftMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
width:parent.width-12*mm
height:Math.max( replyText.contentHeight,5*mm)
TextInput {
id: replyText
font.pixelSize: 3*mm
wrapMode: Text.Wrap
//width: parent.width
anchors.fill: parent
selectByMouse: true
}
}
BlueButton {
id: sendButton
text: "\uf1d9"
anchors.right: parent.right
anchors.rightMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
color:"white"
onClicked: { try{
var body=replyText.getText(0,replyText.length);
newsBusy.running=true;
replyText.text=""
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
if (newsModel.get(0).newsitemobject.messagetype==0){
xhr.setParam("source", "Friendiqa");
xhr.url= login.server + "/api/statuses/update.json";
xhr.setParam("status", body);
xhr.setParam("in_reply_to_status_id", newsModel.get(newsModel.count-1).newsitemobject.status_id)}
else {xhr.url= login.server + "/api/direct_messages/new.json";
xhr.setParam("text", body);
xhr.setParam("screen_name",newsModel.get(newsModel.count-1).newsitemobject.screen_name);
xhr.setParam("replyto", newsModel.get(newsModel.count-1).newsitemobject.status_id)
}
xhr.post();
//replyText.text=""
} catch(e){Helperjs.showMessage("Error",e.toString(),root)}
}
}
}
}
ListView {
id: newsView
anchors.fill: parent
anchors.topMargin: 8*root.mm
anchors.topMargin: 7*root.mm
anchors.leftMargin: 3*root.mm; anchors.rightMargin: root.mm
anchors.bottomMargin: 1*root.mm
clip: true
spacing: 0
footer: (newstab.newstabstatus=="Conversation")?footerReply:footerComponent
footer: footerComponent
model: newsModel
delegate: Newsitem{}
Component.onCompleted: {//print(newstab.newstabstatus);
if(newstab.newstabstatus!="Conversation"){
positionViewAtIndex(newsStack.timelineIndex-1, ListView.Beginning)}
else {positionViewAtBeginning();
newsStack.timelineIndex=0
}}
}
//onContentYChanged:{if(contentY<-15*mm&&contentY>(-15*mm-1)){print("refreshing");
onDragEnded:{if(contentY<-8*mm){//print("refreshing");
newsBusy.running=true;
newstab.newstabstatus=login.newsViewType;
root.contactLoadType="news";
var onlynew=true;
Newsjs.getFriendsTimeline(login,db,contactlist,onlynew,newstab,function(ns,nc){
root.news=ns;root.newContacts=nc;root.currentContact=0;
if (ns.length==0){// update last 20 existing news for changes and likes
onlynew=false;
Newsjs.getFriendsTimeline(login,db,contactlist,onlynew,newstab,function(rns,rnc){
root.contactLoadType="news";
root.news=rns;root.newContacts=rnc;root.currentContact=0})
}
})
}}
}
ListModel{id: newsModel}
@ -331,10 +267,10 @@ Item {
}
MenuItem {
text: qsTr("Tree")
text: qsTr("Conversations")
onTriggered:{
newsModel.clear();
newstab.newstabstatus="Tree";
newstab.newstabstatus="Conversations";
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
}
}

View file

@ -7,9 +7,23 @@ import "qrc:/js/helper.js" as Helperjs
Item {
id: newsitem
width: newsView.width
height:Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
width: parent.width
height:toprow.height+friendicaActivities.height+controlrow.height+1//Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
Connections{
target:newstab
onConversationChanged:{
newsBusy.running=false;
if(index==newsStack.conversationIndex){
if(newstab.conversation.length>0){
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
var conversation = component.createObject(friendicaActivities,{"news":newstab.conversation});
}
else{conversationsymbol.color="grey"}
}
}
}
property string attending: ""
onAttendingChanged: {attendLabel.visible=true;
attendLabel.text= qsTr("attending: ")+ qsTr(attending)}
@ -19,9 +33,7 @@ Item {
function showActivityContacts(contacts){
var component = Qt.createComponent("qrc:/qml/newsqml/FriendicaActivities.qml");
var imagedialog = component.createObject(friendicaActivities,{"activitymembers": contacts});
}
Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom; color:"light grey"}
Rectangle{
@ -29,7 +41,8 @@ Item {
height:newsitem.height-1
color: (newsitemobject.messagetype==1)?"#ffe6e6" : "white"
Column {
Row{id:toprow
Column {
id: authorcolumn
width: 8*mm
@ -41,7 +54,7 @@ Item {
height: 7*mm
MouseArea{
anchors.fill: parent
onClicked:{print(root.currentIndex);
onClicked:{
try{root.currentIndex=1;
friendstab.active=true;
root.contactdetailsSignal(newsitemobject.user)} catch (e){Helperjs.showMessage("Error",e,root)}
@ -61,7 +74,7 @@ Item {
Column {
id:newscolumn
width: newsitem.width-8*mm
anchors.left: authorcolumn.right
//anchors.left: authorcolumn.right
Flow{
id:topFlow
@ -92,7 +105,7 @@ Item {
Label {
id:newscountLabel
visible:((newstabstatus=="Tree")&&(newsitemobject.newscount>1))?true:false
visible:((newstabstatus=="Conversations")&&(newsitemobject.newscount>1))?true:false
color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
@ -117,12 +130,25 @@ Item {
wrapMode: Text.Wrap
onLinkActivated:{
Qt.openUrlExternally(link)}
Component.onCompleted:{
if (newsitemobject.attachmentList.length>0){
for(var attachments in newsitemobject.attachmentList){// (newsitemobject.attachmentList[attachments].url);
var attachcomponent = Qt.createQmlObject('import QtQuick 2.0; '+
'AnimatedImage {id:gif;source: "'+newsitemobject.attachmentList[attachments].url+
'";onStatusChanged: playing = (status == AnimatedImage.Ready)}',
friendicaActivities,"Attachment"+attachments);
}
}
}
}
Flow{
}
}
Flow{
id:friendicaActivities
anchors.top:toprow.bottom
width:parent.width
spacing:mm
Label{color: "grey"
font.pixelSize: 1.5*mm
text: friendica_activities.likeText
@ -162,11 +188,22 @@ Item {
onClicked: { showActivityContacts(newsitemobject.attendmaybe)}
}
}
Label{
id:attendLabel
//visible: false
color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
horizontalAlignment: Label.AlignRight
text: (friendica_activities.self.attending)?(qsTr("Attending: ")+ qsTr(friendica_activities.self.attending)):""
}
}
Row{
Row{id:controlrow
anchors.top:friendicaActivities.bottom
CheckBox{
id:likeCheckbox
height:3*mm
//height:3*mm
width:8*mm
visible: (newsitemobject.messagetype==0)? true:false
checked:(friendica_activities.self.liked==1)?true:false
@ -195,7 +232,7 @@ Item {
}
CheckBox{
id: dislikeCheckbox
height:3*mm
//height:3*mm
width:8*mm
visible: (newsitemobject.messagetype==0)? true:false
checked: (friendica_activities.self.disliked==1)?true:false
@ -222,10 +259,30 @@ Item {
if (dislikeCheckbox.checked==true){Newsjs.like(root.login,root.db,1,"dislike",newsitemobject.status_id,root);likeCheckbox.checked=false; model.friendica_activities.self.disliked=0}
else {Newsjs.like(root.login,root.db,0,"dislike",newsitemobject.status_id,root); model.friendica_activities.self.disliked=1}}
}
// Rectangle{
// width: 8*mm
// height: 3*mm
// color:"transparent"
// Text{
// id:trashsymbol
// color: "grey"
// anchors.centerIn: parent
// font.pixelSize: 2*mm
// font.bold: true
// text: "\uf1f8"
// }
// MouseArea{
// anchors.fill:parent
// onClicked: {
// Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,newsitemobject.messagetype,root,function(reply){
// newsModel.remove(index)})
// }}
// }
CheckBox {
id:favoritedCheckbox
visible:(newsitemobject.messagetype==0)
width: 7*mm
width: 8*mm
style: CheckBoxStyle {
background: Rectangle {
implicitWidth: 6*mm
@ -251,7 +308,7 @@ Item {
}
}
Rectangle{
width: 7*mm
width: 8*mm
height: 3*mm
color:"transparent"
Text{
@ -267,7 +324,7 @@ Item {
onClicked: {newsmenu.popup()}}
}
Rectangle{
width: 7*mm
width: 8*mm
height: 3*mm
visible:newstab.newstabstatus!="Conversation"
color:"transparent"
@ -281,20 +338,15 @@ Item {
}
MouseArea{
anchors.fill:parent
onClicked: { conversationsymbol.color="black";showConversation(index,newsitemobject)}
onClicked:{
conversationsymbol.color="black";
showConversation(index,newsitemobject)
}
}
}
Label{
id:attendLabel
//visible: false
color: "grey"
height:3.5*mm
font.pixelSize: 1.5*mm
horizontalAlignment: Label.AlignRight
text: (friendica_activities.self.attending)?(qsTr("Attending: ")+ qsTr(friendica_activities.self.attending)):""
}
}
}
Menu {
id:newsmenu
MenuItem {
@ -350,6 +402,4 @@ Item {
}
}
}
}
}
}}

View file

@ -32,7 +32,7 @@ Rectangle{
Text{
x:0.5*mm
y:0.5*mm
text: "Contacts"
text: qsTr("Friends")
}
ListView {
id: contactView
@ -93,7 +93,7 @@ Rectangle{
Text{
x:contactView.width+2*mm
y:0.5*mm
text: "Groups"
text: qsTr("Groups")
}
ListView {
id: groupView