Version 0.002 code cleanup and event attending

This commit is contained in:
LubuWest 2017-01-29 17:26:09 +01:00
commit d8186978e7
42 changed files with 925 additions and 968 deletions

View file

@ -1,8 +1,8 @@
import QtQuick 2.0
import QtQuick.Dialogs 1.2
//import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
//import QtQuick.LocalStorage 2.0 as Sql
import "qrc:/qml"
//import "qrc:/qml"
import "qrc:/qml/genericqml"
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/helper.js" as Helperjs
@ -15,6 +15,7 @@ Item {
newstabstatusButton.text= qsTr(newstab.newstabstatus)
}
}
Connections{
target:newstab
onConversationChanged:{
@ -23,14 +24,24 @@ Item {
newsStack.push({item:"qrc:/qml/newsqml/Conversation.qml",properties:{"news": conversation}})
}
}
Connections{
target:root
onCurrentContactChanged:{
if (root.newContacts.length>0){
print(Qt.atob(root.newContacts[root.currentContact].name))
}
if(root.currentContact<root.newContacts.length){
downloadNotice.text= qsTr("Download profile image for ")+ root.newContacts[root.currentContact].name;
print(root.newContacts[root.currentContact].name)
}
}else{downloadNotice.text=""}
}
}
Connections{
target:xhr
onError:{if (data=="contact"){downloadNotice.text=downloadNotice.text+"... Error!"}}
}
function showNews(newsToShow){
if (newsStack.depth>1){newsStack.pop()}
newsBusy.running=false;
@ -40,7 +51,7 @@ Item {
}
function onFriendsMessages(friend){
newstab.newstabstatus="Contact";
newstab.newstabstatus="Contact"
Newsjs.newsfromdb(db,root.login.username, function(dbnews){showNews(dbnews)},friend)
}
@ -83,7 +94,7 @@ Item {
var groups=[];
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
groups=groupobject});
newstab.newstabstatus="SendMessage"
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}})
},"isFriend",1);
@ -177,7 +188,29 @@ Item {
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:""
}
}
Menu {
id:newstabmenu
MenuItem {
@ -224,6 +257,7 @@ Item {
root.directmessageSignal.connect(onDirectMessage);
root.newsSignal.connect(showNews);
try{newsModel.clear()} catch(e){}
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)})}
}