Friendiqa/source-linux/qml/newsqml/NewsTab.qml

183 lines
6.4 KiB
QML
Raw Normal View History

2018-02-19 22:36:00 +01:00
// This file is part of Friendiqa
2018-11-09 22:06:13 +01:00
// https://git.friendi.ca/lubuwest/Friendiqa
2018-02-19 22:36:00 +01:00
// 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/>.
2019-06-25 20:59:10 +02:00
import QtQuick 2.11
import QtQuick.Controls 2.4
2018-07-20 21:15:54 +02:00
//import QtQuick.Controls.Styles 2.3
2019-06-25 20:59:10 +02:00
//import QtQuick.Dialogs 1.3
import "qrc:/qml/newsqml"
2017-01-26 21:55:31 +01:00
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/service.js" as Service
Item {
2017-03-25 23:36:14 +01:00
2019-01-09 22:03:16 +01:00
// Connections{
// target:xhr
// onError:{
// Helperjs.showMessage(qsTr("Network Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);
// }
// onSuccess:{
// if (api=="/api/statuses/friends_timeline"){
// // downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
// //Service.processNews(api,data);
// if(login.newsViewType=="Timeline"){
// Newsjs.newsfromdb(db,login.username,function(dbnews){showNews(dbnews)})}
// else{Newsjs.chatsfromdb(db,login.username,function(dbnews){
// showNews(dbnews);
// })}
// }
// }
// }
2018-07-01 15:09:21 +02:00
Timer {id:contacttimer; interval: 50; running: false; repeat: false
2019-12-10 21:12:32 +01:00
onTriggered: {
2018-07-01 15:09:21 +02:00
// downloadNotice.text=downloadNotice.text + "\n contactTimer start "+ Date.now()
root.newContacts=Newsjs.findNewContacts(root.news,root.contactlist);
Newsjs.storeNews(login,db,root.news,root)
}
}
2017-05-11 22:15:34 +02:00
function showConversation(conversationIndex,newsitemobject){
2019-06-25 20:59:10 +02:00
if(newsitemobject.messagetype==0 || newsitemobject.messagetype==3){
2018-07-01 15:09:21 +02:00
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/conversation/show");
xhr.setParam("id",newsitemobject.id)
xhr.get();
}
else{
xhr.clearParams();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/direct_messages/conversation");
xhr.setParam("uri",newsitemobject.statusnet_conversation_id)
xhr.get();
}
2017-03-25 23:36:14 +01:00
}
2018-07-01 15:09:21 +02:00
2017-01-26 21:55:31 +01:00
function onFriendsMessages(friend){
newstab.newstabstatus="Contact"
2019-06-25 20:59:10 +02:00
Newsjs.newsfromdb(db,root.login.username, 0,function(dbnews){
2018-02-19 22:36:00 +01:00
if (dbnews.length==0){
2019-06-25 20:59:10 +02:00
Newsjs.newsfromdb(db,login.username,0,function(forumnews){
2018-02-19 22:36:00 +01:00
showNews(forumnews)
},friend.url)
}
else showNews(dbnews)
},friend.id)
2017-01-26 21:55:31 +01:00
}
2019-06-25 20:59:10 +02:00
Label{
text:"\uf0c9 "
font.pixelSize: 5* mm
anchors.left: parent.left
anchors.margins: mm
color: "#B0BEC5"
MouseArea{
anchors.fill: parent
onClicked:{
leftDrawer.open()
}
2018-04-22 21:12:40 +02:00
}
}
2019-06-25 20:59:10 +02:00
Label{
text:qsTr(newsSwipeview.stacktype)
font.pixelSize: 3* mm
anchors.horizontalCenter: parent.horizontalCenter
anchors.margins: 2*mm
2018-04-11 21:50:43 +02:00
}
2019-06-25 20:59:10 +02:00
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}
transitions: Transition {
PropertyAnimation { properties: "height";
easing.type: Easing.InOutQuad
duration: 1000
2018-07-01 15:09:21 +02:00
}
2017-01-26 21:55:31 +01:00
}
2019-06-25 20:59:10 +02:00
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";
2017-03-25 23:36:14 +01:00
}
2017-01-26 21:55:31 +01:00
}
2019-06-25 20:59:10 +02:00
//anchors.fill: parent
Loader{
id: friendstimeline
source:(newsSwipeview.currentIndex==0)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="Home"
2017-01-26 21:55:31 +01:00
}
2019-06-25 20:59:10 +02:00
Loader{
id: replies
//property string stacktype:"Replies"
source:(newsSwipeview.currentIndex==1)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="Replies"
2017-01-26 21:55:31 +01:00
}
2019-06-25 20:59:10 +02:00
Loader{
id: directmessages
property var friend:({})
source:(newsSwipeview.currentIndex==2)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="DirectMessages"
2017-05-11 22:15:34 +02:00
}
2019-06-25 20:59:10 +02:00
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);}
}
2017-01-26 21:55:31 +01:00
2019-06-25 20:59:10 +02:00
PageIndicator {
id: swipeIndicator
count: newsSwipeview.count
currentIndex: newsSwipeview.currentIndex
2017-01-26 21:55:31 +01:00
2019-06-25 20:59:10 +02:00
anchors.bottom: newsSwipeview.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
2017-01-26 21:55:31 +01:00
}