Friendiqa v0.3.1

This commit is contained in:
LubuWest 2018-07-20 21:15:54 +02:00
commit 2afa7cbe6b
29 changed files with 490 additions and 465 deletions

View file

@ -37,20 +37,23 @@ import "qrc:/qml/genericqml"
Rectangle {
id:conversationList
// width:root.width-5*mm
// height:root.height-12*mm
//property var news
y:1
z:2
// y:1
// z:2
color: "white"
border.color: "grey"
width:root.width-5*mm
height: conversationView.height+10*mm
// border.color: "grey"
// width:root.width-5*mm
// height: conversationView.height+10*mm
ListView {
id: conversationView
x:3*mm
y:8*mm
width: conversationList.width-4*mm
height: contentHeight
//height: contentHeight
height:conversationList.height-10*mm
clip: true
spacing: 0
footer: footerReply
@ -70,17 +73,19 @@ Rectangle {
Connections{
target:newstab
onConversationChanged:{
if(newsitem.itemindex==newsStack.conversationIndex){
//if(newsitem.itemindex==newsStack.conversationIndex){
if(newstab.conversation.length==0){
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy(); conversationsymbol.color="grey"
newsStack.pop()
//newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
//conversationList.destroy(); conversationsymbol.color="grey"
} else { conversationBusy.running=false;
conversationModel.clear();
var currentTime= new Date();
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':newstab.conversation};
conversationWorker.sendMessage(msg)
conversationsymbol.color="grey"}
}
//conversationsymbol.color="grey"
}
//}
}
}
@ -165,9 +170,10 @@ Rectangle {
anchors.rightMargin: 1*mm
text: "\uf057"
onClicked: {
newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
conversationList.destroy();
conversationsymbol.color="grey"
//newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
newsStack.pop()
//conversationList.destroy();
//conversationsymbol.color="grey"
}
}

View file

@ -32,8 +32,8 @@
// message.qml
// message with buttons
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.4
//import QtQuick.Dialogs 1.2
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/smiley.js" as Smileyjs
import "qrc:/qml/genericqml"
@ -41,8 +41,8 @@ import "qrc:/qml/genericqml"
Rectangle{
color:"white"
width:root.width-5*mm
height:root.height-12*mm
// width:root.width-5*mm
// height:root.height-12*mm
//anchors.fill: parent
property string parentId: ""
property string reply_to_user:""
@ -69,7 +69,7 @@ Rectangle{
xhr.setApi("/api/statuses/update");
xhr.clearParams();
xhr.setParam("source", "Friendiqa");
xhr.setParam("status", status);
xhr.setParam("htmlstatus", 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))};
@ -94,14 +94,11 @@ Rectangle{
}
Flickable{
anchors.fill: parent
contentHeight: messageColumn.height
boundsBehavior: Flickable.StopAtBounds
id:messageSend
Column {
anchors.fill: parent
contentHeight: messageColumn.height
boundsBehavior: Flickable.StopAtBounds
id:messageSend
Column {
id:messageColumn
spacing: 0.5*mm
width: parent.width
@ -124,13 +121,15 @@ Rectangle{
font.pixelSize: 3*mm
wrapMode: Text.Wrap
selectByMouse: true
textFormat: TextEdit.PlainText
textFormat: TextEdit.RichText //TextEdit.PlainText
onLinkActivated:{Qt.openUrlExternally(link)}
}
}
Row{
spacing: 2
width: parent.width
CheckBox{
id:dmCheckbox
text:"DM"
@ -142,38 +141,38 @@ Rectangle{
}
}
BlueButton{
text:"\uf0c1"
onClicked: {
if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)}
else{urlTextEdit.text="";
urlRectangle.visible=true}}
}
Rectangle{
id:urlRectangle
BlueButton{
text:"\uf0c1"
onClicked: {
if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)}
else{urlTextEdit.text="";
urlRectangle.visible=true}}
}
}
Rectangle{
id:urlRectangle
height: 7*mm //parent.height
width:parent.width-2*mm
visible:false
TextField{
id:urlTextEdit
width:parent.width-7*mm
height:parent.height
width:37*mm
visible:false
TextField{
id:urlTextEdit
width:30*mm
height:parent.height
}
BlueButton{
anchors.left:urlTextEdit.right
anchors.leftMargin:mm
text:"\u2713"
onClicked: {if(urlTextEdit.text!=""){
var start = bodyField.selectionStart;
var text=bodyField.selectedText
text = "[url="+urlTextEdit.text+"]" + text + "[/url]";
bodyField.remove(start,bodyField.selectionEnd);
bodyField.insert(start,text);}
urlRectangle.visible=false}
}
}
BlueButton{
anchors.left:urlTextEdit.right
anchors.leftMargin:mm
text:"\u2713"
onClicked: {if(urlTextEdit.text!=""){
var start = bodyField.selectionStart;
var text=bodyField.selectedText
if(text.lastIndexOf(".jpg")>-1 || text.lastIndexOf(".jpeg")>-1 || text.lastIndexOf(".png")>-1){text="<img src="+text+">"}
text = "[url="+urlTextEdit.text+"]" + text + "[/url]";
bodyField.remove(start,bodyField.selectionEnd);
bodyField.insert(start,text);}
urlRectangle.visible=false}
}
}
Row{
spacing:2
BlueButton{id:permButton
@ -208,7 +207,7 @@ Rectangle{
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: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.insert("+bodyField.cursorPosition+",' @"+contacts[i].screen_name+" ')}"
}}
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
var contactlistObject=Qt.createQmlObject(menuString,messageColumn,"contactmenuOutput")
@ -234,10 +233,11 @@ Rectangle{
text: "\uf1d9"
onClicked: {
var title=titleField.text.replace("\"","\'");
var body=bodyField.getText(0,bodyField.length);
var body=bodyField.getFormattedText(0,bodyField.length);
var dmbody=bodyField.getText(0,bodyField.length);
if (directmessage==0){
statusUpdate(title,body,messageSend.parentId,attachImageURLs)}
else {dmUpdate(title,body,"",messageSend.reply_to_user) }
statusUpdate(title,body,parentId,attachImageURLs)}
else {dmUpdate(title,dmbody,parentId,reply_to_user) }
newstab.newstabstatus=login.newsViewType; newsStack.pop(null)
}
}

