Qt/QML App for Friendiqa
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

friendiqa.qml 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // This file is part of Friendiqa
  2. // https://git.friendi.ca/lubuwest/Friendiqa
  3. // Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // In addition, as a special exception, the copyright holders give
  11. // permission to link the code of portions of this program with the
  12. // OpenSSL library under certain conditions as described in each
  13. // individual source file, and distribute linked combinations including
  14. // the two.
  15. //
  16. // You must obey the GNU General Public License in all respects for all
  17. // of the code used other than OpenSSL. If you modify file(s) with this
  18. // exception, you may extend this exception to your version of the
  19. // file(s), but you are not obligated to do so. If you do not wish to do
  20. // so, delete this exception statement from your version. If you delete
  21. // this exception statement from all source files in the program, then
  22. // also delete it here.
  23. //
  24. // This program is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU General Public License
  30. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. import QtQuick 2.5
  32. import QtQuick.LocalStorage 2.0
  33. import QtQuick.Window 2.0
  34. import QtQuick.Controls 1.2
  35. import QtQuick.Controls.Styles 1.4
  36. //import QtQuick.Controls 2.3
  37. import "qrc:/js/news.js" as Newsjs
  38. import "qrc:/js/service.js" as Service
  39. import "qrc:/qml/genericqml"
  40. import "qrc:/qml/newsqml"
  41. import "qrc:/qml/contactqml"
  42. import "qrc:/qml/photoqml"
  43. import "qrc:/qml/calendarqml"
  44. import "qrc:/qml/configqml"
  45. TabView{
  46. id:root
  47. property QtObject osSettings: {var tmp=Qt.createComponent("qrc:/qml/configqml/OSSettingsAndroid.qml");return tmp.createObject(root)}
  48. //IntentReceiver{}
  49. tabPosition: Qt.BottomEdge
  50. width: osSettings.appWidth
  51. height:osSettings.appHeight
  52. focus:true
  53. property var db: ["Friendiqa", "1.0", "Stores Friendica data", 100000000]
  54. property var login: Service.readActiveConfig(db)
  55. property var globaloptions: ({}) //Service.readGlobaloptions(db)
  56. property var contactlist: []
  57. property real mm: Screen.pixelDensity
  58. signal messageSignal(var friend)
  59. signal fotoSignal(var username, var friend)
  60. signal directmessageSignal(var friend)
  61. signal newsSignal(var news)
  62. signal friendsSignal(var username)
  63. signal contactdetailsSignal(var contact)
  64. signal eventSignal(var contact)
  65. signal uploadSignal(var urls)
  66. signal sendtextSignal(var intenttext)
  67. signal changeimage(var method, var type, var id)
  68. property var news:[]
  69. property var newContacts:[]
  70. //property string contactLoadType: ""
  71. property bool imagePicking: false
  72. onLoginChanged:{
  73. if(login==""){root.currentIndex=4}
  74. else{
  75. newstab.newstabstatus=login.newsViewType;
  76. Newsjs.getCurrentContacts(login,db,function(contacts){
  77. contactlist=contacts})}
  78. }
  79. onNewContactsChanged:{
  80. if(newContacts.length>0){// download contact images and update db
  81. var contacturls=[];
  82. var contactnames=[];
  83. for (var link in newContacts){
  84. contacturls.push(newContacts[link].profile_image_url);
  85. contactnames.push(newContacts[link].screen_name);
  86. Service.updateContactInDB(login,db,newContacts[link].isFriend,newContacts[link])
  87. contactlist.push(newContacts[link].url);
  88. }
  89. xhr.setDownloadtype("contactlist");
  90. xhr.setFilelist(contacturls);
  91. xhr.setContactlist(contactnames);
  92. xhr.setImagedir(login.imagestore);
  93. xhr.getlist();
  94. }
  95. }
  96. Connections{
  97. target:xhr
  98. onDownloaded:{
  99. if(type=="contactlist"){
  100. var database=LocalStorage.openDatabaseSync(root.db[0],root.db[1],root.db[2],root.db[3]);
  101. var result;
  102. database.transaction( function(tx) {
  103. result = tx.executeSql('UPDATE contacts SET profile_image="'+filename+'" where profile_image_url="'+url+'"');
  104. })
  105. }
  106. }
  107. }
  108. FontLoader{id: fontAwesome; source: "qrc:/images/fontawesome-webfont.ttf"}
  109. Keys.onReleased: {
  110. if (event.key === osSettings.backKey) {
  111. if (currentIndex==0){
  112. newstab.active=true;
  113. if (newstab.newstabstatus!=login.newsViewType){
  114. newstab.newstabstatus=login.newsViewType;
  115. if(login.newsViewType=="Timeline"){Newsjs.newsfromdb(db,login.username,function(dbnews){
  116. newsSignal(dbnews)
  117. })}
  118. else{
  119. Newsjs.chatsfromdb(db,login.username,function(dbnews){
  120. newsSignal(dbnews)
  121. })}
  122. }
  123. else if (newstab.conversation.length>0){newstab.conversation=[]}
  124. else{Service.cleanNews(root.db,function(){
  125. Service.cleanContacts(root.login,root.db,function(){
  126. Qt.quit()})
  127. })}
  128. }
  129. else if (currentIndex==2){fotoSignal("backButton")}
  130. else {currentIndex=0}
  131. event.accepted = true
  132. }}
  133. style: TabViewStyle {
  134. frameOverlap: 1
  135. tab: Rectangle {
  136. color: styleData.selected?"sky blue":"light blue"
  137. //border.color: "light grey"
  138. implicitWidth: root.width/5
  139. implicitHeight: 5*mm
  140. Text { id: text
  141. anchors.centerIn: parent
  142. text: styleData.title
  143. color: "black"
  144. font.family: fontAwesome.name
  145. font.pixelSize: 3*mm
  146. }
  147. }
  148. frame: Rectangle { color: "light grey" }
  149. tabsAlignment:Qt.AlignHCenter
  150. }
  151. Tab{
  152. title: "\uf03a"
  153. id: newstab
  154. property string newstabstatus
  155. property var conversation:[]
  156. property var contactposts:[]
  157. source:(root.currentIndex==0)? "qrc:/qml/newsqml/NewsTab.qml":""
  158. }
  159. Tab{
  160. title: "\uf0c0"
  161. id: friendstab
  162. source: (root.currentIndex==1)?"qrc:/qml/contactqml/FriendsTab.qml":""
  163. }
  164. Tab{
  165. title: "\uf03e"
  166. id: fotostab
  167. property string phototabstatus:"Images"
  168. source: (root.currentIndex==2)?"qrc:/qml/photoqml/PhotoTab.qml":""
  169. }
  170. Tab{
  171. title: "\uf073"
  172. id: calendartab
  173. property string calendartabstatus:"Events"
  174. source: (root.currentIndex==3)?"qrc:/qml/calendarqml/CalendarTab.qml":""
  175. }
  176. Tab{
  177. title:"\uf085"
  178. id: configtab
  179. source: (root.currentIndex==4)?"qrc:/qml/configqml/ConfigTab.qml":""
  180. }
  181. Component.onCompleted: {
  182. Service.readGlobaloptions(db,function(go){globaloptions=go})
  183. //print(xhr.networktype);
  184. if(osSettings.osType=="Android"){
  185. var component = Qt.createComponent("qrc:/qml/genericqml/IntentReceiver.qml");
  186. var IntentReceiverQml = component.createObject(root);
  187. }
  188. }
  189. }