forked from lubuwest/Friendiqa
Friendiqa v0.3.2
This commit is contained in:
parent
8cd5905b63
commit
99ae53f624
54 changed files with 2771 additions and 437 deletions
|
@ -29,8 +29,9 @@
|
|||
// 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
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls 2.3 as QC2
|
||||
//import QtQuick.Controls.Styles 2.3
|
||||
import QtQuick.Dialogs 1.3
|
||||
import "qrc:/qml/genericqml"
|
||||
|
@ -50,7 +51,7 @@ Item {
|
|||
Connections{
|
||||
target:xhr
|
||||
onError:{
|
||||
Helperjs.showMessage(qsTr("Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);
|
||||
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();
|
||||
|
@ -85,9 +86,9 @@ Item {
|
|||
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,'appendnews':newsStack.appendNews};
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow,'method':newsStack.updateMethodNews};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsStack.appendNews=false
|
||||
//newsStack.appendNews=false
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,13 +127,14 @@ Item {
|
|||
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();}
|
||||
newsSearch.visible=false;
|
||||
//newsSearch.visible=false;
|
||||
newsView.anchors.topMargin=7*mm
|
||||
}
|
||||
|
||||
|
@ -151,21 +153,21 @@ Item {
|
|||
|
||||
function onDirectMessage(friend){
|
||||
newstab.newstabstatus="SendMessage"
|
||||
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"reply_to_user": friend,"directmessage":1,"login":root.login});
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||
}
|
||||
|
||||
function sendUrls(urls){
|
||||
function sendUrls(urls){print(root.currentIndex==0);
|
||||
if((urls.length==1)&&(newsStack.depth<2)){
|
||||
newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"attachImageURLs":urls})
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"attachImageURLs":urls}})
|
||||
}
|
||||
}
|
||||
|
||||
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(".jpeg")>-1){
|
||||
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("qrc:/qml/newsqml/MessageSend.qml",{"bodyMessage":text.subject+"\n"+text.plaintext})
|
||||
newsStack.push({item:"qrc:/qml/newsqml/MessageSend.qml",properties:{"bodyMessage":text.subject+"\n"+text.plaintext}})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +175,7 @@ Item {
|
|||
id: newsStack
|
||||
anchors.fill:parent
|
||||
property int conversationIndex: 0
|
||||
property bool appendNews: false
|
||||
property string updateMethodNews: "refresh"
|
||||
property var allchats: ({})
|
||||
initialItem:Rectangle {
|
||||
id:newslistRectangle
|
||||
|
@ -187,10 +189,10 @@ Item {
|
|||
text: qsTr(newstab.newstabstatus)
|
||||
onClicked: {newstabmenu.popup(2*mm,6*mm)}
|
||||
|
||||
Menu{id:newstabmenu
|
||||
QC2.Menu{id:newstabmenu
|
||||
width: 40*mm
|
||||
|
||||
delegate:MenuItem{
|
||||
delegate:QC2.MenuItem{
|
||||
contentItem: Text{
|
||||
font.pixelSize: 3.5*mm
|
||||
text:parent.text
|
||||
|
@ -201,57 +203,66 @@ Item {
|
|||
border.color: "grey"
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Timeline")
|
||||
onTriggered: {
|
||||
newstab.newstabstatus="Timeline";
|
||||
newsModel.clear();
|
||||
//newsModel.clear();
|
||||
try{ Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}catch(e){Helperjs.showMessage("Error",e,root)}}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Conversations")
|
||||
onTriggered:{
|
||||
newsModel.clear();
|
||||
//newsModel.clear();
|
||||
newstab.newstabstatus="Conversations";
|
||||
Newsjs.chatsfromdb(db,root.login.username,function(news){showNews(news)})
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Favorites")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Favorites";
|
||||
Service.updateView("Favorites")
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Public timeline")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Public Timeline";
|
||||
Service.updateView("Public Timeline")
|
||||
}
|
||||
}
|
||||
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Direct Messages")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Direct Messages";
|
||||
Service.updateView("Direct Messages")
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Notifications")
|
||||
onTriggered:{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
newstab.newstabstatus="Notifications";
|
||||
Service.updateView("Notifications")
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
|
||||
text: qsTr("Group news")
|
||||
onTriggered:Service.showGroups();
|
||||
onTriggered:
|
||||
{
|
||||
newsStack.updateMethodNews="refresh";
|
||||
Service.showGroups();
|
||||
}
|
||||
}
|
||||
Action {
|
||||
QC2.Action {
|
||||
text: qsTr("Quit")
|
||||
onTriggered:{
|
||||
Service.cleanNews(root.db,function(){
|
||||
|
@ -273,13 +284,17 @@ Item {
|
|||
id: searchButton
|
||||
text: "\uf002"
|
||||
onClicked: {
|
||||
if (newsSearch.visible==false){
|
||||
//if (newsSearch.visible==false){
|
||||
newsView.anchors.topMargin=18*mm;
|
||||
newsSearch.visible=true}
|
||||
else{
|
||||
newsSearch.visible=false;
|
||||
newsView.anchors.topMargin=7*mm;
|
||||
}
|
||||
var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
|
||||
var searchItem = component.createObject(newsStack,{y:8*mm,width:root.width,height: 8*mm});
|
||||
//searchItem.forceActiveFocus()
|
||||
|
||||
// newsSearch.visible=true}
|
||||
//else{
|
||||
// newsSearch.visible=false;
|
||||
// newsView.anchors.topMargin=7*mm;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,6 +324,9 @@ Item {
|
|||
id: update
|
||||
text: "\uf021"
|
||||
onClicked: {
|
||||
if (newstab.newstabstatus=="Timeline"){
|
||||
newsStack.updateMethodNews="append"
|
||||
} else {newsStack.updateMethodNews="refresh"}
|
||||
root.contactLoadType="news";
|
||||
Service.updateView(newstab.newstabstatus)
|
||||
}
|
||||
|
@ -354,18 +372,19 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
id: newsSearch
|
||||
color: "#FFFAFA"
|
||||
y:8*mm
|
||||
width:root.width
|
||||
height: 8*mm
|
||||
visible:false
|
||||
Search{
|
||||
anchors.fill: parent
|
||||
anchors.margins: mm
|
||||
}
|
||||
}
|
||||
// Rectangle{
|
||||
// id: newsSearch
|
||||
// color: "#FFFAFA"
|
||||
// y:8*mm
|
||||
// width:root.width
|
||||
// height: 8*mm
|
||||
// //visible:false
|
||||
// Search{
|
||||
// anchors.fill: parent
|
||||
// anchors.margins: mm
|
||||
// }
|
||||
// }
|
||||
|
||||
ListView {
|
||||
id: newsView
|
||||
anchors.fill: parent
|
||||
|
@ -378,11 +397,12 @@ Item {
|
|||
model: newsModel
|
||||
delegate: Newsitem{}
|
||||
//onContentYChanged:{if(contentY<-8*mm&&contentY>(-8*mm-1)){print("refreshing");
|
||||
onDragEnded:{if(contentY<-5*mm){//print("refreshing");
|
||||
onDragEnded:{if(contentY<-5*mm){
|
||||
root.contactLoadType="news";
|
||||
var onlynew=true;
|
||||
Service.updateView(newstab.newstabstatus)
|
||||
}}
|
||||
//Component.onCompleted: currentIndex=count
|
||||
}
|
||||
|
||||
ListModel{id: newsModel}
|
||||
|
@ -436,7 +456,9 @@ Item {
|
|||
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)})}
|
||||
else{Newsjs.chatsfromdb(db,login.username,function(dbnews){
|
||||
showNews(dbnews);
|
||||
})}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue