// message.qml // message with buttons import QtQuick 2.0 import QtQml 2.2 import QtQuick.Controls 1.3 import QtQuick.Dialogs 1.2 import QtQuick.LocalStorage 2.0 import "qrc:/js/helper.js" as Helperjs import "qrc:/js/service.js" as Servicejs Item{ id:messageSend property var login property string parentId: "" property string reply_to_user:"" property string attachImageURL: ""; property int directmessage: 0; property var contacts: [] property var groups: [] 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)); xhr.clearParams(); xhr.setParam("source", "Friendiqa"); xhr.setParam("status", status); 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(); } function dmUpdate(title,text,replyto,screen_name,attachImageURL) { xhr.url= login.server + "/api/direct_messages/new.xml"; xhr.setLogin(login.username+":"+Qt.atob(login.password)); xhr.clearParams(); xhr.setParam("text", text); xhr.setParam("screen_name", screen_name); if (parentId!="") {xhr.setParam("replyto", replyto)}; if (title!=="") {xhr.setParam("title", title)}; if (attachImageURL!=="") {xhr.setImageFileParam("media", attachImageURL )}; xhr.post(); } Column { id:messageColumn spacing: 2 width: parent.width TextField { id: titleField width: parent.width placeholderText: qsTr("Title (optional)") visible: messageSend.parentId === "" } TextArea { id: bodyField width: parent.width height: 30*mm wrapMode: TextEdit.Wrap textFormat: TextEdit.PlainText } Row{ spacing: 2 CheckBox{ id:dmCheckbox text:"DM" enabled: false checked: (directmessage==1)?true:false onClicked:{ if(dmCheckbox.checkedState==Qt.Checked){directmessage=1} else if(dmCheckbox.checkedState==Qt.Unchecked){directmessage=0} } } Button{ text:qsTr("Url") onClicked: { if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)} else{urlTextEdit.text=""; urlRectangle.visible=true}} } Rectangle{ id:urlRectangle height:parent.height width:37*mm visible:false TextField{ id:urlTextEdit width:30*mm height:parent.height } Button{ anchors.left:urlTextEdit.right anchors.leftMargin:mm text:qsTr("\u2713") onClicked: { var start = bodyField.selectionStart; var end = bodyField.selectionEnd; var text = bodyField.getText(start,end); text = "" + text + ""; bodyField.remove(start,end); bodyField.insert(start,text); urlRectangle.visible=false } } } } Row{ spacing:2 Button{ visible: (directmessage==1)?false:true text:qsTr("Permissions") onClicked: { var component = Qt.createComponent("qrc:/qml/newsqml/PermissionDialog.qml"); var permissions = component.createObject(messageColumn); }} Button { id: attachButton text: qsTr("Attach") onClicked: { try{imageAttachment.visible=false; imageAttachment.opacity=0;imageAttachment.destroy()}catch(e){} imageAttachmentDialog.open()} } Button{ id:contactButton text:qsTr("cc") visible:(directmessage==0) onClicked:{ var contactitems=""; for (var i=0;i 1) { stackView.pop(); event.accepted = true; }} FileDialog { id: imageAttachmentDialog title: "Please choose a picture" folder: shortcuts.pictures selectFolder: false onAccepted: { attachImageURL=imageAttachmentDialog.fileUrl; var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment;source:"'+attachImageURL.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage"); //console.log("You chose: " + attachImageURL) } onRejected: { //console.log("Canceled") } } }