v0.6.4 contact search

This commit is contained in:
LubuWest 2022-03-01 21:59:21 +01:00
commit 5032c78de1
57 changed files with 2218 additions and 2252 deletions

View file

@ -44,8 +44,6 @@ Page {
property var contact:({})
property string profileimagesource:contact.profile_image
//function backRequested(){pageStack.pop()}
function getDateDiffString (seconds){
var timestring="";
if (seconds<60) {timestring= Math.round(seconds) + " " +qsTr("seconds");}
@ -141,14 +139,12 @@ Page {
Component { id: contactHeader
Rectangle{
border.color: Material.backgroundDimColor//"#EEEEEE"
border.color: Material.backgroundDimColor
border.width: 1
color: Material.backgroundColor//"white"
color: Material.backgroundColor
width:contactView.width
height: contactView.width<35*root.fontFactor*osSettings.systemFontSize?(profileImage.height+namelabel.height+detailtext.height+7*mm):Math.max(profileImage.height,(buttonflow.height+namelabel.height+detailtext.height))+7*mm
//height: wrapper.height
property var createdAtDate: new Date(contact.created_at)
property string connectUrl: (contact.network!=="dfrn")||(contact.isFriend!=0)?"":( "<a href='"+contact.url.replace("profile","dfrn_request") +"'>"+qsTr("Connect")+"</a><br>")
Image {
id: profileImage
@ -160,7 +156,7 @@ Page {
onStatusChanged: if (profileImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
Connections{
target:contactList
onProfileimagesourceChanged:profileImage.source=profileimagesource
function onProfileimagesourceChanged(){profileImage.source=profileimagesource}
}
}
Flow{id:buttonflow
@ -175,7 +171,7 @@ Page {
id:photobutton
height: 6*mm
width: 8*mm
text: "\uf03e" // "Photos"
text: "\uf03e"
visible:(contact.network=="dfrn")
onClicked:{
rootstack.currentIndex=2;
@ -193,7 +189,7 @@ Page {
height: 6*mm
width: 8*mm
visible: (contact.following=="true")
text: "\uf040" //"DM"
text: "\uf040"
onClicked:{
rootstack.currentIndex=0;
newsSwipeview.currentIndex=2;
@ -217,9 +213,8 @@ Page {
}
MButton{
id:approvebutton
visible:(contact.hasOwnProperty("acct"))
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
height: 6*mm
//width: implicitContentWidth+2*mm//8*mm
text:qsTr("Approve")
onClicked:{
@ -232,9 +227,8 @@ Page {
}
MButton{
id:rejectbutton
visible:(contact.hasOwnProperty("acct"))
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
height: 6*mm
//width: implicitContentWidth+2*mm//8*mm
text:qsTr("Reject")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/follow_requests/" + contact.id + "/reject",'',"POST",root,function(returnvalue){
@ -246,9 +240,8 @@ Page {
}
MButton{
id:ignorebutton
visible:(contact.hasOwnProperty("acct"))
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
height: 6*mm
//width: implicitContentWidth+2*mm//8*mm
text:qsTr("Ignore")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/follow_requests/" + contact.id + "/ignore",'',"POST",root,function(returnvalue){
@ -260,9 +253,8 @@ Page {
}
MButton{
id:followbutton
visible:(contact.isFriend==0)
visible:(contact.isFriend==0 || !contact.hasOwnProperty("isFriend"))
height: 6*mm
//width: implicitContentWidth+2*mm//8*mm
text:qsTr("Follow")
onClicked:{
contactBusy.running=true;
@ -281,7 +273,6 @@ Page {
id:unfollowbutton
visible:(contact.isFriend==1)
height: 6*mm
//width: implicitContentWidth+2*mm//8*mm
text:qsTr("Unfollow")
onClicked:{
Helperjs.friendicaPostRequest(login,"/api/v1/accounts/" + contact.id + "/unfollow",'',"POST",root,function(returnvalue){
@ -297,12 +288,11 @@ Page {
}//Flow end
Label {
id: namelabel
//x:mm
width: contactView.width<35*root.fontFactor*osSettings.systemFontSize?contactView.width-2*mm:contactView.width-17*root.fontFactor*osSettings.bigFontSize
height: implicitHeight
text:contact.name+" (@"+contact.screen_name+")"
wrapMode: Text.Wrap//elide:Text.ElideRight
color: Material.primaryTextColor//"#303030"
wrapMode: Text.Wrap
color: Material.primaryTextColor
font.pointSize: 1.2*osSettings.bigFontSize
font.family: "Noto Sans"
anchors.top: contactView.width<35*root.fontFactor*osSettings.systemFontSize?profileImage.bottom:buttonflow.bottom
@ -314,7 +304,6 @@ Page {
anchors.top: namelabel.bottom
anchors.left: contactView.width<35*root.fontFactor*osSettings.systemFontSize?contactView.left:profileImage.right
anchors.margins: 2*mm
//x:mm
width: contactView.width<35*root.fontFactor*osSettings.systemFontSize?contactView.width-2*mm:contactView.width-17*root.fontFactor*osSettings.bigFontSize
height: implicitHeight
font.pointSize: osSettings.systemFontSize
@ -324,15 +313,11 @@ Page {
color: Material.primaryTextColor
text:"<b>"+qsTr("Description")+": </b> "+(Qt.atob(contact.description)!=""?contact.description:"")+"<br> <b>"+qsTr("Location")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ contact.url+"'>"+contact.url+"</a><br>"+
connectUrl+ "<b>"+qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
"<b>"+qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
//}
}
}//Component end
Connections{
@ -342,8 +327,9 @@ Page {
contactBusy.running=false;
}
function onSuccess(data,api){
Service.processNews(api,data)
//replySignal("")
if (api=="/api/statuses/user_timeline"){
Service.processNews(api,data)
}
}
}
@ -373,7 +359,6 @@ Page {
anchors.rightMargin: 1*mm
width: 2*root.fontFactor*osSettings.bigFontSize;
text: "\uf057"
//font.pixelSize: 3*mm
onClicked: {
rootstackView.pop()
}
@ -382,9 +367,10 @@ Page {
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
if(contact.isFriend==1 || contact.hasOwnProperty("acct")){
xhr.setApi("/api/statuses/user_timeline");}
else{xhr.setApi("/api/users/show");}
// if(contact.isFriend==1 || contact.hasOwnProperty("acct")){
// xhr.setApi("/api/statuses/user_timeline");}
// else{xhr.setApi("/api/users/show");}
xhr.setApi("/api/statuses/user_timeline")
xhr.setParam("user_id",contact.id)
xhr.get();
}

View file

@ -34,7 +34,6 @@
import QtQuick 2.4
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
//import QtQuick.Dialogs 1.2
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/smiley.js" as Smileyjs
import "qrc:/js/news.js" as Newsjs
@ -42,19 +41,17 @@ import "qrc:/qml/genericqml"
Rectangle{
color:Material.dialogColor//"#EEEEEE"
color:Material.dialogColor
width:parent.width
height: conversation || (newsSwipeview.stacktype!="Notifications")?messageColumn.height+mm:0
height: conversation || (newsSwipeview.stacktype!="Notifications")?messageColumn.height+2*mm:0
id:messageSend
visible:conversation || (newsSwipeview.stacktype!="Notifications")||(newstab.newstabstatus!="Search")?true:false
property string parentId: ""
property bool textfocus: false
//property var parentObject:({})
property bool conversation: false
property string reply_to_user:""
property alias bodyMessage: bodyField.text
property var attachImageURLs: [];
//property int directmessage: 0;
property var contacts: []
property var groups: []
property var contact_allow:login.hasOwnProperty("permissions")?login.permissions[0]:[]
@ -130,13 +127,12 @@ Rectangle{
}
function setParent(newsitemobject){
//print("Newsobject "+newsitemobject.id+ " "+JSON.stringify(newsitemobject.user));
if (newsitemobject!=""){
messageSend.state="conversation"
messageSend.reply_to_user=newsitemobject.user.screen_name;
messageSend.parentId=newsitemobject.id
} else {
//messageSend.state=null;
messageSend.state=null;
messageSend.reply_to_user="";
messageSend.parentId="";
bodyField.text="";
@ -145,7 +141,7 @@ Rectangle{
}
}
function contactmenu(letter){//print("letter "+letter)
function contactmenu(letter){
Newsjs.listFriends(login,db,function(contacts){
contactModel.clear();
for (var i=0;i<contacts.length;i++){
@ -158,7 +154,7 @@ Rectangle{
},letter);
}
function hashtagmenu(){//print("letter "+letter)
function hashtagmenu(){
Newsjs.listHashtags(login,db,function(tags){
tagModel.clear();
for (var i=0;i<tags.length;i++){
@ -191,7 +187,7 @@ Rectangle{
id:messageColumn
spacing: 0.5*mm
width: parent.width
height: 11*mm+stackTypeDescription.height//implicitHeight
height: 2.6*root.fontFactor*osSettings.bigFontSize+stackTypeDescription.height
Label{id:stackTypeDescription
width: parent.width
horizontalAlignment:Text.AlignHCenter
@ -200,7 +196,7 @@ Rectangle{
}
TextArea{
id:receiverLabel
width: messageColumn.width//-8*mm
width: messageColumn.width
font.pointSize: osSettings.bigFontSize
placeholderText:qsTr("to:")
text: ""
@ -222,11 +218,12 @@ Rectangle{
}
Rectangle{
color: Material.backgroundColor//"white"
color: Material.backgroundColor
radius: 0.5*mm
visible:(newsSwipeview.stacktype!="Notifications")
x:mm
width: parent.width-2*mm
height:Math.max(bodyField.contentHeight+4*mm,10*mm)
height:Math.max(bodyField.contentHeight+4*mm,2.5*root.fontFactor*osSettings.bigFontSize)
TextArea {
id: bodyField
@ -238,14 +235,27 @@ Rectangle{
wrapMode: Text.Wrap
selectByMouse: true
placeholderText: conversation?"": (qsTr("What's on your mind?")+placeholder)
textFormat: TextEdit.RichText //TextEdit.PlainText
onLineCountChanged: (conversation==true)?conversationView.contentY=conversationView.contentY+3*mm:newsView.contentY=newsView.contentY+3*mm
textFormat: TextEdit.RichText
onLineCountChanged: {
if (messageSend.ListView.view==null){
if (newsitem.ListView.view==null){}
else {newsitem.ListView.view.contentY=newsitem.ListView.view.contentY+root.fontFactor*osSettings.systemFontSize}
}
if(conversation==true){
conversationView.contentY=conversationView.contentY+root.fontFactor*osSettings.systemFontSize
}
else{
messageSend.ListView.view.contentY=messageSend.ListView.view.contentY+root.fontFactor*osSettings.systemFontSize
}
}
onLinkActivated:{Qt.openUrlExternally(link)}
onActiveFocusChanged:{//print(placeholder)
onActiveFocusChanged:{
if (activeFocus==true){
print("contenty "+messageSend.ListView.view.contentY)
if (messageSend.ListView.view.contentY==null){messageSend.parent.ListView.view.y=0}else{messageSend.ListView.view.contentY=messageSend.ListView.view.contentY+8*mm};
if (conversation==true){
if (messageSend.ListView.view==null){
if (newsitem.ListView.view==null){}
else {newsitem.ListView.view.contentY=newsitem.ListView.view.contentY+newsitem.height/2}
}
else if (conversation==true){
if(parentId==""){setParent(conversationModel.get(0).newsitemobject);}
messageSend.state="conversation";
try{conversationView.contentY=conversationView.contentY+20*mm}catch(e){}
@ -253,15 +263,15 @@ Rectangle{
messageSend.state="active";
newsView.positionViewAtBeginning();
}
else{
messageSend.ListView.view.contentY=messageSend.ListView.view.contentY+8*mm
};
}
}
onTextChanged:{
if (text!=""){
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)){
var regex1 = /@[a-z]+/;var regex2 = /\![a-z]+/;var regex3 = /\s/;
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="@";
@ -280,8 +290,8 @@ Rectangle{
id:contactSelector
visible: false
z:3
x:8*mm
width: parent.width-9*mm
x:2*root.fontFactor*osSettings.bigFontSize//8*mm
width: parent.width-2.2*root.fontFactor*osSettings.bigFontSize//9*mm
height: messageSend.height/2
model:contactModel
function processContactSelection(contact){
@ -307,8 +317,8 @@ Rectangle{
id: tagSelector
visible: false
z:3
x:8*mm
width: parent.width-9*mm
x:2*root.fontFactor*osSettings.bigFontSize//8*mm
width: parent.width-2.2*root.fontFactor*osSettings.bigFontSize//9*mm
height: messageSend.height/2
model:tagModel
clip: true
@ -367,15 +377,15 @@ Rectangle{
id:buttonRow
visible:false //(bodyField.length>1)||(attachImageURLs.length>0)
spacing: mm
height: 12*mm
height: 2.5*root.fontFactor*osSettings.bigFontSize//12*mm
x: 0.5*mm
MButton{id:permButton
visible: !conversation && (newsSwipeview.stacktype!=="DirectMessages")
height: 2*root.fontFactor*osSettings.bigFontSize
width: 2*root.fontFactor*osSettings.bigFontSize
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
onClicked: { if (permissionDialog.visible==false){permissionDialog.visible=true} else{permissionDialog.visible=false}}
}
// MButton{id:permButton //Permissions not working in Friendica 02/2022
// visible: !conversation && (newsSwipeview.stacktype!=="DirectMessages")
// height: 2*root.fontFactor*osSettings.bigFontSize
// width: 2*root.fontFactor*osSettings.bigFontSize
// text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
// onClicked: { if (permissionDialog.visible==false){permissionDialog.visible=true} else{permissionDialog.visible=false}}
// }
MButton {
id: attachButton
height: 2*root.fontFactor*osSettings.bigFontSize
@ -440,8 +450,8 @@ Rectangle{
var body=bodyField.getFormattedText(0,bodyField.length);
var dmbody=bodyField.getText(0,bodyField.length);
if (conversation || newsSwipeview.stacktype!=="DirectMessages"){
statusUpdate(title,body,parentId,attachImageURLs)}
else {
statusUpdate(title,body,parentId,attachImageURLs)
}else {
if (reply_to_user!=""){dmUpdate(title,dmbody,parentId,reply_to_user)}
else{Helperjs.showMessage(qsTr("Error"),qsTr("No receiver supplied!"),root)}
}

View file

@ -55,7 +55,7 @@ AnimatedImage {id:gif;
MouseArea {anchors.fill:parent;
onClicked:{
rootstackView.push("qrc:/qml/newsqml/NewsPhotolist.qml",{"photolistarray": model.newsitemobject.imageAttachmentList})
roottoolbar.visible=false
//roottoolbar.visible=false
}
}
}

View file

@ -69,7 +69,7 @@ Page{
text: "\uf057"
onClicked: {
if (rootstackView.depth>1){
roottoolbar.visible=true;
//roottoolbar.visible=true;
rootstackView.pop()}
}
}

View file

@ -49,7 +49,6 @@ Rectangle{
BusyIndicator{
id: newsBusy
//visible: false
anchors.horizontalCenter: parent.horizontalCenter
anchors.top:parent.top
anchors.topMargin: 2*mm
@ -60,10 +59,8 @@ Rectangle{
}
function newstypeHandling(newstype){
newsBusy.running=true;
try{newsBusy.running=true}catch(e){print(e)};
replySignal("");
//messagesend.state="";
//newsModel.clear();
switch(newstype){
case "timeline":
newstab.newstabstatus="Timeline";
@ -75,7 +72,7 @@ Rectangle{
case "conversation":
newsStack.updateMethodNews="conversation";
newstab.newstabstatus="Conversations";
Newsjs.chatsfromdb(root.db,root.login,0,function(news,lastid){
Newsjs.chatsfromdb(root.db,root.login,0,[],function(news,lastid){
lastnewsid=lastid;
showNews(news)});
break;
@ -105,7 +102,7 @@ Rectangle{
newsBusy.running=false;
var leftoffset=(osSettings.osType=="Android")?2*root.fontFactor*osSettings.bigFontSize:0
var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-(leftoffset+mm),height: 1.5*root.fontFactor*osSettings.systemFontSize});
var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-(leftoffset+mm),height: 1.5*root.fontFactor*osSettings.systemFontSize,selfdestroying:true});
break;
case "refresh":
if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
@ -147,20 +144,19 @@ Rectangle{
function showNews(newsToShow){
try{if (rootstackView.depth>1){rootstackView.pop()}}catch(e){}
newsBusy.running=false;
var currentTime= new Date();
// downloadNotice.text=downloadNotice.text + "\n shownews start "+ Date.now();
//print("appendnews "+JSON.stringify(newsToShow))
if (newsToShow.length==1){var method="refresh"}else{var method = newsStack.updateMethodNews}
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow,'method':method, 'options':globaloptions};
newsWorker.sendMessage(msg);
//newsStack.appendNews=false
if(newsToShow.length>0){
var currentTime= new Date()
// downloadNotice.text=downloadNotice.text + "\n shownews start "+ Date.now();
if (newsToShow.length==1){var method="refresh"}else{var method = newsStack.updateMethodNews}
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow,'method':method, 'options':globaloptions};
newsWorker.sendMessage(msg);
}
}
function search(term){
if (term!=""){
//newstab.newstabstatus="Search";
newstabstatus="Search";
newsBusy.running=true;
newsStack.updateMethodNews="refresh";
@ -179,10 +175,12 @@ Rectangle{
try{var oldnewsitemobject=newsModel.get(newsModel.count-1).newsitemobject;
if(oldnewsitemobject.hasOwnProperty("lastcomment")){
var lastnews_id=oldnewsitemobject.lastcomment.created_at;
//var lastconv_id=oldnewsitemobject.lastcomment.statusnet_conversation_id
}else{
var lastnews_id=oldnewsitemobject.created_at;
//var lastconv_id=oldnewsitemobject.statusnet_conversation_id
}
} catch(e){print(e);var lastnews_id=99999999999999 }
} catch(e){print(e);var lastnews_id=99999999999999}
var messagetype=0;
switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break;
@ -192,14 +190,19 @@ Rectangle{
default:messagetype=0;
}
if(newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline" ){
if(newsSwipeview.stacktype!="Home"|| newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline" ){
Newsjs.newsfromdb(root.db,root.login, messagetype,function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions};
newsWorker.sendMessage(msg);
},false,lastnews_id)}
else if(newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
Newsjs.chatsfromdb(root.db,root.login, messagetype,function(news){
var currentconversations=[];
for (let c=0;c<newsModel.count;c++){
currentconversations.push(parseInt(newsModel.get(c).newsitemobject.statusnet_conversation_id))
}
Newsjs.chatsfromdb(root.db,root.login, messagetype,currentconversations,function(news){
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'method':"", 'options':globaloptions};
newsWorker.sendMessage(msg);
},lastnews_id)}
@ -252,7 +255,6 @@ Rectangle{
Service.updateView("Replies")
}
replySignal("")
//Service.updateView(newstab.newstabstatus)
}
}
}
@ -301,7 +303,6 @@ Rectangle{
property string viewtype: "news"
width: parent.width
height: parent.height-3*mm
//anchors.fill: parent
anchors.margins: 0.5*mm
clip: true
spacing: 0
@ -355,11 +356,11 @@ Rectangle{
})}catch(e){Helperjs.showMessage("Error",e,root)};
}
if(newstab.newstabstatus=="Conversations"){
Newsjs.chatsfromdb(db,root.login,0,function(news,lastid){
Newsjs.chatsfromdb(db,root.login,0,[],function(news,lastid){
lastnewsid=lastid;
showNews(news)});
}
} else {
} else {print("newstab.newstabstatus "+newstab.newstabstatus)
Service.updateView(newstab.newstabstatus)
}
});
@ -424,7 +425,7 @@ Rectangle{
root.searchSignal.connect(search);
try{newsModel.clear()} catch(e){}
swipeIndicator.visible=true;
//newsSwipeview.height=rootstack.height//-12*mm;
//newsSwipeview.height=rootstack.height
//newsSwipeview.y=5*mm;
//rootStackItem.state=""
root.globaloptions.hasOwnProperty("newsViewType")?newstab.newstabstatus=root.globaloptions.newsViewType:newstab.newstabstatus="Conversations";
@ -438,9 +439,8 @@ Rectangle{
default:messagetype=0;
}
//if((newstab.newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){
if((newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){
Newsjs.chatsfromdb(db,login,messagetype,function(dbnews,lastid){
Newsjs.chatsfromdb(db,login,messagetype,[],function(dbnews,lastid){
lastnewsid=lastid;
showNews(dbnews);
})
@ -451,5 +451,4 @@ Rectangle{
showNews(dbnews)
})}
}
//}
}

View file

@ -33,7 +33,6 @@ import QtQuick 2.9
Rectangle{
color:"black"
//border.color: "light grey"
width:toprow.width/2;
height:toprow.width/3//video.hasVideo?newscolumn.width/4*3:10*mm
property var attachment:({})
@ -49,11 +48,7 @@ Rectangle{
MouseArea {anchors.fill:parent;
onClicked:{
if(attachment.mimetype=="video/youtube"){
rootstackView.push("qrc:/qml/newsqml/NewsYplayer.qml",{"ytcode":attachment.url,"mimetype":attachment.mimetype});
} else {
rootstackView.push("qrc:/qml/newsqml/NewsVideoLarge.qml",{"source": attachment.url,"mimetype": attachment.mimetype});
}
}
}
}

View file

@ -1,77 +0,0 @@
// This file is part of Friendiqa
// https://git.friendi.ca/lubuwest/Friendiqa
// Copyright (C) 2020 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.8
import QtQuick.Controls 2.12
import "qrc:/js/helper.js" as Helperjs
import QtWebView 1.1
Page {
id:newsYplayer
//color:"black"
width:root.width;
height:root.height-7*mm
property string url:""
property string ytcode:""
WebView {
id: webView
anchors.fill: parent
z:1
opacity: 0
url: root.osSettings.osType=="Android"?"https://youtube.com/watch?v="+ytcode:"qrc:/js/yplayer.html?" + ytcode
Behavior on opacity { NumberAnimation { duration: 200 } }
onLoadingChanged: {
switch (loadRequest.status)
{
case WebView.LoadSucceededStatus:
opacity = 1
return
case WebView.LoadStartedStatus:
case WebView.LoadStoppedStatus:
break
case WebView.LoadFailedStatus:
print("Failed to load the requested video" + url)
break
}
opacity = 0
}
onTitleChanged: {
if (title==2){root.pop()}
}
}
}

View file

@ -58,23 +58,21 @@ Item {
function pushConversation(){
if (model.newsitemobject.hasOwnProperty("currentconversation")){
rootstackView.push("qrc:/qml/newsqml/Conversation.qml",{"news": model.newsitemobject.currentconversation})}
//newsStack.push("qrc:/qml/newsqml/Conversation.qml",{"news": model.newsitemobject.currentconversation})}
//else{newsStack.push("qrc:/qml/newsqml/Conversation.qml")};
else{rootstackView.push("qrc:/qml/newsqml/Conversation.qml")};
showConversation(index,newsitemobject)
}
Rectangle{width:newsitem.width; height: 1; anchors.bottom: newsitem.bottom;
color: Material.backgroundDimColor//"light grey"
color: Material.backgroundDimColor
}
Rectangle{
width:newsitem.width
height:newsitem.height-1
color: Material.background//"white"
color: Material.background
Column {
id:toprow //newscolumn
id:toprow
width: newsitemobject.hasOwnProperty("indent")?newsitem.width-(newsitem.width/20 *(newsitemobject.indent+1)):newsitem.width//-8*mm
x:newsitemobject.hasOwnProperty("indent")?newsitem.width/20*(newsitemobject.indent):0
height: newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
@ -105,7 +103,6 @@ Item {
anchors.margins: mm
Label {
id:user_name
//color: "grey"
width:parent.width
font.bold: true
font.pointSize: osSettings.systemFontSize
@ -115,25 +112,24 @@ Item {
Label {
id:messageTypeLabel
color: Material.secondaryTextColor//"grey"
color: Material.secondaryTextColor
text: if (newsitemobject.messagetype==1){ qsTr("Direct Message")} else if(newsitemobject.messagetype==2) {" Notification"} else {qsTr("Source: ")+newsitemobject.source}
font.pointSize: 0.6*osSettings.systemFontSize
}
Label {
id:createdAtLabel
color: Material.secondaryTextColor//"grey"
color: Material.secondaryTextColor
font.pointSize: 0.6*osSettings.systemFontSize
horizontalAlignment: Label.AlignRight
text: " \u00B7 "+getDateDiffString(newsitemobject.dateDiff) + " " +qsTr("ago")
}
Label {
id:replytoLabel
color: Material.secondaryTextColor//"grey"
color: Material.secondaryTextColor
font.pointSize: 0.6*osSettings.systemFontSize
font.family: "Noto Sans"
horizontalAlignment: Label.AlignRight
text: try {" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name
}catch(e){" "}
text: (newsitemobject.in_reply_to_status_id!="null"&&newsitemobject.in_reply_to_status_id!=null)?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
}
}
}
@ -141,32 +137,27 @@ Item {
MouseArea{id: itemBody
width: toprow.width-2
height: itemMessage.height
//onPressAndHold: {pushConversation()}
onClicked: {pushConversation()}
Text {
color: Material.primaryTextColor//"#404040"
linkColor: Material.accentColor//"light green"
color: Material.primaryTextColor
linkColor: Material.accentColor
id: itemMessage
textFormat: Text.RichText
font.family: "Noto Sans"
font.pointSize: osSettings.systemFontSize
text: newsitemobject.statusnet_html
width: toprow.width-2
//height:newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
height: implicitHeight
wrapMode: Text.Wrap
clip:true
onLinkActivated:{Qt.openUrlExternally(link)}
Component.onCompleted:{
if (newsitemobject.messagetype==0){
var hashtags=[];
hashtags=Newsjs.findTags(newsitemobject.text);
var component = Qt.createComponent("qrc:/qml/newsqml/Hashtag.qml");
for (var tags in hashtags){
var hashtagQml = component.createObject(friendicaActivities,{"text":hashtags[tags].trim()});
}
onLinkActivated:{
if(link.startsWith(root.login.server+"\/search\?tag=")){
newstab.newstabstatus="Search";
root.searchSignal(link.substring(root.login.server.length+12,link.length))
}
else{Qt.openUrlExternally(link)}
}
Component.onCompleted:{
if (newsitemobject.imageAttachmentList.length>0){
if(newsitemobject.imageAttachmentList[0].mimetype.substring(0,5)=="image"){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsImage.qml");
@ -195,16 +186,16 @@ Item {
BlueButton{
width: newsitem.width-2
height:5*mm
anchors.bottom: toprow.bottom//itemMessage.bottom
visible: toprow.implicitHeight>3/4*root.height || newsitemobject.nsfw//messageColumn.implicitHeight>3/4*root.height || newsitemobject.nsfw//itemMessage.implicitHeight>3/4*root.height
anchors.bottom: toprow.bottom
visible: toprow.implicitHeight>3/4*root.height || newsitemobject.nsfw
text:"\uf078"
fontColor: Material.secondaryTextColor//"grey"
fontColor: Material.secondaryTextColor
border.color: "transparent"
color: Material.backgroundColor//"white"
// gradient: Gradient {
// GradientStop { position: 0.0; color: "transparent" }
// GradientStop { position: 0.5; color: "white" }
// }
color: Material.backgroundColor
// gradient: Gradient {
// GradientStop { position: 0.0; color: "transparent" }
// GradientStop { position: 0.5; color: Material.backgroundDimColor}
// }
radius:0
onClicked: {
if (text=="\uf078"){
@ -224,45 +215,45 @@ Item {
width:parent.width
spacing:mm
Label{color: Material.secondaryTextColor//"grey"
Label{color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
text: friendica_activities_view.likeText
text: newsitemobject.hasOwnProperty("isLastComment")?"":friendica_activities_view.likeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.like)}
}
}
Label{color: Material.secondaryTextColor//"grey"
Label{color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
text: friendica_activities_view.dislikeText
text: newsitemobject.hasOwnProperty("isLastComment")?"":friendica_activities_view.dislikeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.dislike)}
}
}
Label{color: Material.secondaryTextColor//"grey"
Label{color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
text: friendica_activities_view.attendyesText
text: newsitemobject.hasOwnProperty("isLastComment")?"":friendica_activities_view.attendyesText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendyes)}
}}
Label{color: Material.secondaryTextColor//"grey"
Label{color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
text: friendica_activities_view.attendnoText
text: newsitemobject.hasOwnProperty("isLastComment")?"":friendica_activities_view.attendnoText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendno)}
}
}
Label{color: Material.secondaryTextColor//"grey"
Label{color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
text: friendica_activities_view.attendmaybeText
text: newsitemobject.hasOwnProperty("isLastComment")?"":friendica_activities_view.attendmaybeText
MouseArea{
anchors.fill: parent
onClicked: { showActivityContacts(newsitemobject.friendica_activities.attendmaybe)}
@ -270,7 +261,7 @@ Item {
}
Label{
id:attendLabel
color: Material.secondaryTextColor//"grey"
color: Material.secondaryTextColor
height:3.5*mm
font.pointSize: 0.75*osSettings.systemFontSize
horizontalAlignment: Label.AlignRight
@ -284,12 +275,12 @@ Item {
height: root.fontFactor*osSettings.bigFontSize
CheckBox{
id:likeCheckbox
width:newsitem.width/5 //10*mm
width:newsitem.width/5
height: parent.height
visible: ((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))? true:false
checked:(model.newsitemobject.friendica_activities_view.self.liked==1)?true:false
indicator: Rectangle{
implicitWidth: newsitem.width/5 //10*mm
implicitWidth: newsitem.width/5
implicitHeight:root.fontFactor*osSettings.bigFontSize
color:"transparent"
Text{
@ -312,12 +303,12 @@ Item {
}
CheckBox{
id: dislikeCheckbox
width:newsitem.width/5 //10*mm
width:newsitem.width/5
height: parent.height
visible: ((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))? true:false
checked: (newsitemobject.friendica_activities_view.self.disliked==1)?true:false
indicator: Rectangle{
implicitWidth: newsitem.width/5 //10*mm
implicitWidth: newsitem.width/5
implicitHeight:root.fontFactor*osSettings.bigFontSize
color:"transparent"
Text{
@ -339,39 +330,72 @@ Item {
}}
}
CheckBox {
id:favoritedCheckbox
visible:((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))
width: newsitem.width/5 // 10*mm
// CheckBox {
// id:favoritedCheckbox
// visible:((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))
// width: newsitem.width/5
// height: parent.height
// indicator:Rectangle{
// implicitWidth: newsitem.width/5
// implicitHeight:root.fontFactor*osSettings.bigFontSize
// color:"transparent"
// Text{
// anchors.centerIn: parent
// font.pointSize: osSettings.systemFontSize
// font.family:fontAwesome.name
// color: favoritedCheckbox.checked?Material.primaryTextColor: Material.secondaryTextColor
// text:"\uf005"
// }
// }
// checked:(newsitemobject.favorited>0)
// onClicked:{
// if(favoritedCheckbox.checkState==Qt.Checked){
// Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
// else if(favoritedCheckbox.checkState==Qt.Unchecked){
// Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
// }
// }
Rectangle{
width: newsitem.width/5
height: parent.height
indicator:Rectangle{
implicitWidth: newsitem.width/5 //10*mm
implicitHeight:root.fontFactor*osSettings.bigFontSize
color:"transparent"
Text{
anchors.centerIn: parent
font.pointSize: osSettings.systemFontSize
font.family:fontAwesome.name
color: favoritedCheckbox.checked?Material.primaryTextColor: Material.secondaryTextColor
text:"\uf005"
}
visible:(newsitemobject.messagetype!==2)
color:"transparent"
Text{
id:replysymbol
color: Material.secondaryTextColor
anchors.centerIn: parent
font.pointSize: osSettings.systemFontSize
font.family:fontAwesome.name
text: "\uf112"
}
checked:(newsitemobject.favorited>0)
onClicked:{
if(favoritedCheckbox.checkState==Qt.Checked){
Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
else if(favoritedCheckbox.checkState==Qt.Unchecked){
Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
MouseArea{
anchors.fill:parent
onClicked: {
var directmessage=0;
if (newsitemobject.messagetype==1){ directmessage=1}
var replycomp=Qt.createComponent("qrc:/qml/newsqml/MessageSend.qml");
var conversation;
if (newsitem.ListView.view==null){conversation=true}
else if (newsitem.ListView.view.viewtype=="conversation"){
conversation=true
newsitem.ListView.view.currentIndex=itemindex
}
else{
conversation=false;
newsitem.ListView.view.currentIndex=itemindex
};
var reply=replycomp.createObject(friendicaActivities,{parentId:newsitemobject.id,reply_to_user:newsitemobject.user.screen_name, state:"reply",conversation:conversation,textfocus:true})
}
}
}
Rectangle{
width: newsitem.width/5 //10*mm
width: newsitem.width/5
height: parent.height
visible:(newsitemobject.messagetype!==2)
color:"transparent"
Text{
id:newsmenusymbol
color: Material.secondaryTextColor//"grey"
color: Material.secondaryTextColor
anchors.centerIn: parent
font.pointSize: osSettings.systemFontSize
font.family:fontAwesome.name
@ -393,30 +417,8 @@ Item {
text: parent.text
}
}
Action{
text: qsTr("Reply")
onTriggered: {
var directmessage=0;
if (newsitemobject.messagetype==1){ directmessage=1}
var replycomp=Qt.createComponent("qrc:/qml/newsqml/MessageSend.qml");
var conversation;
if (newsitem.ListView.view==null){conversation=true}
else if (newsitem.ListView.view.viewtype=="conversation"){
conversation=true
newsitem.ListView.view.currentIndex=itemindex
}
else{
conversation=false;
newsitem.ListView.view.currentIndex=itemindex
};
var reply=replycomp.createObject(friendicaActivities,{parentId:newsitemobject.id,reply_to_user:newsitemobject.user.screen_name, state:"reply",conversation:conversation,textfocus:true})
}
}
Action {
text: qsTr("DM")
onTriggered: {
root.directmessageSignal(newsitemobject.user.screen_name);
}
onAboutToShow:{if(newsitemobject.hasOwnProperty("external_url")){
insertAction(4,externalAction)}
}
Action {
text: qsTr("Repost")
@ -432,7 +434,21 @@ Item {
pushConversation();
}
}
Action {
text: qsTr("DM")
onTriggered: {
root.directmessageSignal(newsitemobject.user.screen_name);
}
}
Action {
text: qsTr("Bookmark")
onTriggered: {
if(model.newsitemobject.favorited==0){
Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
else if(model.newsitemobject.favorited==1){
Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
}
}
Menu{
title: qsTr("Attending")
width: 10*root.fontFactor*osSettings.systemFontSize
@ -469,11 +485,6 @@ Item {
})
}
}
//MenuItem{
// text:qsTr("Show on website")
// onTriggered:Qt.openUrlExternally(login.server+"/display/"+newsitemobject
//}
}
Column{
id:conversationColumn
@ -481,4 +492,8 @@ Item {
width: newsitem.width
}
}
Action{id:externalAction
text: qsTr("External")
onTriggered: {Qt.openUrlExternally(newsitemobject.external_url)}
}
}

View file

@ -207,7 +207,7 @@ Rectangle{
width:4.5*mm
height: 4.5*mm
textFormat:Text.RichText
font.pointSize: 1.2*osSettings.systemFontSize
font.pointSize: osSettings.osType=="Linux"?1.7*osSettings.systemFontSize:1.2*osSettings.systemFontSize
text: emoji
MouseArea{