View file

@ -0,0 +1,50 @@
// 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.0
AnimatedImage {id:gif;
width:newscolumn.width;
property string mimetype:""
fillMode: Image.PreserveAspectFit;
onStatusChanged: playing = (status == AnimatedImage.Ready);
MouseArea {anchors.fill:parent;
onClicked:{
if (mimetype!="image/gif"){
var attachcomponent = Qt.createQmlObject('import QtQuick 2.0; '+
'Rectangle{id:recfullscreen;color:"white";width:root.width;height:root.height;'+
'MouseArea {anchors.fill:parent;onClicked:{recfullscreen.destroy()}}'+
'AnimatedImage {id:giffullscreen;source: "'+gif.source+
'";anchors.centerIn:parent; width:root.width;fillMode: Image.PreserveAspectFit; onStatusChanged: playing = (status == AnimatedImage.Ready);'+
'}}',root,"Attachmentlarge")
}
}
}
}

View file

@ -30,8 +30,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 2.3
//import QtQuick.Controls.Styles 2.3
import QtQuick.Dialogs 1.3
import "qrc:/qml/genericqml"
import "qrc:/js/news.js" as Newsjs
@ -44,16 +44,6 @@ Item {
target:newstab
onNewstabstatusChanged:{
newstabstatusButton.text= qsTr(newstab.newstabstatus)
// switch(newstab.newstabstatus){
// case "Timeline": newstabstatusCombo.currentIndex=1; break;
// case "Conversations":newstabstatusCombo.currentIndex=2; break;
// case "Favorites":newstabstatusCombo.currentIndex=3; break;
// case "Network":newstabstatusCombo.currentIndex=4; break;
// case "Direct Messages":newstabstatusCombo.currentIndex=5; break;
// case "Notifications":newstabstatusCombo.currentIndex=6; break;
// case "Search":newstabstatusCombo.currentIndex=7; break;
// case "Groupnews":newstabstatusCombo.currentIndex=8; break;
// }
}
}
@ -132,7 +122,7 @@ Item {
}
}
function search(term){print("Search "+term)
function search(term){//print("Search "+term)
if (term!=""){
newstab.newstabstatus="Search";
newsBusy.running=true;
@ -161,19 +151,21 @@ Item {
function onDirectMessage(friend){
newstab.newstabstatus="SendMessage"
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"reply_to_user": friend,"directmessage":1,"login":root.login});
}
function sendUrls(urls){
if((urls.length==1)&&(newsStack.depth<2)){
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{attachImageURLs:urls}}])
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"attachImageURLs":urls})
}
}
function sendtext(text){
if(text&&(newsStack.depth<2)){
if (text.subject=="undefined"){text.subject=""}
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{bodyMessage:text.subject+"\n"+text.plaintext}}])
if(text.plaintext.lastIndexOf(".jpg")>-1 || text.plaintext.lastIndexOf(".jpeg")>-1 || text.plaintext.lastIndexOf(".png")>-1 || text.plaintext.lastIndexOf(".jpeg")>-1){
text.plaintext="<a href="+text.plaintext+"><img src="+text.plaintext+"></a>"}
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"bodyMessage":text.subject+"\n"+text.plaintext})
}
}
@ -188,96 +180,28 @@ Item {
y:1
color: "white"
// ComboBox{
// id:newstabstatusCombo
// anchors.top: parent.top
// anchors.topMargin: 0.5*mm
// width: 1/3*root.width
// height: 5*mm;
// style:
// ComboBoxStyle{
// background: Rectangle {
// color:"light blue"
// radius: 0.5*mm
// }
// label: Text {
// verticalAlignment: Text.AlignVCenter
// horizontalAlignment: Text.AlignHCenter
// text: control.currentText
// }
// }
// model: ListModel {
// id: newscomboItems
// ListElement { type: "Timeline"; text: qsTr("Timeline")}
// ListElement { type: "Conversations";text: qsTr("Conversations")}
// ListElement { type: "Favorites";text: qsTr("Favorites") }
// ListElement { type: "PublicTimeline";text: qsTr("Public timeline") }
// ListElement { type: "DirectMessages";text: qsTr("Direct Messages") }
// ListElement { type: "Notifications";text: qsTr("Notifications") }
// ListElement { type: "Search";text: qsTr("Search") }
// ListElement { type: "Groupnews"; text: qsTr("Group News") }
// ListElement { type: "Quit";text: qsTr("Quit") }
// }
// currentIndex:(login.newsViewType=="Timeline")?0:1
// onCurrentIndexChanged:{
// //onActivated:{
// print(newscomboItems.get(currentIndex).type);
// switch(newscomboItems.get(currentIndex).type){
// case "Timeline":
// newstab.newstabstatus="Timeline";
// newsModel.clear();
// try{ Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
// showNews(dbnews)
// })}catch(e){Helperjs.showMessage("Error",e,root)}
// break;
// case "Conversations":
// newsModel.clear();
// newstab.newstabstatus="Conversations";
// Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
// break;
// case "Favorites":
// newstab.newstabstatus="Favorites";
// root.contactLoadType="favorites";
// Service.updateView("Favorites");
// break;
// case "PublicTimeline":
// newstab.newstabstatus="Network";
// Service.updateView("Network");
// break;
// case "DirectMessages":
// newstab.newstabstatus="DirectMessages";
// Service.updateView("DirectMessages");
// break;
// case "Notifications":
// newstab.newstabstatus="Notifications";
// Service.updateView("Notifications");
// break;
// case "Search":
// newsView.anchors.topMargin=18*mm;
// newsSearch.visible=true
// break;
// case "Groupnews":
// Service.showGroups();
// break;
// case "Quit":
// Service.cleanNews(root.db,function(){
// Service.cleanContacts(root.login,root.db,function(){
// Qt.quit()})
// })
// }
// }
// }
BlueButton{
id:newstabstatusButton
anchors.top: parent.top
anchors.topMargin: 0.5*mm
text: qsTr(newstab.newstabstatus)
onClicked: {newstabmenu.popup()}
onClicked: {newstabmenu.popup(2*mm,6*mm)}
Menu{id:newstabmenu
MenuItem {
width: 40*mm
delegate:MenuItem{
contentItem: Text{
font.pixelSize: 3.5*mm
text:parent.text
}
background: Rectangle {
implicitWidth: 40*mm; implicitHeight: 5*mm
color: "#ffffff"
border.color: "grey"
}
}
Action {
text: qsTr("Timeline")
onTriggered: {
newstab.newstabstatus="Timeline";
@ -286,7 +210,7 @@ Item {
showNews(dbnews)
})}catch(e){Helperjs.showMessage("Error",e,root)}}
}
MenuItem {
Action {
text: qsTr("Conversations")
onTriggered:{
newsModel.clear();
@ -294,15 +218,14 @@ Item {
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
}
}
MenuItem {
Action {
text: qsTr("Favorites")
onTriggered:{
newstab.newstabstatus="Favorites";
// root.contactLoadType="favorites";
Service.updateView("Favorites")
}
}
MenuItem {
Action {
text: qsTr("Public timeline")
onTriggered:{
newstab.newstabstatus="Public Timeline";
@ -310,25 +233,25 @@ Item {
}
}
MenuItem {
Action {
text: qsTr("Direct Messages")
onTriggered:{
newstab.newstabstatus="Direct Messages";
Service.updateView("Direct Messages")
}
}
MenuItem {
Action {
text: qsTr("Notifications")
onTriggered:{
newstab.newstabstatus="Notifications";
Service.updateView("Notifications")
}
}
MenuItem {
Action {
text: qsTr("Group news")
onTriggered:Service.showGroups();
}
MenuItem {
Action {
text: qsTr("Quit")
onTriggered:{
Service.cleanNews(root.db,function(){
@ -370,7 +293,7 @@ Item {
});
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}})
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"contacts": friends,"login":root.login})
},"isFriend",1);
}
}
@ -386,7 +309,7 @@ Item {
id: update
text: "\uf021"
onClicked: {
//root.contactLoadType="news";
root.contactLoadType="news";
Service.updateView(newstab.newstabstatus)
}
}
@ -502,21 +425,18 @@ Item {
}
Component.onCompleted: {
root.messageSignal.connect(onFriendsMessages);
root.directmessageSignal.connect(onDirectMessage);
root.newsSignal.connect(showNews);
root.uploadSignal.connect(sendUrls);
root.sendtextSignal.connect(sendtext);
try{newsModel.clear()} catch(e){}
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
root.messageSignal.connect(onFriendsMessages);
root.directmessageSignal.connect(onDirectMessage);
root.newsSignal.connect(showNews);
root.uploadSignal.connect(sendUrls);
root.sendtextSignal.connect(sendtext);
try{newsModel.clear()} catch(e){}
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
if(root.news.length>0){showNews(root.news)}
else{ newstab.newstabstatus=login.newsViewType;
if(login.newsViewType=="Timeline"){Newsjs.newsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
else{Newsjs.chatsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
}
if(osSettings.imagePickQml=="ImagePicker"){var component = Qt.createComponent("qrc:/qml/genericqml/IntentReceiver.qml");
var IntentReceiverQml = component.createObject(root)
else{ newstab.newstabstatus=login.newsViewType;
if(login.newsViewType=="Timeline"){Newsjs.newsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
else{Newsjs.chatsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
}
}
}

View file

@ -144,16 +144,31 @@ Item {
}
}
Text {
Column{ id: messageColumn
//anchors.top:topFlow.bottom
width:parent.width
spacing:mm
clip:true
height: Math.min(implicitHeight,3/4*root.height)
MouseArea{
width: newsitem.width-8*mm-2
height: itemMessage.height
onPressAndHold: {
newsStack.push("qrc:/qml/newsqml/Conversation.qml");
showConversation(index,newsitemobject)
}
Text {
color: "#404040"
linkColor: "light green"
id: itemMessage
textFormat: Text.RichText
text:newsitemobject.statusnet_html
text: newsitemobject.attachmentList.length>0?newsitemobject.text : newsitemobject.statusnet_html
width: newsitem.width-8*mm-2
height: Math.min(implicitHeight,3/4*root.height)
height: implicitHeight
wrapMode: Text.Wrap
clip:true
//MouseArea{anchors.fill:parent;onClicked: print("Test")}
onLinkActivated:{
Qt.openUrlExternally(link)}
Component.onCompleted:{
@ -166,38 +181,38 @@ Item {
}}
if (newsitemobject.attachmentList.length>0){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsImage.qml");
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);
var imageQml = component.createObject(messageColumn,{"source":newsitemobject.attachmentList[attachments].url,"mimetype":newsitemobject.attachmentList[attachments].mimetype});
}
}
}
BlueButton{
width: newsitem.width-8*mm-2
height:10*mm
anchors.bottom: itemMessage.bottom
visible: itemMessage.implicitHeight>3/4*root.height
text:"\uf078"
fontColor:"grey"
border.color: "transparent"
gradient: Gradient {
GradientStop { position: 0.0; color: "transparent" }
GradientStop { position: 0.5; color: "white" }
}
radius:0
onClicked: {
if (text=="\uf078"){
itemMessage.height=itemMessage.implicitHeight+10*mm;text="\uf077"
} else {
itemMessage.height=Math.min(itemMessage.implicitHeight,3/4*root.height);
text="\uf078";
newsView.positionViewAtIndex(index,ListView.Beginning);
}
}
}
}
}}
}
BlueButton{
width: newsitem.width-8*mm-2
height:5*mm
//anchors.bottom: messageColumn.bottom//itemMessage.bottom
visible: messageColumn.implicitHeight>3/4*root.height//itemMessage.implicitHeight>3/4*root.height
text:"\uf078"
fontColor:"grey"
border.color: "transparent"
color:"white"
// gradient: Gradient {
// GradientStop { position: 0.0; color: "transparent" }
// GradientStop { position: 0.5; color: "white" }
// }
radius:0
onClicked: {
if (text=="\uf078"){
messageColumn.height=messageColumn.implicitHeight+10*mm;text="\uf077"
} else {
messageColumn.height=Math.min(messageColumn.implicitHeight,3/4*root.height);
text="\uf078";
newsView.positionViewAtIndex(index,ListView.Beginning);
}
}
}
}
}
Flow{
@ -364,9 +379,11 @@ Item {
MouseArea{
anchors.fill:parent
onClicked:{
conversationsymbol.color="black";
var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
var conversationItem = component.createObject(friendicaActivities); showConversation(index,newsitemobject)
//conversationsymbol.color="black";
// var component = Qt.createComponent("qrc:/qml/newsqml/Conversation.qml");
// var conversationItem = component.createObject(friendicaActivities);
newsStack.push("qrc:/qml/newsqml/Conversation.qml")
showConversation(index,newsitemobject)
}
}
}
@ -380,7 +397,7 @@ Item {
onTriggered: {
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.id,"login":root.login,"directmessage":directmessage}});
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.id,"login":root.login,"directmessage":directmessage});
}
}
MenuItem {