forked from lubuwest/Friendiqa
v.0.5
This commit is contained in:
parent
63dfb9b197
commit
d48847d183
135 changed files with 8879 additions and 3693 deletions
|
@ -29,37 +29,16 @@
|
|||
// 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.7
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls 2.3 as QC2
|
||||
import QtQuick 2.11
|
||||
import QtQuick.Controls 2.4
|
||||
//import QtQuick.Controls.Styles 2.3
|
||||
import QtQuick.Dialogs 1.3
|
||||
import "qrc:/qml/genericqml"
|
||||
//import QtQuick.Dialogs 1.3
|
||||
import "qrc:/qml/newsqml"
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/service.js" as Service
|
||||
|
||||
|
||||
import AndroidNative 1.0
|
||||
|
||||
Item {
|
||||
Connections{
|
||||
target:newstab
|
||||
onNewstabstatusChanged:{
|
||||
newstabstatusButton.text= qsTr(newstab.newstabstatus)
|
||||
}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:xhr
|
||||
onError:{
|
||||
Helperjs.showMessage(qsTr("Network Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);
|
||||
}
|
||||
onSuccess:{
|
||||
// downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
|
||||
Service.processNews(api,data);
|
||||
}
|
||||
}
|
||||
|
||||
// Connections{
|
||||
// target:xhr
|
||||
|
@ -80,43 +59,18 @@ Item {
|
|||
// }
|
||||
|
||||
|
||||
Timer {id:replytimer; interval: 1000; running: false; repeat: false
|
||||
onTriggered: {
|
||||
if(newstab.newstabstatus=="Conversation"){
|
||||
showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)}
|
||||
else{
|
||||
Service.updateView(newstab.newstabstatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timer {id:contacttimer; interval: 50; running: false; repeat: false
|
||||
onTriggered: {
|
||||
onTriggered: {//print("Contacttimer "+JSON.stringify(root.news));
|
||||
// downloadNotice.text=downloadNotice.text + "\n contactTimer start "+ Date.now()
|
||||
root.newContacts=Newsjs.findNewContacts(root.news,root.contactlist);
|
||||
Newsjs.storeNews(login,db,root.news,root)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showNews(newsToShow){
|
||||
try{
|
||||
if (newsStack.depth>1){newsStack.pop()}
|
||||
}catch(e){}
|
||||
newsBusy.running=false;
|
||||
var currentTime= new Date();
|
||||
// downloadNotice.text=downloadNotice.text + "\n shownews start "+ Date.now();
|
||||
//print("appendnews "+newsStack.appendNews +JSON.stringify(newsToShow))
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow,'method':newsStack.updateMethodNews, 'options':globaloptions};
|
||||
newsWorker.sendMessage(msg);
|
||||
//newsStack.appendNews=false
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showConversation(conversationIndex,newsitemobject){
|
||||
if(newsitemobject.messagetype==0){
|
||||
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
|
||||
xhr.clearParams();
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setUrl(login.server);
|
||||
|
@ -134,31 +88,12 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
function showContact(contact){
|
||||
newstab.newstabstatus="Contact";
|
||||
newsStack.push({item:"qrc:/qml/newsqml/ContactPage.qml",properties:{"contact": contact}});
|
||||
}
|
||||
|
||||
function search(term){//print("Search "+term)
|
||||
if (term!=""){
|
||||
newstab.newstabstatus="Search";
|
||||
newsBusy.running=true;
|
||||
newsStack.updateMethodNews="refresh";
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setUrl(login.server);
|
||||
xhr.setApi("/api/search");
|
||||
xhr.clearParams();
|
||||
xhr.setParam("q",term)
|
||||
xhr.get();}
|
||||
newsView.anchors.topMargin=7*mm
|
||||
}
|
||||
|
||||
|
||||
function onFriendsMessages(friend){
|
||||
newstab.newstabstatus="Contact"
|
||||
Newsjs.newsfromdb(db,root.login.username, function(dbnews){
|
||||
Newsjs.newsfromdb(db,root.login.username, 0,function(dbnews){
|
||||
if (dbnews.length==0){
|
||||
Newsjs.newsfromdb(db,login.username,function(forumnews){
|
||||
Newsjs.newsfromdb(db,login.username,0,function(forumnews){
|
||||
showNews(forumnews)
|
||||
},friend.url)
|
||||
}
|
||||
|
@ -166,303 +101,84 @@ Item {
|
|||
},friend.id)
|
||||
}
|
||||
|
||||
function onDirectMessage(friend){
|
||||
//newstab.newstabstatus="SendMessage" ,"login":login ,
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1, "login":root.login}});
|
||||
}
|
||||
|
||||
function sendUrls(urls){print(root.currentIndex==0);
|
||||
if((urls.length==1)&&(newsStack.depth<2)){
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"attachImageURLs":urls}})
|
||||
Label{
|
||||
text:"\uf0c9 "
|
||||
font.pixelSize: 5* mm
|
||||
anchors.left: parent.left
|
||||
anchors.margins: mm
|
||||
color: "#B0BEC5"
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked:{
|
||||
leftDrawer.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendtext(text){
|
||||
if(text&&(newsStack.depth<2)){
|
||||
if (text.subject=="undefined"){text.subject=""}
|
||||
if(text.plaintext.lastIndexOf(".jpg")>-1 || text.plaintext.lastIndexOf(".jpeg")>-1 || text.plaintext.lastIndexOf(".png")>-1 || text.plaintext.lastIndexOf(".gif")>-1){
|
||||
text.plaintext="<a href="+text.plaintext+"><img src="+text.plaintext+"></a>"}
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"bodyMessage":text.subject+"\n"+text.plaintext}})
|
||||
}
|
||||
Label{
|
||||
text:qsTr(newsSwipeview.stacktype)
|
||||
font.pixelSize: 3* mm
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.margins: 2*mm
|
||||
}
|
||||
SwipeView{
|
||||
id: newsSwipeview
|
||||
property string stacktype:"Home"
|
||||
currentIndex: 0
|
||||
width: parent.width
|
||||
height: parent.height-6*mm
|
||||
y: 5*mm
|
||||
function onDirectMessage(friend){currentIndex=2}
|
||||
|
||||
StackView{
|
||||
id: newsStack
|
||||
anchors.fill:parent
|
||||
property string updateMethodNews: "refresh"
|
||||
property var allchats: ({})
|
||||
initialItem:Rectangle {
|
||||
id:newslistRectangle
|
||||
y:1
|
||||
color: "white"
|
||||
|
||||
BlueButton{
|
||||
id:newstabstatusButton
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
text: qsTr(newstab.newstabstatus)
|
||||
onClicked: {newstabmenu.popup(2*mm,6*mm)}
|
||||
|
||||
QC2.Menu{id:newstabmenu
|
||||
width: 40*mm
|
||||
|
||||
delegate:QC2.MenuItem{
|
||||
contentItem: Text{
|
||||
font.pixelSize: 3.5*mm
|
||||
text:parent.text
|
||||
}
|
||||
background: Rectangle {
|
||||
implicitWidth: 40*mm; implicitHeight: 5*mm
|
||||
color: "#ffffff"
|
||||
border.color: "grey"
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Timeline")
|
||||
onTriggered: {
|
||||
newstab.newstabstatus="Timeline";
|
||||
//newsModel.clear();
|
||||
try{ Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}catch(e){Helperjs.showMessage("Error",e,root)}}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Conversations")
|
||||
onTriggered:{
|
||||
//newsModel.clear();
|
||||
newstab.newstabstatus="Conversations";
|
||||
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Favorites")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Favorites";
|
||||
Service.updateView("Favorites")
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Replies")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Replies";
|
||||
Service.updateView("Replies")
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Public timeline")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Public Timeline";
|
||||
Service.updateView("Public Timeline")
|
||||
}
|
||||
}
|
||||
|
||||
QC2.Action {
|
||||
text: qsTr("Direct Messages")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Direct Messages";
|
||||
Service.updateView("Direct Messages")
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Notifications")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Notifications";
|
||||
Service.updateView("Notifications")
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
|
||||
text: qsTr("Group news")
|
||||
onTriggered:
|
||||
{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
Service.showGroups();
|
||||
}
|
||||
}
|
||||
QC2.Action {
|
||||
text: qsTr("Quit")
|
||||
onTriggered:{
|
||||
Service.cleanNews(root.db,function(){
|
||||
Service.cleanContacts(root.login,root.db,function(){
|
||||
Qt.quit()})
|
||||
})
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
PropertyAnimation { properties: "height";
|
||||
easing.type: Easing.InOutQuad
|
||||
duration: 1000
|
||||
}
|
||||
}
|
||||
|
||||
Row{
|
||||
spacing: mm
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0.5*mm
|
||||
anchors.right: parent.right
|
||||
|
||||
BlueButton {
|
||||
id: searchButton
|
||||
text: "\uf002"
|
||||
onClicked: {
|
||||
newsView.anchors.topMargin=18*mm;
|
||||
var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
|
||||
var searchItem = component.createObject(newsStack,{y:8*mm,width:root.width,height: 8*mm});
|
||||
}
|
||||
}
|
||||
|
||||
BlueButton {
|
||||
id: newMessageButton
|
||||
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("qrc:/qml/newsqml/MessageSend.qml",{"contacts": friends,"login":root.login})
|
||||
},"isFriend",1);
|
||||
}
|
||||
}
|
||||
// BlueButton {
|
||||
// id: quitButton
|
||||
// text: "\uf08b"
|
||||
// onClicked: {Service.cleanNews(root.db,function(){
|
||||
// Service.cleanContacts(root.login,root.db,function(){
|
||||
// Qt.quit() })
|
||||
// })}
|
||||
// }
|
||||
BlueButton {
|
||||
id: update
|
||||
text: "\uf021"
|
||||
onClicked: {
|
||||
if (newstab.newstabstatus=="Timeline"){
|
||||
newsStack.updateMethodNews="append"
|
||||
} else {newsStack.updateMethodNews="refresh"}
|
||||
//root.contactLoadType="news";
|
||||
Service.updateView(newstab.newstabstatus)
|
||||
onCurrentIndexChanged: {
|
||||
switch(currentIndex){
|
||||
case 0: stacktype="Home";break;
|
||||
case 1: stacktype="Replies";break;
|
||||
case 2: stacktype="DirectMessages";break;
|
||||
case 3: stacktype="Notifications";break;
|
||||
default: stacktype="Home";
|
||||
}
|
||||
}
|
||||
|
||||
//anchors.fill: parent
|
||||
Loader{
|
||||
id: friendstimeline
|
||||
source:(newsSwipeview.currentIndex==0)? "qrc:/qml/newsqml/NewsStack.qml":""
|
||||
//onLoaded: newsSwipeview.stacktype="Home"
|
||||
}
|
||||
Component { id:footerComponent
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:newsView.width
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 1.5*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("More")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{
|
||||
var currentTime= new Date();
|
||||
var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;
|
||||
if(newstab.newstabstatus=="Timeline"){
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(news){
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true, 'options':globaloptions};
|
||||
newsWorker.sendMessage(msg);
|
||||
},false,lastnews_id)}
|
||||
if(newstab.newstabstatus=="Conversations"){
|
||||
Newsjs.chatsfromdb(root.db,root.login.username, function(news){
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true, 'options':globaloptions};
|
||||
newsWorker.sendMessage(msg);
|
||||
},lastnews_id)}
|
||||
// else if(newstab.newstabstatus=="Contact"){
|
||||
// Newsjs.newsfromdb(root.db,root.login.username, function(news){
|
||||
// var msg = {'currentTime': currentTime, 'model': newsModel,'news':news,'appendnews':true};
|
||||
// newsWorker.sendMessage(msg);
|
||||
// },newsModel.get(newsModel.count-1).newsitemobject.uid,lastnews_id)}
|
||||
else if (newstab.newstabstatus=="Notifications"){}
|
||||
else{
|
||||
//newsStack.appendNews=true;
|
||||
xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);
|
||||
xhr.get()
|
||||
}}
|
||||
}
|
||||
}
|
||||
Loader{
|
||||
id: replies
|
||||
//property string stacktype:"Replies"
|
||||
source:(newsSwipeview.currentIndex==1)? "qrc:/qml/newsqml/NewsStack.qml":""
|
||||
//onLoaded: newsSwipeview.stacktype="Replies"
|
||||
}
|
||||
|
||||
|
||||
ListView {
|
||||
id: newsView
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 7*root.mm
|
||||
anchors.leftMargin: 3*root.mm; anchors.rightMargin: root.mm
|
||||
anchors.bottomMargin: 1*root.mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
footer: footerComponent
|
||||
model: newsModel
|
||||
delegate: Newsitem{}
|
||||
//onContentYChanged:{if(contentY<-8*mm&&contentY>(-8*mm-1)){print("refreshing");
|
||||
onDragEnded:{if(contentY<-5*mm){
|
||||
var onlynew=true;
|
||||
Service.updateView(newstab.newstabstatus)
|
||||
}}
|
||||
Loader{
|
||||
id: directmessages
|
||||
property var friend:({})
|
||||
source:(newsSwipeview.currentIndex==2)? "qrc:/qml/newsqml/NewsStack.qml":""
|
||||
//onLoaded: newsSwipeview.stacktype="DirectMessages"
|
||||
}
|
||||
|
||||
ListModel{id: newsModel}
|
||||
|
||||
WorkerScript {
|
||||
id: newsWorker
|
||||
source: "qrc:/js/newsworker.js"
|
||||
}
|
||||
|
||||
BusyIndicator{
|
||||
id: newsBusy
|
||||
anchors.horizontalCenter: newsView.horizontalCenter
|
||||
anchors.top:newsView.top
|
||||
anchors.topMargin: 2*mm
|
||||
width:10*mm
|
||||
height: 10*mm
|
||||
}
|
||||
Rectangle{
|
||||
id:downloadNotice
|
||||
property alias text: noticeText.text
|
||||
color:"white"
|
||||
border.color:"grey"
|
||||
z:1
|
||||
anchors.horizontalCenter: newsView.horizontalCenter
|
||||
anchors.bottom:newsView.bottom
|
||||
anchors.bottomMargin: 2*mm
|
||||
width: noticeText.width+2*mm
|
||||
height: noticeText.height+2*mm
|
||||
visible: (downloadNotice.text!="")
|
||||
|
||||
Text{
|
||||
id:noticeText
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
width: contentWidth
|
||||
height: contentHeight
|
||||
font.pixelSize: 2*mm
|
||||
text:""
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
root.messageSignal.connect(onFriendsMessages);
|
||||
root.directmessageSignal.connect(onDirectMessage);
|
||||
root.contactdetailsSignal.connect(showContact);
|
||||
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);
|
||||
})}
|
||||
}
|
||||
Loader{
|
||||
id: notifications
|
||||
//property string stacktype:"Notifications"
|
||||
source:(newsSwipeview.currentIndex==3)? "qrc:/qml/newsqml/NewsStack.qml":""
|
||||
//onLoaded: newsSwipeview.stacktype="Notifications"
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {root.directmessageSignal.connect(onDirectMessage);}
|
||||
}
|
||||
|
||||
PageIndicator {
|
||||
id: swipeIndicator
|
||||
count: newsSwipeview.count
|
||||
currentIndex: newsSwipeview.currentIndex
|
||||
|
||||
anchors.bottom: newsSwipeview.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue