Version 0.002 with working Permissions

This commit is contained in:
LubuWest 2016-12-04 18:28:52 +01:00
commit 15e2e8f60a
62 changed files with 924 additions and 1277 deletions

View file

@ -0,0 +1,65 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import "qrc:/js/layout.js" as Layoutjs
Item {
id: contactComponent
property var createdAtDate: new Date(contact.created_at)
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:(contact.profile_image!="")? "file://"+contact.profile_image : contact.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Label {
id: namelabel
x: 1
width: wrapper.width-4
height: 3*mm
text: contact.screen_name
elide:Text.ElideRight
anchors.topMargin: 0
anchors.left: photoImage.left
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
contactComponent.state="large";
var component = Qt.createComponent("qrc:/qml/contactqml/ContactDetailsComponent.qml");
if (component.status== Component.Ready){
var contactDetails = component.createObject(wrapper,{"contact": contact})}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
PropertyChanges { target: contactComponent; z: 2 }
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
}
]
}

View file

@ -0,0 +1,77 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
//opacity: 0
Flickable{
id:namelabelflickable
width: root.width-10*mm
height:friendsTabView.height-55*mm
boundsBehavior:Flickable.StopAtBounds
flickableDirection:Flickable.VerticalFlick
contentWidth:width
contentHeight: namelabeltext.height
clip:true
Text{
id:namelabeltext
width: namelabelflickable.width
height: implicitHeight
font.pixelSize: 3*mm
textFormat:Text.RichText
wrapMode: Text.Wrap
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
onLinkActivated: {
Qt.openUrlExternally(link)}
}
}
Row{
anchors.top: namelabelflickable.bottom
anchors.topMargin: 2*mm
spacing:4
Button{
id:photobutton
text:"Photos"
visible:contact.location=="Friendica"? 1:0
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=2;
fotostab.active=true;
root.fotoSignal(contact) ;
}
}
Button{
id:messagebutton
text:"Messages"
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=0;
newstab.active=true;
root.messageSignal(contact.id) ;
}
}
Button{
id:dmbutton
visible: contact.following=="true"?true:false
text: "DM"
onClicked:{contactComponent.state="";detailsrectangle.destroy();
root.currentIndex=0;
newstab.active=true;
root.directmessageSignal(contact.screen_name);
}
}
Button{
id: closeButton
text: "close"
onClicked:{contactComponent.state="";detailsrectangle.destroy()}
}
}
}

View file

@ -0,0 +1,194 @@
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/news.js" as Newsjs
import "qrc:/qml/contactqml"
Rectangle {
y:1
color: "white"
TabView{
id:friendsTabView
// property var contacts: []
// property var groups: []
tabPosition: Qt.TopEdge
x:mm
y:mm
width: root.width-2*mm
height: root.height-10*mm
currentIndex: 0
signal contactsSignal(var username)
signal groupsSignal(var username)
onCurrentIndexChanged:{
if (currentIndex==0){root.friendsSignal(root.login.username)}
else if (currentIndex==1){contactsSignal(root.login.username)}
else if (currentIndex==2){groupsSignal(root.login.username)}
}
style: TabViewStyle {
frameOverlap: 1
tab: Rectangle {
color: "white"
//border.color: "light grey"
implicitWidth: root.width/3-2*mm
implicitHeight: 4*mm
Text { id: text
anchors.centerIn: parent
text: styleData.title
color: "dark grey"
font.pixelSize:2.5*mm
font.bold: styleData.selected
}
}
frame: Rectangle { color: "light grey" }
tabsAlignment:Qt.AlignHCenter
}
Tab{
title: qsTr("Friends")
Rectangle{
id: friendsGridTab
function showFriends(username){
try {friendsModel.clear()} catch(e){print(e)};
Helperjs.readData(db,"contacts",username,function(friendsobject){
for (var i=0;i<friendsobject.length;i++){
friendsModel.append({"contact":friendsobject[i]});
}},"isFriend",1)
}
Button {
id: updateFriendsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
try {friendsModel.clear()} catch(e){print(e)};
root.contactLoadType="friends";
Newsjs.requestFriends(root.login,db,root,function(nc){
root.newContacts=nc
})
}}
ProgressBar{
id: newContactsProgress
width: 15*mm
height: updateFriendsButton.height
anchors.top: parent.top
anchors.right:updateFriendsButton.left
anchors.rightMargin:mm
visible: (root.currentContact!=root.newContacts.length)?true:false
value: root.currentContact/root.newContacts.length
}
GridView {
id: friendsView
x:mm
y:updateFriendsButton.height+2*mm
width:friendsGridTab.width-2*mm
height:friendsGridTab.height-updateFriendsButton.height-2*mm
clip: true
cellHeight: 16*mm
cellWidth: 17*mm
add: Transition {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: friendsModel
delegate: ContactComponent { }
}
ListModel{id:friendsModel}
Component.onCompleted: {
root.friendsSignal.connect(showFriends);
showFriends(root.login.username)
}
}
}
Tab{
title: qsTr("Other Contacts")
Rectangle{
id: contactsGridTab
function showContacts(username){
try {contactsModel.clear()} catch(e){print(e)};
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
for (var j=0;j<contactsobject.length;j++){
contactsModel.append({"contact":contactsobject[j]});
}
},"isFriend",0)}
GridView {
id: contactsView
x:mm
y:2*mm
width:contactsGridTab.width-2*mm
height:contactsGridTab.height-2*mm
clip: true
cellHeight: 16*mm
cellWidth: 17*mm
add: Transition {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: contactsModel
delegate: ContactComponent { }
}
ListModel{id: contactsModel}
Component.onCompleted: {
friendsTabView.contactsSignal.connect(showContacts);
}
}
}
Tab{
title: qsTr("Groups")
Rectangle{
id: groupsGridTab
function showGroups(username){
try {groupsModel.clear()} catch(e){print(e)};
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
for (var j=0;j<groupsobject.length;j++){
groupsModel.append({"group":groupsobject[j]});
}})}
Button {
id: updateGroupsButton
text: qsTr("Update")
anchors.top: parent.top
anchors.topMargin: mm
anchors.right: parent.right
onClicked: {
print("Update groups");
Newsjs.requestGroups(root.login,root.db,root,function(){
showGroups(root.login.username)})}
}
GridView {
id: groupsView
x:mm
y:updateGroupsButton.height+2*mm
width:groupsGridTab.width-2*mm
height:groupsGridTab.height-updateGroupsButton.height-2*mm
clip: true
cellHeight: 16*mm
cellWidth: 17*mm
add: Transition {
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
}
model: groupsModel
delegate: GroupComponent { }
}
ListModel{
id: groupsModel
}
Component.onCompleted: {
friendsTabView.groupsSignal.connect(showGroups);
}
}
}
}
}

View file

@ -0,0 +1,118 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import "qrc:/js/helper.js" as Helperjs
Item {
id: groupComponent
Rectangle {
id: wrapper
width: 16*mm
height: 15*mm
border.color: "grey"
color:"white"
Image {
id: photoImage
x:1
y:1
width: 10*mm
height:10*mm
source:"qrc:/images/defaultcontact.jpg"
}
Label {
id: namelabel
x: 1
width: wrapper.width-2
height: 3*mm
text: group.groupname
color: "#303030"
font.pixelSize: 3*mm
anchors.top: photoImage.bottom
}
Button{
id:infobutton
width: 5*mm
height: 5*mm
text:"?"
anchors.left: photoImage.right
anchors.leftMargin: 3
anchors.topMargin: 3
anchors.top: parent.top
onClicked:{
Helperjs.readField("members",root.db,"groups",root.login.username,function(groups){
try {groupModel.clear()}catch (e){print(e)}
var groupmembers=JSON.parse(groups);
for (var user in groupmembers){
Helperjs.readData(root.db,"contacts",root.login.username,function(userdata){
groupModel.append({"groupmember":userdata[0]});
},"id",groupmembers[user])}
},"groupname",group.groupname);
groupComponent.state="large"}
}
Rectangle{
id: detailsrectangle
anchors.top: namelabel.bottom
anchors.topMargin: 2*mm
opacity: 0
Component { id:groupMember
Rectangle{
border.color: "#EEEEEE"
border.width: 1
width:parent.width
height:6*mm
Image {
id: memberImage
x:1
y:1
width: 5*mm
height:5*mm
source:(groupmember.isFriend==1)? "file://"+groupmember.profile_image :groupmember.profile_image_url
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
}
Text{
font.pixelSize: 3*mm
anchors.left: memberImage.right
anchors.margins: 1*mm
text:Qt.atob(groupmember.name)
}
}}
ListView{
id: groupListView
x:1
//anchors.top: parent.top
width: root.width-10*mm
height:groupsView.height -28*mm
clip: true
spacing: 2
model: groupModel
delegate: groupMember
}
ListModel{id: groupModel}
Button{
id: closeButton
anchors.top: groupListView.bottom
x:1
text: "close"
onClicked:{groupComponent.state=""}
}
}
}
states: [
State {
name: "large"
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width}
PropertyChanges { target: groupComponent; z: 2 }
PropertyChanges { target: wrapper; width:groupsView.width;height:groupsView.height -2*mm-1}
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
PropertyChanges { target:groupComponent.GridView.view ;contentY:groupComponent.y;contentX:groupComponent.x;interactive:false}
PropertyChanges { target: detailsrectangle; opacity:1 }
}
]
}