forked from lubuwest/Friendiqa
v0.5.1
This commit is contained in:
parent
01e9ae06f4
commit
7119d5bdf4
292 changed files with 790 additions and 16347 deletions
|
@ -47,6 +47,7 @@ Rectangle{
|
|||
id:messageSend
|
||||
visible:(newsSwipeview.stacktype!="Notifications")?true:false
|
||||
property string parentId: ""
|
||||
property bool textfocus: false
|
||||
//property var parentObject:({})
|
||||
property bool conversation: false
|
||||
property string reply_to_user:""
|
||||
|
@ -55,21 +56,23 @@ Rectangle{
|
|||
//property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property var contact_allow:login.permissions[0]
|
||||
property var contact_deny:login.permissions[1]
|
||||
property var group_allow:login.permissions[2]
|
||||
property var group_deny:login.permissions[3]
|
||||
property var contact_allow:login.hasOwnProperty("permissions")?login.permissions[0]:[]
|
||||
property var contact_deny:login.hasOwnProperty("permissions")?login.permissions[1]:[]
|
||||
property var group_allow:login.hasOwnProperty("permissions")?login.permissions[2]:[]
|
||||
property var group_deny:login.hasOwnProperty("permissions")?login.permissions[3]:[]
|
||||
|
||||
onReply_to_userChanged: {
|
||||
if (reply_to_user!=""){
|
||||
receiverLabel.visible=true
|
||||
}
|
||||
}
|
||||
// onReply_to_userChanged: {
|
||||
// if (reply_to_user!=""){
|
||||
// print("reply "+reply_to_user)
|
||||
// //receiverLabel.visible=true
|
||||
// receiverLabel.text=reply_to_user
|
||||
// }
|
||||
// }
|
||||
|
||||
function directmessagePrepare(friend){
|
||||
messageSend.state="active";
|
||||
reply_to_user=friend.screen_name;
|
||||
receiverLabel.text=qsTr("to:")+ " "+ friend.screen_name;
|
||||
receiverLabel.text=friend.screen_name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,9 +97,10 @@ Rectangle{
|
|||
|
||||
|
||||
function attachImage(url){
|
||||
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment'+attachImageURLs.length+'; source:"'+
|
||||
url.toString()+'"; x:2*mm; width: 45*mm; height: 45*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+
|
||||
url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
|
||||
imageAttachment.source=url.toString();
|
||||
// var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment'+attachImageURLs.length+'; source:"'+
|
||||
// url.toString()+'"; x:2*mm; width: 45*mm; height: 45*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+
|
||||
// url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
|
||||
}
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
|
@ -114,7 +118,12 @@ Rectangle{
|
|||
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.length>0) {for (var image in attachImageURL){xhr.setImageFileParam("media", attachImageURL[image] )}};
|
||||
if (attachImageURL.length>0) {
|
||||
for (var image in attachImageURL){
|
||||
xhr.setImageFileParam("media", attachImageURL[image]);
|
||||
xhr.setImageFileParam("angle", rotator.angle.toString());
|
||||
}
|
||||
};
|
||||
xhr.post();
|
||||
}
|
||||
|
||||
|
@ -137,35 +146,24 @@ Rectangle{
|
|||
if (newsitemobject!=""){
|
||||
messageSend.state="conversation"
|
||||
reply_to_user=newsitemobject.user.screen_name;
|
||||
receiverLabel.text=qsTr("to:")+ " "+ newsitemobject.user.screen_name;
|
||||
parentId=newsitemobject.id
|
||||
} else {
|
||||
messageSend.state=""
|
||||
reply_to_user="";
|
||||
receiverLabel.text=qsTr("to:");
|
||||
parentId="";
|
||||
bodyField.text="";
|
||||
attachImageURLs.pop();
|
||||
try{imageAttachment.destroy()}catch(e){}
|
||||
imageAttachment.source=""
|
||||
}
|
||||
}
|
||||
|
||||
function contactmenu(letter){
|
||||
Newsjs.listFriends(login,db,function(contacts){
|
||||
var contactitems="";
|
||||
contactModel.clear();
|
||||
for (var i=0;i<contacts.length;i++){
|
||||
if(Helperjs.getCount(db,login,"contacts","screen_name",contacts[i].screen_name)>1){
|
||||
contacts[i].screen_name=contacts[i].screen_name+"+"+contacts[i].cid
|
||||
}
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+
|
||||
"'; onTriggered:{if (newsSwipeview.stacktype=='DirectMessages'){reply_to_user='"+
|
||||
contacts[i].screen_name+"'} else {bodyField.insert("+
|
||||
bodyField.cursorPosition+",' "+contacts[i].screen_name.substring(1)+" ');bodyField.cursorPosition=bodyField.cursorPosition+"+contacts[i].screen_name.length+"}}}"
|
||||
//}
|
||||
contactModel.append({"contact":contacts[i]})
|
||||
}
|
||||
var menuString="import QtQuick.Controls 2.4; Menu {width:40*mm; font.pixelSize: 3*mm; "+contactitems+"}";
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageColumn,"contactmenuOutput");
|
||||
if (contacts.length>0){contactlistObject.popup()}
|
||||
contactSelector.visible=true
|
||||
},letter);
|
||||
}
|
||||
// Flickable{
|
||||
|
@ -179,18 +177,47 @@ Rectangle{
|
|||
spacing: 0.5*mm
|
||||
width: parent.width
|
||||
height: 10*mm//implicitHeight
|
||||
Label{
|
||||
id:receiverLabel
|
||||
x: 0.5*mm
|
||||
width: parent.width-mm
|
||||
font.pixelSize: 3*mm
|
||||
text: newsSwipeview.stacktype=="DirectMessages"?qsTr("to:")+ " "+ reply_to_user:""
|
||||
visible:false// ((parentId !== "") || (newsStack.parent.stacktype=="DirectMessages"))
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked:{}
|
||||
|
||||
// Row{
|
||||
// x: 0.5*mm
|
||||
// Label{
|
||||
// id:toLabel
|
||||
// width: 7*mm
|
||||
// height: 6*mm
|
||||
// topPadding: 1.5* mm
|
||||
// font.pixelSize: 3*mm
|
||||
// text: newsSwipeview.stacktype=="DirectMessages"?qsTr("to:"):""
|
||||
// visible:false// ((parentId !== "") || (newsStack.parent.stacktype=="DirectMessages"))
|
||||
// }
|
||||
TextArea{
|
||||
id:receiverLabel
|
||||
//x: 8*mm
|
||||
width: messageColumn.width//-8*mm
|
||||
font.pixelSize: 3*mm
|
||||
placeholderText:qsTr("to:")
|
||||
text: ""//newsSwipeview.stacktype=="DirectMessages"?qsTr("to:")+ " "+ reply_to_user:""
|
||||
visible:false// ((parentId !== "") || (newsStack.parent.stacktype=="DirectMessages"))
|
||||
//onLengthChanged: contactmenu(text)
|
||||
//onPreeditTextChanged: contactmenu(text)
|
||||
// onActiveFocusChanged:{
|
||||
// if (activeFocus==true){contactmenu("")}
|
||||
// }
|
||||
onTextChanged: {
|
||||
//print (text)
|
||||
contactmenu(text)}
|
||||
// MouseArea{
|
||||
// anchors.fill: parent
|
||||
// onClicked:{print("receiverlabel")
|
||||
// if(newsSwipeview.stacktype=="DirectMessages"){
|
||||
// contactmenu();
|
||||
|
||||
// }}
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
TextField {
|
||||
id: titleField
|
||||
x: 0.5*mm
|
||||
|
@ -203,16 +230,16 @@ Rectangle{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Rectangle{
|
||||
color: "white"
|
||||
radius: 0.5*mm
|
||||
x:mm
|
||||
width: parent.width-2*mm
|
||||
height:Math.max(bodyField.contentHeight+4*mm,10*mm)
|
||||
|
||||
TextArea {
|
||||
id: bodyField
|
||||
property string contactprefix:""
|
||||
anchors.fill: parent
|
||||
font.pixelSize: 3*mm
|
||||
font.family: "Noto Sans"
|
||||
|
@ -226,26 +253,103 @@ Rectangle{
|
|||
if (activeFocus==true){
|
||||
if (conversation==true){
|
||||
setParent(conversationModel.get(0).newsitemobject);
|
||||
messageSend.state="conversation"
|
||||
} else{
|
||||
messageSend.state="active"
|
||||
messageSend.state="conversation";
|
||||
conversationView.contentY=conversationView.contentY+20*mm
|
||||
} else if (textfocus==false){
|
||||
messageSend.state="active";
|
||||
newsView.positionViewAtBeginning();
|
||||
}
|
||||
}
|
||||
}
|
||||
onTextChanged:{
|
||||
if (text!=""){
|
||||
//print(getText(bodyField.cursorPosition-2,bodyField.cursorPosition) +" preedit: "+ preeditText+cursorPosition);
|
||||
var regex1 = /@[a-z]/;var regex2 = /![a-z]/;
|
||||
//print(text.substring(cursorPosition-2,cursorPosition));
|
||||
//if (regex.test(getText(bodyField.cursorPosition-2,bodyField.cursorPosition)) || regex.test(preeditText) || regex.test(text)){
|
||||
if (regex1.test(getText(bodyField.cursorPosition-2,bodyField.cursorPosition)+preeditText) || regex2.test(getText(bodyField.cursorPosition-2,bodyField.cursorPosition)+preeditText)){
|
||||
var letter=(getText(bodyField.cursorPosition-2,bodyField.cursorPosition)).match(/[a-z]/);
|
||||
contactmenu(letter)
|
||||
}
|
||||
}}
|
||||
var plaintext=getText(0,cursorPosition)
|
||||
//print(plaintext+plaintext.lastIndexOf("@",cursorPosition)+getText(plaintext.lastIndexOf('@',cursorPosition),cursorPosition) +" preedit: "+ preeditText+cursorPosition);
|
||||
var regex1 = /@[a-z]+/;var regex2 = /![a-z]+/;var regex3 = /\s/;
|
||||
//print(text.substring(cursorPosition-2,cursorPosition));
|
||||
//if (regex.test(getText(bodyField.cursorPosition-2,bodyField.cursorPosition)) || regex.test(preeditText) || regex.test(text)){
|
||||
if (regex1.test(getText(plaintext.lastIndexOf('@',cursorPosition),cursorPosition)+preeditText) && !regex3.test(getText(plaintext.lastIndexOf('@',cursorPosition),cursorPosition)+preeditText)){
|
||||
var letter=(getText(plaintext.lastIndexOf('@',cursorPosition),cursorPosition)).match(/[a-z]+/);
|
||||
contactprefix="@";
|
||||
contactmenu(letter.toString())
|
||||
} else if( regex2.test(getText(plaintext.lastIndexOf('!',cursorPosition),cursorPosition)+preeditText) && !regex3.test(getText(plaintext.lastIndexOf('@',cursorPosition),cursorPosition)+preeditText) ){
|
||||
var letter=(getText(plaintext.lastIndexOf('!',cursorPosition),cursorPosition)).match(/[a-z]+/);
|
||||
contactprefix="!";
|
||||
contactmenu(letter.toString())
|
||||
}else {contactSelector.visible=false}
|
||||
}else{contactSelector.visible=false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView{
|
||||
id:contactSelector
|
||||
visible: false
|
||||
z:3
|
||||
x:8*mm
|
||||
width: parent.width-9*mm
|
||||
height: messageSend.height/2
|
||||
model:contactModel
|
||||
function processContactSelection(contact){
|
||||
if(Helperjs.getCount(db,login,"contacts","screen_name",contact.screen_name)>1){
|
||||
contact.screen_name=contact.screen_name+"+"+contacts.cid
|
||||
}
|
||||
if (newsSwipeview.stacktype=='DirectMessages'){
|
||||
receiverLabel.text=contact.screen_name;
|
||||
reply_to_user=contact.screen_name
|
||||
} else {
|
||||
bodyField.remove(bodyField.getText(0,bodyField.cursorPosition).lastIndexOf(bodyField.contactprefix,bodyField.cursorPosition),bodyField.cursorPosition);
|
||||
bodyField.insert(bodyField.cursorPosition, bodyField.contactprefix+contact.screen_name+" ");
|
||||
bodyField.cursorPosition=bodyField.cursorPosition+contact.screen_name.length+1
|
||||
}
|
||||
//receiverLabel.text=contact.screen_name;
|
||||
contactSelector.visible=false
|
||||
}
|
||||
delegate: ContactComponent { }
|
||||
}
|
||||
ListModel{id:contactModel}
|
||||
|
||||
|
||||
Item{
|
||||
id:imageAttachment;
|
||||
property alias source:realimage.source
|
||||
//property alias angle:rotator.angle
|
||||
visible: source!=""
|
||||
width: 45*mm
|
||||
height: 45*mm;
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
attachImageURLs.splice(attachImageURLs.indexOf(source),1);
|
||||
imageAttachment.source=""
|
||||
}
|
||||
}
|
||||
Image{id:realimage
|
||||
source:"";
|
||||
x:2*mm;
|
||||
width: 45*mm;
|
||||
height: source==""?0:45*mm;
|
||||
fillMode: Image.PreserveAspectFit;
|
||||
transform: Rotation {id:rotator; origin.x: 22.5*mm; origin.y: 22.5*mm; angle: 0}
|
||||
|
||||
}
|
||||
Rectangle{
|
||||
width: 5*mm
|
||||
height: 5*mm
|
||||
visible: imageAttachment.source!=""
|
||||
anchors.bottom: imageAttachment.bottom
|
||||
anchors.right: imageAttachment.right
|
||||
color: "black"
|
||||
opacity: 0.5
|
||||
Text{anchors.centerIn:parent;text: "\uf01e";color: "white"}
|
||||
MouseArea{
|
||||
anchors.fill:parent;
|
||||
onClicked:{
|
||||
rotator.angle+=90;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Row{
|
||||
// spacing: 2
|
||||
|
@ -341,13 +445,16 @@ Rectangle{
|
|||
width: 7*mm
|
||||
text: "\uf057"
|
||||
onClicked: {
|
||||
bodyField.text="";
|
||||
messageSend.state="";
|
||||
permissionDialog.visible=false;
|
||||
receiverLabel.visible=false;
|
||||
reply_to_user="";
|
||||
attachImage("");
|
||||
attachImageURLs.pop();
|
||||
if (textfocus==true){messageSend.destroy()}
|
||||
else{
|
||||
bodyField.text="";
|
||||
messageSend.state="";
|
||||
permissionDialog.visible=false;
|
||||
receiverLabel.visible=false;
|
||||
reply_to_user="";
|
||||
attachImage("");
|
||||
attachImageURLs.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
MButton {
|
||||
|
@ -382,6 +489,7 @@ Rectangle{
|
|||
root.directmessageSignal.connect(directmessagePrepare);
|
||||
root.uploadSignal.connect(sendUrls);
|
||||
root.sendtextSignal.connect(sendtext);
|
||||
if (textfocus==true){bodyField.forceActiveFocus()}
|
||||
}
|
||||
|
||||
states: [ State {
|
||||
|
@ -398,6 +506,9 @@ Rectangle{
|
|||
PropertyChanges {
|
||||
target: receiverLabel; visible:(newsSwipeview.stacktype=="DirectMessages");
|
||||
}
|
||||
// PropertyChanges {
|
||||
// target: toLabel; visible:(newsSwipeview.stacktype=="DirectMessages");
|
||||
// }
|
||||
},
|
||||
State {
|
||||
name: "conversation"
|
||||
|
@ -422,6 +533,23 @@ Rectangle{
|
|||
// PropertyChanges {
|
||||
// target: messageSend; parentId: conversationModel.get(0).newsitemobject.status_id
|
||||
// }
|
||||
} ]
|
||||
},
|
||||
|
||||
State {
|
||||
name: "reply"
|
||||
PropertyChanges {
|
||||
target: messageColumn; height: implicitHeight
|
||||
}
|
||||
PropertyChanges {
|
||||
target: buttonRow; visible:true
|
||||
}
|
||||
PropertyChanges {
|
||||
target: titleField; visible:false
|
||||
}
|
||||
PropertyChanges {
|
||||
target: bodyField; placeholderText:"";focus:true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue