Dynamic news tabs

This commit is contained in:
LubuWest 2023-11-04 18:04:55 +01:00
parent 2debd8f2ab
commit 3c1c97d489
43 changed files with 526 additions and 327 deletions

View file

@ -1 +0,0 @@
../source-linux/application.qrc

View file

@ -1 +0,0 @@
../../source-linux/common/alarm.h

View file

@ -1 +0,0 @@
../../source-linux/common/alarmandroid.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/alarmlinux.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/filesystem.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/filesystem.h

View file

@ -1 +0,0 @@
../../source-linux/common/filesystemandroid.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/oauth.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/oauth.h

View file

@ -1 +0,0 @@
../../source-linux/common/remoteauthasyncimageprovider.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/remoteauthasyncimageprovider.h

View file

@ -1 +0,0 @@
../../source-linux/common/updatenews.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/updatenews.h

View file

@ -1 +0,0 @@
../../source-linux/common/uploadableimage.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/uploadableimage.h

View file

@ -1 +0,0 @@
../../source-linux/common/xhr.cpp

View file

@ -1 +0,0 @@
../../source-linux/common/xhr.h

View file

@ -1 +0,0 @@
../source-linux/images

View file

@ -1 +0,0 @@
../source-linux/js

View file

@ -1 +0,0 @@
../../source-linux/qml/calendarqml

View file

@ -1 +0,0 @@
../../source-linux/qml/configqml

View file

@ -1 +0,0 @@
../../source-linux/qml/contactqml

View file

@ -1 +0,0 @@
../../source-linux/qml/genericqml

View file

@ -1 +0,0 @@
../../source-linux/qml/newsqml

View file

@ -1 +0,0 @@
../../source-linux/qml/photoqml

View file

@ -1 +0,0 @@
../source-linux/qtquickcontrols2.conf

View file

@ -1 +0,0 @@
../source-linux/translations

View file

@ -256,5 +256,7 @@
<file>qml/configqml/AcceptRules.qml</file> <file>qml/configqml/AcceptRules.qml</file>
<file>translations/friendiqa-nl.qm</file> <file>translations/friendiqa-nl.qm</file>
<file>translations/friendiqa-nl.ts</file> <file>translations/friendiqa-nl.ts</file>
<file>qml/genericqml/SearchDialog.qml</file>
<file>qml/newsqml/NewsTabbutton.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -233,10 +233,11 @@ void XHR::download()
void XHR::get() void XHR::get()
{ {
QUrlQuery query; QUrlQuery query;
qDebug() << "get";
QHashIterator<QString, QString> i(params); QHashIterator<QString, QString> i(params);
while(i.hasNext()) { while(i.hasNext()) {
i.next(); i.next();
qDebug() << "value" << i.value();
query.addQueryItem(i.key(), i.value()); query.addQueryItem(i.key(), i.value());
} }
QUrl requrl(m_url+m_api); QUrl requrl(m_url+m_api);
@ -354,6 +355,11 @@ void XHR::onReplyError(QNetworkReply::NetworkError code)
void XHR::onReplySuccess() void XHR::onReplySuccess()
{ {
qDebug() << "!"; qDebug() << "!";
QHashIterator<QString, QString> i(params);
while(i.hasNext()) {
i.next();
qDebug() << i.key()<< " " << i.value();
}
emit this->success(buffer, m_api); emit this->success(buffer, m_api);
buffer.clear(); buffer.clear();
// reply->deleteLater(); // reply->deleteLater();

View file

@ -34,6 +34,10 @@
.import "qrc:/js/helper.js" as Helperjs .import "qrc:/js/helper.js" as Helperjs
.import "qrc:/js/news.js" as Newsjs .import "qrc:/js/news.js" as Newsjs
const newsViewType = 'Conversations'
const defaultNewsTypes = encodeURI(JSON.stringify(["Home","Replies","DirectMessages","Notifications"])) //'[\"Home\",\"Replies\",\"DirectMessages\",\"Notifications\"]'
// CONFIG FUNCTIONS // CONFIG FUNCTIONS
function initDatabase(database) { // initialize the database object function initDatabase(database) { // initialize the database object
@ -171,7 +175,8 @@ function readActiveConfig(database){
function setDefaultOptions(database){ function setDefaultOptions(database){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) { db.transaction( function(tx) {
var rs = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES ("newsViewType","Conversations")'); let rs = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES ("newsViewType","'+ newsViewType+'")');
let rs2 = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES ("defaultNewsTypes","'+ defaultNewsTypes+'")');
}) })
} }
@ -180,8 +185,18 @@ function readGlobaloptions(database,callback){
var go=({}); var go=({});
db.transaction( function(tx) { db.transaction( function(tx) {
var rs = tx.executeSql('select * from globaloptions'); var rs = tx.executeSql('select * from globaloptions');
for (var r=0; r<rs.rows.length; r++){ for (var r=0; r<rs.rows.length; r++){//print("rs.rows.item(r).k "+rs.rows.item(r).k +" rs.rows.item(r).v "+rs.rows.item(r).v)
go[rs.rows.item(r).k]=rs.rows.item(r).v if(rs.rows.item(r).k=="defaultNewsTypes"){
go[rs.rows.item(r).k]=JSON.parse(decodeURI(rs.rows.item(r).v))
} else{
go[rs.rows.item(r).k]=rs.rows.item(r).v
}
}
if (!go.hasOwnProperty('defaultNewsTypes')){
go.defaultNewsTypes=JSON.parse(decodeURI(defaultNewsTypes))
}
else if (!go.hasOwnProperty('newsViewType')){
go.newsViewType=newsViewType
} }
callback(go) callback(go)
}) })
@ -195,12 +210,14 @@ function readGO(database){
function updateglobaloptions(database,key,value){ function updateglobaloptions(database,key,value){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
if(key=='defaultNewsTypes'){var dbValue=encodeURI(JSON.stringify(value))} else {var dbValue=value}
db.transaction( function(tx) { db.transaction( function(tx) {
var result = tx.executeSql('SELECT * from globaloptions where k="'+key+'"'); // check for key var result = tx.executeSql('SELECT * from globaloptions where k="'+key+'"'); // check for key
if(result.rows.length > 0) {// use update if(result.rows.length > 0) {// use update
result = tx.executeSql('UPDATE globaloptions SET v="'+value+'" WHERE k="'+key+'"') result = tx.executeSql('UPDATE globaloptions SET v="'+dbValue+'" WHERE k="'+key+'"')
} else {// use insert } else {// use insert
result = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES (?,?)', [key,value]) result = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES (?,?)', [key,dbValue])
} }
}) })
root.globaloptions[key]=value; root.globaloptions[key]=value;
@ -221,14 +238,14 @@ function deleteConfig(database,userobj,callback) { // delete user data from DB
}) })
} }
function updateNewsviewtype(database, newsViewtype){ //function updateNewsviewtype(database, newsViewtype){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); // var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
if(!db) { return; } // if(!db) { return; }
db.transaction( function(tx) { // db.transaction( function(tx) {
var rs1 = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES (?,?)', ["newsViewType",newsViewtype]) // var rs1 = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES (?,?)', ["newsViewType",newsViewtype])
var rs2 = tx.executeSql('UPDATE config SET newsViewType=""'); // var rs2 = tx.executeSql('UPDATE config SET newsViewType=""');
}) // })
} //}
function cleanNews(database,callback){ function cleanNews(database,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]); var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);

View file

@ -62,19 +62,18 @@ Page{
Helperjs.friendicaRequest(userconfig,"/api/v1/accounts/verify_credentials",root,function(obj){ Helperjs.friendicaRequest(userconfig,"/api/v1/accounts/verify_credentials",root,function(obj){
accountBusy.running=false; accountBusy.running=false;
try{var credentials=JSON.parse(obj); try{var credentials=JSON.parse(obj);
if (credentials.hasOwnProperty('error')){ if (credentials.hasOwnProperty('error')){print("error "+credentials.error);
Helperjs.showMessage(qsTr("Error"),qsTr("Wrong password or 2FA enabled!"),root) Helperjs.showMessage(qsTr("Error"),qsTr("Wrong password or 2FA enabled!"),root)
} }
else{ else{
if (users.length==0){Service.setDefaultOptions(db);} if (users.length==0){Service.setDefaultOptions(db);}
if (userconfig.APIVersion!=""){userconfig.password=""} if (userconfig.hasOwnProperty("APIVersion")){userconfig.password=""}
if (imagestoredir==""){ if (imagestoredir==""){
imagestoredir=filesystem.homePath+"/"+credentials.username+"/"; imagestoredir=filesystem.homePath+"/"+credentials.username+"/";
userconfig.imagestore=imagestoredir userconfig.imagestore=imagestoredir
} }
if(userconfig.imagestore == filesystem.homePath+"/"+credentials.username+"/") if(userconfig.imagestore == filesystem.homePath+"/"+credentials.username+"/")
{filesystem.makePath(filesystem.homePath+"/"+credentials.username);} {filesystem.makePath(filesystem.homePath+"/"+credentials.username);}
print("imagestoredir "+imagestoredir)
filesystem.Directory=imagestoredir; filesystem.Directory=imagestoredir;
filesystem.makeDir("contacts"); filesystem.makeDir("contacts");
filesystem.makeDir("albums"); filesystem.makeDir("albums");
@ -97,7 +96,7 @@ Page{
Helperjs.showMessage(qsTr("Success"),qsTr("Name")+": "+credentials.display_name+"\nScreen Name: "+credentials.username,root) Helperjs.showMessage(qsTr("Success"),qsTr("Name")+": "+credentials.display_name+"\nScreen Name: "+credentials.username,root)
rootstackView.pop() rootstackView.pop()
} }
}catch(e){Helperjs.showMessage(qsTr("Error"),qsTr("Wrong password or 2FA enabled!"),root)}; }catch(e){Helperjs.showMessage(qsTr("Error"),qsTr("Wrong password or 2FA enabled!"+e),root)};
}) })
} }
@ -212,6 +211,28 @@ Page{
rootstackView.push("qrc:/qml/configqml/InfoBox.qml"); rootstackView.push("qrc:/qml/configqml/InfoBox.qml");
} }
} }
MButton {
text: "\uf150"
font.family: fontAwesome.name
font.pointSize: osSettings.bigFontSize
Menu {
id:authMethodMenu
width: 10*root.fontFactor*osSettings.systemFontSize
MenuItem {
text: qsTr("OAuth")
font.pointSize: osSettings.systemFontSize
font.bold:accountPage.state=="oauth"
onTriggered: {accountPage.state="oauth"}
}
MenuItem {
text: qsTr("Password")
font.pointSize: osSettings.systemFontSize
font.bold:accountPage.state=="password"
onTriggered: {accountPage.state="password"}
}
}
onClicked: {authMethodMenu.popup()}
}
MButton{ MButton{
id:closeButton id:closeButton
visible: users.length>0 visible: users.length>0
@ -248,7 +269,7 @@ Page{
MButton{ MButton{
id:serverSearchButton id:serverSearchButton
width: 3*root.fontFactor*osSettings.bigFontSize; height: 2.5*root.fontFactor*osSettings.bigFontSize width: 3*root.fontFactor*osSettings.bigFontSize; height: 2.5*root.fontFactor*osSettings.bigFontSize
text:"\uf002" //text:"\uf002"
icon.name: "search" icon.name: "search"
font.pointSize: osSettings.bigFontSize font.pointSize: osSettings.bigFontSize
visible: servericon.visible?false:true visible: servericon.visible?false:true
@ -353,7 +374,7 @@ Page{
TextField { TextField {
id: username id: username
width: root.width-5*root.fontFactor*osSettings.bigFontSize width: root.width-5*root.fontFactor*osSettings.bigFontSize
height: servername.height height: 2.5*root.fontFactor*osSettings.bigFontSize;
Layout.leftMargin: 3*root.fontFactor*osSettings.bigFontSize; Layout.leftMargin: 3*root.fontFactor*osSettings.bigFontSize;
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
visible: (osSettings.osType=="Android")?(text!= ""):true visible: (osSettings.osType=="Android")?(text!= ""):true
@ -370,6 +391,7 @@ Page{
TextField { TextField {
id: password id: password
width: root.width-9*mm; height: 2.5*root.fontFactor*osSettings.bigFontSize; width: root.width-9*mm; height: 2.5*root.fontFactor*osSettings.bigFontSize;
Layout.leftMargin: 3*root.fontFactor*osSettings.bigFontSize;
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
visible: (osSettings.osType=="Android")?(userButton.text!= qsTr("User")):true visible: (osSettings.osType=="Android")?(userButton.text!= qsTr("User")):true
selectByMouse: true selectByMouse: true
@ -469,7 +491,7 @@ Page{
catch(e){print(e)} catch(e){print(e)}
} }
else if (api=="/api/v1/apps"){print("/api/v1/apps text "+text) else if (api=="/api/v1/apps"){
let app=JSON.parse(text); let app=JSON.parse(text);
accountPage.appdata=app; accountPage.appdata=app;
oauth2.setClientId(app.client_id); oauth2.setClientId(app.client_id);
@ -546,7 +568,7 @@ Page{
}, },
State { State {
name:"oauth" name:"oauth"
PropertyChanges {target: username; visible: true} PropertyChanges {target: username; visible: false}
PropertyChanges {target: password; visible: false} PropertyChanges {target: password; visible: false}
PropertyChanges {target: confirmationOAuth; visible: true} PropertyChanges {target: confirmationOAuth; visible: true}
PropertyChanges {target: setDefault; visible: true} PropertyChanges {target: setDefault; visible: true}

View file

@ -33,6 +33,7 @@ import QtQuick 2.11
//import QtQuick.Dialogs 1.2 //import QtQuick.Dialogs 1.2
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import "qrc:/js/service.js" as Service import "qrc:/js/service.js" as Service
import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/configqml" import "qrc:/qml/configqml"
import "qrc:/qml/genericqml" import "qrc:/qml/genericqml"
@ -155,10 +156,37 @@ Page{
// } // }
// } // }
// } // }
Column{ Column{
visible: osSettings.osType=="Android"
x: root.fontFactor*osSettings.bigFontSize x: root.fontFactor*osSettings.bigFontSize
y: 18*root.fontFactor*osSettings.bigFontSize y: 18*root.fontFactor*osSettings.bigFontSize
Label{
text: qsTr("Default News Tabs")
font.pointSize: osSettings.systemFontSize
}
Repeater{id:newstypeRepeater
model: 4
delegate:ComboBox{
required property int index
model: ["Home", "Replies", "DirectMessages","Favorites","Public Timeline","Notifications"]
currentIndex: model.indexOf(globaloptions.defaultNewsTypes[index])
onCurrentTextChanged: {
if (currentText !== globaloptions.defaultNewsTypes[index]){
globaloptions.defaultNewsTypes.splice(index,1,currentText);
Service.updateglobaloptions(root.db,"defaultNewsTypes",globaloptions.defaultNewsTypes)
root.globaloptionsChanged()
}
}
}
}
}
Column{
//visible: osSettings.osType=="Android"
x: root.fontFactor*osSettings.bigFontSize
y: 26*root.fontFactor*osSettings.bigFontSize
Label{ Label{
text: qsTr("Dark Mode") text: qsTr("Dark Mode")
font.pointSize: osSettings.systemFontSize} font.pointSize: osSettings.systemFontSize}
@ -198,38 +226,7 @@ Page{
} }
} }
Column{
x: root.fontFactor*osSettings.bigFontSize
y: 28*root.fontFactor*osSettings.bigFontSize
Label{
text: qsTr("Toolbar Postion")
font.pointSize: osSettings.systemFontSize}
RadioButton{
text: qsTr("Top")
checked: (globaloptions["toolbarposition"]==0 || globaloptions["toolbarposition"]==undefined)?true:false
font.pointSize: osSettings.bigFontSize
onClicked: {
if(checked==true){
Service.updateglobaloptions(root.db,"roottoolbarposition",0);
globaloptions.toolbarposition=0;
root.roottoolbar.position=ToolBar.Header
}
}
}
RadioButton{
text: qsTr("Bottom")
checked: (globaloptions["toolbarposition"]==1)?true:false
font.pointSize: osSettings.bigFontSize
onClicked: {
if(checked==true){
Service.updateglobaloptions(root.db,"roottoolbarposition",1);
globaloptions.toolbarposition=1;
root.roottoolbar.position=ToolBar.Footer
}
}
}
}
MButton { MButton {

View file

@ -91,25 +91,33 @@ ScrollView{
} }
} }
} }
ListModel{id:accountModel}
Component{id:accountLoader
Loader{
source: bar.currentIndex==0?"qrc:/qml/genericqml/DrawerAccountComponent.qml":"qrc:/qml/genericqml/DrawerAccountComponentContacts.qml"
}
}
ListView{
id:accountList
y: 6.5*root.fontFactor*osSettings.bigFontSize
width:parent.width
height: contentHeight
model: accountModel
delegate: accountLoader
}
} }
Component.onCompleted:{ Component.onCompleted:{
Service.readAllLogins(db,function(accounts){ Service.readAllLogins(db,function(accounts){
if (accounts.length>0 && bar.currentIndex==0){ if (accounts.length>0 && bar.currentIndex==0){
leftDrawerColumn.height=4.5*root.fontFactor*osSettings.bigFontSize+accounts.length*17*root.fontFactor*osSettings.bigFontSize leftDrawerColumn.height=6.5*root.fontFactor*osSettings.bigFontSize+accounts.length*17*root.fontFactor*osSettings.bigFontSize
for(var i = 0; i < accounts.length; i++) { for(var account in accounts) {
var accountComponent = Qt.createComponent("qrc:/qml/genericqml/DrawerAccountComponent.qml"); accountModel.append({"account":accounts[account]})
var accountQml = accountComponent.createObject(leftDrawerColumn,{
"y":4.5*root.fontFactor*osSettings.bigFontSize+i*17*root.fontFactor*osSettings.bigFontSize,
"currentnewstabstatus":currentnewstabstatus,
"account":accounts[i]});
} }
}else if(accounts.length>0 && bar.currentIndex==1){ }else if(accounts.length>0 && bar.currentIndex==1){
leftDrawerColumn.height=4.5*root.fontFactor*osSettings.bigFontSize+accounts.length*8*root.fontFactor*osSettings.bigFontSize leftDrawerColumn.height=6.5*root.fontFactor*osSettings.bigFontSize+accounts.length*8*root.fontFactor*osSettings.bigFontSize
for(var i = 0; i < accounts.length; i++) { for(var account in accounts) {
var accountComponent = Qt.createComponent("qrc:/qml/genericqml/DrawerAccountComponentContacts.qml"); accountModel.append({"account":accounts[account]})
var accountQml = accountComponent.createObject(leftDrawerColumn,{
"y":4.5*root.fontFactor*osSettings.bigFontSize+i*8*root.fontFactor*osSettings.bigFontSize,
"account":accounts[i]});
} }
} }
})} })}

View file

@ -113,10 +113,6 @@ ApplicationWindow{
Service.updateglobaloptions(db,"appWidth",appWidth) Service.updateglobaloptions(db,"appWidth",appWidth)
} }
} }
}
Connections {
target: root
function onHeightChanged(appHeight) { function onHeightChanged(appHeight) {
if(osSettings.osType=="Linux" && Math.abs(appHeight-(globaloptions.appHeight||0))>50){ if(osSettings.osType=="Linux" && Math.abs(appHeight-(globaloptions.appHeight||0))>50){
Service.updateglobaloptions(db,"appHeight",appHeight) Service.updateglobaloptions(db,"appHeight",appHeight)
@ -190,7 +186,6 @@ ApplicationWindow{
footer: ToolBar{ footer: ToolBar{
id: roottoolbar id: roottoolbar
//position: ToolBar.Footer//globaloptions.roottoolbarposition==0 || globaloptions.roottoolbarposition==undefined?ToolBar.Header:ToolBar.Footer
width:root.width width:root.width
background: Rectangle{ background: Rectangle{
anchors.fill: parent anchors.fill: parent
@ -307,7 +302,6 @@ ApplicationWindow{
} }
} }
Component.onCompleted: { Component.onCompleted: {
onLoginChanged(login); onLoginChanged(login);
globaloptions=Service.readGO(db); globaloptions=Service.readGO(db);
@ -326,7 +320,6 @@ ApplicationWindow{
var IntentReceiverQml = component.createObject(root); var IntentReceiverQml = component.createObject(root);
} }
else if (osSettings.osType=="Linux"){ else if (osSettings.osType=="Linux"){
//if (login!=""){newstypeSignal("refresh")}
var component = Qt.createComponent("qrc:/qml/genericqml/LinuxSync.qml"); var component = Qt.createComponent("qrc:/qml/genericqml/LinuxSync.qml");
var LinuxSyncQml = component.createObject(root); var LinuxSyncQml = component.createObject(root);
} }

View file

@ -34,7 +34,7 @@ Rectangle{
id: blueButton id: blueButton
width: Math.max(mainText.width+2*mm,5*mm) width: Math.max(mainText.width+2*mm,5*mm)
height: 5*mm height: 5*mm
border.color: "light blue" //border.color: "light blue"
color:"transparent"//"#EFEAEA" "sky blue" color:"transparent"//"#EFEAEA" "sky blue"
property alias fontColor: mainText.color property alias fontColor: mainText.color
border.width:1 border.width:1

View file

@ -32,11 +32,28 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 6.3 import QtQuick.Controls 6.3
import "qrc:/qml/genericqml" import "qrc:/qml/genericqml"
import "qrc:/qml/newsqml"
Item { Item {
id: drawerAccountComponent id: drawerAccountComponent
property var account: ({}) width: accountList.width
width: parent.width height: 17*root.fontFactor*osSettings.bigFontSize
function changeNews(typeRequest){
newsSwipeview.stacktype=typeRequest;
if (newstabitem.newstypes.indexOf(typeRequest)<0){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsStack.qml");
var newscomp = component.createObject(newsSwipeview,{"expectScreenUpdate":true});
newsSwipeview.addItem(newscomp);
newstabitem.newstypes.push(typeRequest);
newsSwipeview.currentIndex=newsSwipeview.count;
addToolbutton(typeRequest)
newstabbar.currentIndex=newsSwipeview.count
}else{
newsSwipeview.currentIndex=newstabitem.newstypes.indexOf(typeRequest);
newstabbar.currentIndex=newstabitem.newstypes.indexOf(typeRequest);
}
}
Label{ Label{
y:0.5*root.fontFactor*osSettings.bigFontSize y:0.5*root.fontFactor*osSettings.bigFontSize
@ -58,11 +75,10 @@ Item {
onClicked: { onClicked: {
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
// newstypeSignal("refresh") newstypeSignal("")
newsBusy.running=true; // updatenews.setDatabase();
updatenews.setDatabase(); // updatenews.login();
updatenews.login(); // updatenews.startsync();
updatenews.startsync();
} }
} }
} }
@ -72,14 +88,14 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Timeline" font.bold: account.username==login.username && newsSwipeview.stacktype=="Home" && newstab.newstabstatus=="Timeline"
text: "\uf1da " + qsTr("Timeline") text: "\uf1da " + qsTr("Timeline")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; changeNews("Home");
currentnewstabstatus="Timeline"; currentnewstabstatus="Timeline";
newstypeSignal("timeline") newstypeSignal("timeline")
} }
@ -91,36 +107,34 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Conversations" font.bold: account.username==login.username && newsSwipeview.stacktype=="Home" && newstab.newstabstatus=="Conversations"
text: "\uf086 " + qsTr("Conversations") text: "\uf086 " + qsTr("Conversations")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; changeNews("Home");
currentnewstabstatus="Conversations"; currentnewstabstatus="Conversations";
newstypeSignal("conversation") newstypeSignal("conversation")
} }
} }
} }
Label{ Label{
y:6.5*root.fontFactor*osSettings.bigFontSize y:6.5*root.fontFactor*osSettings.bigFontSize
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Replies" font.bold: account.username==login.username && newsSwipeview.stacktype=="Replies"
text: "\uf0ec " + qsTr("Replies") text: "\uf0ec " + qsTr("Replies")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=1 changeNews("Replies");
currentnewstabstatus="Replies"; //urrentnewstabstatus="Replies";
newstypeSignal("replies") newstypeSignal("replies")
} }
} }
@ -131,32 +145,33 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="DirectMessages" font.bold: account.username==login.username && newsSwipeview.stacktype=="DirectMessages"
text: "\uf0e0 " + qsTr("Direct Messages") text: "\uf0e0 " + qsTr("Direct Messages")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=2//newstypeSignal("replies") changeNews("DirectMessages")
currentnewstabstatus="DirectMessages"; //currentnewstabstatus="DirectMessages";
} }
} }
} }
Label{ Label{
y:9.5*root.fontFactor*osSettings.bigFontSize y:9.5*root.fontFactor*osSettings.bigFontSize
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Favorites" font.bold: account.username==login.username && newsSwipeview.stacktype=="Favorites"
text: "\uf005 " + qsTr("Favorites") text: "\uf005 " + qsTr("Favorites")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; changeNews("Favorites")
currentnewstabstatus="Favorites"; //currentnewstabstatus="Favorites";
newstypeSignal("favorites") newstypeSignal("favorites")
} }
} }
@ -167,14 +182,14 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Public Timeline" font.bold: account.username==login.username && newsSwipeview.stacktype=="Public Timeline"
text: "\uf0ac " + qsTr("Public Timeline") text: "\uf0ac " + qsTr("Public Timeline")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; changeNews("Public Timeline")
currentnewstabstatus="Public Timeline"; currentnewstabstatus="Public Timeline";
newstypeSignal("publictimeline") newstypeSignal("publictimeline")
} }
@ -186,15 +201,14 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Groupnews" font.bold: account.username==login.username && newsSwipeview.stacktype=="Groupnews"
text: "\uf0c0 " + qsTr("Group news") text: "\uf0c0 " + qsTr("Group news")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; changeNews("Group News")
currentnewstabstatus="Groupnews";
newstypeSignal("groupnews") newstypeSignal("groupnews")
} }
} }
@ -205,16 +219,19 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Search" font.bold: account.username==login.username && newsSwipeview.stacktype=="Search"
text: "\uf002 " + qsTr("Search") text: "\uf002 " + qsTr("Search")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=0; // newsSwipeview.currentIndex=0;
currentnewstabstatus="Search"; // currentnewstabstatus="Search";
newstypeSignal("search") // newstypeSignal("search")
var component = Qt.createComponent("qrc:/qml/genericqml/SearchDialog.qml");
var searchItem = component.createObject(newstab,{"selfdestroying":true});
searchItem.open()
} }
} }
} }
@ -224,15 +241,14 @@ Item {
width:parent.width width:parent.width
font.family: fontAwesome.name font.family: fontAwesome.name
font.pointSize: osSettings.systemFontSize font.pointSize: osSettings.systemFontSize
font.bold: account.username==login.username && currentnewstabstatus=="Notifications" font.bold: account.username==login.username && newsSwipeview.stacktype=="Notifications"
text: "\uf0f3 " + qsTr("Notifications") text: "\uf0f3 " + qsTr("Notifications")
MouseArea{ MouseArea{
anchors.fill:parent anchors.fill:parent
onClicked:{ onClicked:{
login=account; login=account;
if(!wideScreen){leftDrawerAndroid.close()} if(!wideScreen){leftDrawerAndroid.close()}
newsSwipeview.currentIndex=3; changeNews("Notifications")
currentnewstabstatus="Notifications";
newstypeSignal("notifications") newstypeSignal("notifications")
} }
} }

View file

@ -35,11 +35,10 @@ import "qrc:/qml/genericqml"
Item { Item {
id: drawerAccountComponent id: drawerAccountComponent
property var account: ({}) width: accountList.width
width: parent.width height: 8*root.fontFactor*osSettings.bigFontSize
Label{ Label{
y:0.5*osSettings.bigFontSize y:0.5*osSettings.bigFontSize
width:parent.width width:parent.width
height: 1.5*root.fontFactor*osSettings.bigFontSize height: 1.5*root.fontFactor*osSettings.bigFontSize

View file

@ -0,0 +1,78 @@
// This file is part of Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2020 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/>.
import QtQuick 2.7
import QtQuick.Controls 2.12
import "qrc:/qml/genericqml"
Dialog {
id: searchDialog
// width: 0.5*parent.width
// height: 0.5*parent.height
anchors.centerIn: parent
title: qsTr("Search")
standardButtons: Dialog.Ok | Dialog.Abort
modal: true
onAccepted: {
}
onRejected: {close()}
property bool selfdestroying:true
/* anchors.left: parent.left
anchors.leftMargin:mm
anchors.top:parent.top
anchors.topMargin: 0.5*mm
width:parent.width-2*mm
height: 4*mm *///Math.max( searchText.contentHeight,5*mm)
TextInput {
id: searchText
color: osSettings.primaryTextColor
focus: true
font.pointSize: osSettings.bigFontSize
wrapMode: Text.Wrap
anchors.fill: parent
selectByMouse: true
cursorVisible: false
onAccepted:{
if (displayText!=""){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsStack.qml");
var newscomp = component.createObject(newsSwipeview,{"expectScreenUpdate":true});
newsSwipeview.addItem(newscomp);
newsSwipeview.currentIndex=newsSwipeview.count;
currentnewstabstatus="Public Timeline";
newscomp.search(displayText)
};
if(selfdestroying){close()}
}
}
Component.onCompleted: searchText.forceActiveFocus()
}

View file

@ -32,7 +32,7 @@
// ConversationView with button // ConversationView with button
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import "qrc:/js/helper.js" as Helperjs //import "qrc:/js/helper.js" as Helperjs
import "qrc:/qml/genericqml" import "qrc:/qml/genericqml"
import "qrc:/qml/newsqml" import "qrc:/qml/newsqml"
@ -88,6 +88,17 @@ Page {
return {likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText} return {likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText}
} }
function openMessageSend(messageState,newsitemobject){
var parentId=""
var replyUser=""
if(newsitemobject!=""){
parentId=newsitemobject.id
replyUser=newsitemobject.user.screen_name;
}
var messageObject = Qt.createComponent("qrc:/qml/newsqml/MessageSend.qml");
var messageWindow=messageObject.createObject(root, { parentId: parentId, reply_to_user: replyUser, windowstate: messageState });
messageWindow.show();
}
ListView { ListView {
id: conversationView id: conversationView
@ -140,7 +151,6 @@ Page {
width: 2*root.fontFactor*osSettings.bigFontSize; width: 2*root.fontFactor*osSettings.bigFontSize;
text: "\uf057" text: "\uf057"
onClicked: { onClicked: {
//newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
newstab.conversation=[]; newstab.conversation=[];
if (rootstackView.depth>1){ rootstackView.pop()} if (rootstackView.depth>1){ rootstackView.pop()}
} }

View file

@ -46,7 +46,7 @@ import "qrc:/qml/newsqml"
Window{ Window{
color: osSettings.backgroundColor color: osSettings.backgroundColor
width: parent.width width: parent.width
height: parent.height//messageColumn.height+2*mm height: 2/3*parent.height//messageColumn.height+2*mm
id: messageSend id: messageSend
property bool wideScreen : width>height property bool wideScreen : width>height
// visible: conversation || (newstab.newstabstatus!="Search")?true:false // visible: conversation || (newstab.newstabstatus!="Search")?true:false
@ -391,6 +391,7 @@ Window{
MButton { MButton {
id: boldButton id: boldButton
text: "\uf032" // icon-bold text: "\uf032" // icon-bold
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Bold") ToolTip.text: qsTr("Bold")
focusPolicy: Qt.NoFocus focusPolicy: Qt.NoFocus
@ -406,6 +407,7 @@ Window{
MButton { MButton {
id: italicButton id: italicButton
text: "\uf033" // icon-italic text: "\uf033" // icon-italic
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Italic") ToolTip.text: qsTr("Italic")
focusPolicy: Qt.NoFocus focusPolicy: Qt.NoFocus
@ -418,6 +420,7 @@ Window{
MButton { MButton {
id: liststyleButton id: liststyleButton
text: "\uf03a" // icon-align-justify text: "\uf03a" // icon-align-justify
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Create list") ToolTip.text: qsTr("Create list")
// focusPolicy: Qt.NoFocus // focusPolicy: Qt.NoFocus
@ -428,6 +431,7 @@ Window{
MButton { MButton {
id: codeblockButton id: codeblockButton
text: "\uf121" // icon-code text: "\uf121" // icon-code
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Format as code") ToolTip.text: qsTr("Format as code")
// focusPolicy: Qt.NoFocus // focusPolicy: Qt.NoFocus
@ -438,6 +442,7 @@ Window{
MButton { MButton {
id: plainButton id: plainButton
text: bodyField.textFormat==TextEdit.PlainText?qsTr("Rendered"):qsTr("MD") // icon-code text: bodyField.textFormat==TextEdit.PlainText?qsTr("Rendered"):qsTr("MD") // icon-code
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Show Markdown code") ToolTip.text: qsTr("Show Markdown code")
// focusPolicy: Qt.NoFocus // focusPolicy: Qt.NoFocus
@ -472,6 +477,7 @@ Window{
MButton{ MButton{
id:smileyButton id:smileyButton
text: "\uf118" text: "\uf118"
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Insert smiley") ToolTip.text: qsTr("Insert smiley")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize
@ -482,6 +488,7 @@ Window{
MButton{ MButton{
id:hastagButton id:hastagButton
text: "\uf292" text: "\uf292"
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Insert previous hashtag") ToolTip.text: qsTr("Insert previous hashtag")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize
@ -492,6 +499,7 @@ Window{
id:imagesButton id:imagesButton
visible:(newsSwipeview.stacktype!="DirectMessages") visible:(newsSwipeview.stacktype!="DirectMessages")
text: "\uf03e" text: "\uf03e"
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Insert images") ToolTip.text: qsTr("Insert images")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize
@ -506,6 +514,7 @@ Window{
MButton { MButton {
id: cancelButton id: cancelButton
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Cancel message") ToolTip.text: qsTr("Cancel message")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize
@ -515,6 +524,7 @@ Window{
} }
MButton { MButton {
id: formatButton id: formatButton
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Format message") ToolTip.text: qsTr("Format message")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize
@ -524,6 +534,7 @@ Window{
} }
MButton { MButton {
id: sendButton id: sendButton
ToolTip.delay: 500
ToolTip.visible: pressed || hovered ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Send message") ToolTip.text: qsTr("Send message")
height: 3*root.fontFactor*osSettings.bigFontSize height: 3*root.fontFactor*osSettings.bigFontSize

View file

@ -34,11 +34,12 @@ import QtQuick.Controls 2.12
import "qrc:/js/news.js" as Newsjs import "qrc:/js/news.js" as Newsjs
import "qrc:/js/helper.js" as Helperjs import "qrc:/js/helper.js" as Helperjs
import "qrc:/js/service.js" as Service import "qrc:/js/service.js" as Service
import "qrc:/qml/genericqml"
Rectangle{ Rectangle{
id: newsStack id: newsStack
width: parent.width // width: parent.width
height: parent.height // height: parent.height
color: osSettings.backgroundColor color: osSettings.backgroundColor
property string updateMethodNews: "refresh" property string updateMethodNews: "refresh"
property var allchats: ({}) property var allchats: ({})
@ -46,92 +47,109 @@ Rectangle{
property string newstabstatus: "" property string newstabstatus: ""
property bool expectScreenUpdate: false property bool expectScreenUpdate: false
function newstypeHandling(newstype){ function newstypeHandling(newstype){print("newstype "+newstype)
try{newsBusy.running=true}catch(e){print(e)}; if (!newsBusy.running) {
root.replySignal(""); try{newsBusy.running=true}catch(e){print(e)};
switch(newstype){ //root.replySignal("");
case "timeline": switch(newstype){
newstab.newstabstatus="Timeline"; case "timeline":
try{ Newsjs.newsfromdb(root.db,root.login,0, function(dbnews,lastid){ newstab.newstabstatus="Timeline";
lastnewsid=lastid; try{ Newsjs.newsfromdb(root.db,root.login,0, function(dbnews,lastid){
showNews(dbnews) lastnewsid=lastid;
})}catch(e){//Helperjs.showMessage("Error",e,root) showNews(dbnews)
}; })}catch(e){//Helperjs.showMessage("Error",e,root)
break; };
case "conversation": break;
newsStack.updateMethodNews="conversation"; case "conversation":
newstab.newstabstatus="Conversations"; newsStack.updateMethodNews="conversation";
Newsjs.chatsfromdb(root.db,root.login,0,[],function(news,lastid){ newstab.newstabstatus="Conversations";
lastnewsid=lastid; Newsjs.chatsfromdb(root.db,root.login,0,[],function(news,lastid){
showNews(news)}); lastnewsid=lastid;
break; showNews(news)});
case "favorites": break;
newsStack.updateMethodNews="refresh"; case "favorites":
newstab.newstabstatus="Favorites"; newsStack.updateMethodNews="refresh";
Service.updateView("Favorites"); newstab.newstabstatus="Favorites";
expectScreenUpdate=true; Service.updateView("Favorites");
break; expectScreenUpdate=true;
case "replies": break;
newsStack.updateMethodNews="refresh"; case "replies":
newstab.newstabstatus="Replies"; newsStack.updateMethodNews="refresh";
Service.updateView("Replies"); newstab.newstabstatus="Replies";
expectScreenUpdate=true; Service.updateView("Replies");
break; expectScreenUpdate=true;
case "publictimeline": break;
newsStack.updateMethodNews="refresh"; case "publictimeline":
newstab.newstabstatus="Public Timeline"; newsStack.updateMethodNews="refresh";
Service.updateView("Public Timeline"); newstab.newstabstatus="Public Timeline";
expectScreenUpdate=true; Service.updateView("Public Timeline");
break; expectScreenUpdate=true;
case "groupnews": break;
newsStack.updateMethodNews="refresh"; case "groupnews":
newstab.newstabstatus="Groupnews"; newsStack.updateMethodNews="refresh";
Service.showGroups(); newstab.newstabstatus="Groupnews";
expectScreenUpdate=true; Service.showGroups();
break; expectScreenUpdate=true;
case "search": break;
newsView.anchors.topMargin=7*mm; case "search":
newstab.newstabstatus="Search"; newsView.anchors.topMargin=7*mm;
newsBusy.running=false; newstab.newstabstatus="Search";
var leftoffset=(osSettings.osType=="Android")?2*root.fontFactor*osSettings.bigFontSize:0 newsBusy.running=false;
var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml"); var leftoffset=(osSettings.osType=="Android")?2*root.fontFactor*osSettings.bigFontSize:0
var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-(leftoffset+mm),height: 1.5*root.fontFactor*osSettings.systemFontSize,selfdestroying:true}); var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
break; var searchItem = component.createObject(newsStack,{y:mm,x:leftoffset,width:root.width-(leftoffset+mm),height: 1.5*root.fontFactor*osSettings.systemFontSize,selfdestroying:true});
case "refresh": break;
if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){ case "refresh":
newsStack.updateMethodNews="append" if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
} else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){ newsStack.updateMethodNews="append"
newsStack.updateMethodNews="conversation"} } else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
else {newsStack.updateMethodNews="refresh"} newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
if (newsSwipeview.stacktype=="Home"){ //root.contactLoadType="news";
Service.updateView(newstab.newstabstatus) if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus,lastnewsid)
}
else if (newsSwipeview.stacktype=="Directmessage"){
Service.updateView("Direct Messages",lastnewsid)
}
else if (newsSwipeview.stacktype=="Notifications"){
Service.updateView("Notifications")
}
expectScreenUpdate=true;
break;
default:
if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append"
} else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
//root.contactLoadType="news";
if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus,lastnewsid)
}
else if (newsSwipeview.stacktype=="Directmessage"){
Service.updateView("Direct Messages",lastnewsid)
}
else if (newsSwipeview.stacktype=="Notifications"){
Service.updateView("Notifications",lastnewsid)
}
else if (newsSwipeview.stacktype=="Favorites"){
Service.updateView("Favorites",lastnewsid)
}
else if (newsSwipeview.stacktype=="Replies"){
Service.updateView("Replies",lastnewsid)
}
else if (newsSwipeview.stacktype=="Public Timeline"){
Service.updateView("Public Timeline",lastnewsid)
}
else if (newsSwipeview.stacktype=="Search"){
Service.updateView("Search",lastnewsid)
}
else{
Service.updateView(newstab.newstabstatus,lastnewsid)
}
expectScreenUpdate=true;
} }
else if (newsSwipeview.stacktype=="DirectMessage"){
Service.updateView("Direct Messages")
}
else if (newsSwipeview.stacktype=="Notifications"){
Service.updateView("Notifications")
}
expectScreenUpdate=true;
break;
default:
if (newstab.newstabstatus=="Timeline" || newstabstatus=="Timeline"){
newsStack.updateMethodNews="append"
} else if (newstab.newstabstatus=="Conversations" || newstabstatus=="Conversations"){
newsStack.updateMethodNews="conversation"}
else {newsStack.updateMethodNews="refresh"}
//root.contactLoadType="news";
if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus)
}
else if (newsSwipeview.stacktype=="Directmessage"){
Service.updateView("Direct Messages")
}
else if (newsSwipeview.stacktype=="Notifications"){
Service.updateView("Notifications")
}
expectScreenUpdate=true;
} }
} }
@ -161,7 +179,7 @@ Rectangle{
newsView.anchors.topMargin=mm newsView.anchors.topMargin=mm
} }
function getOldNews(){ function getOldNews(){print("getoldnews")
var currentTime= new Date(); var currentTime= new Date();
try{var oldnewsitemobject=newsModel.get(newsModel.count-1).newsitemobject; try{var oldnewsitemobject=newsModel.get(newsModel.count-1).newsitemobject;
@ -199,13 +217,13 @@ Rectangle{
else if (newstab.newstabstatus=="Notifications" || newstabstatus=="Notifications"){} else if (newstab.newstabstatus=="Notifications" || newstabstatus=="Notifications"){}
else{ else{
switch(newsSwipeview.stacktype){ // switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break; // case "Home":messagetype=0;break;
case "DirectMessages": messagetype=1;break; // case "DirectMessages": messagetype=1;break;
case "Notifications":messagetype=2;break; // case "Notifications":messagetype=2;break;
case "Replies":messagetype=3;break; // case "Replies":messagetype=3;break;
default:messagetype=0; // default:messagetype=0;
} // }
try{xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);}catch(e){} try{xhr.setParam("max_id",newsModel.get(newsModel.count-1).newsitemobject.id-1);}catch(e){}
xhr.get() xhr.get()
@ -215,20 +233,24 @@ Rectangle{
function loadDBNews(){ function loadDBNews(){
var messagetype=0; var messagetype=99;
switch(newsSwipeview.stacktype){ switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break; case "Home":messagetype=0;break;
case "DirectMessages": messagetype=1;break; case "DirectMessages": messagetype=1;break;
case "Notifications":messagetype=2;break; case "Notifications":messagetype=2;break;
case "Replies":messagetype=3;break; case "Replies":messagetype=3;break;
default:messagetype=0; default:messagetype=99;
} }
print("messagetype " + messagetype);
if((newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){ if((newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){
Newsjs.chatsfromdb(db,login,messagetype,[],function(dbnews,lastid){ Newsjs.chatsfromdb(db,login,messagetype,[],function(dbnews,lastid){
lastnewsid=lastid; lastnewsid=lastid;
showNews(dbnews); showNews(dbnews);
}) })
} }
else if (messagetype==99){
newstypeHandling()
}
else{ else{
Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){ Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){
lastnewsid=lastid; lastnewsid=lastid;
@ -243,7 +265,7 @@ Rectangle{
newsBusy.running=false; newsBusy.running=false;
expectScreenUpdate=false; expectScreenUpdate=false;
} }
function onSuccess(data,api){ function onSuccess(data,api){print("newsstack api "+api);
const newsApiArray=["/api/statuses/friends_timeline", const newsApiArray=["/api/statuses/friends_timeline",
"/api/direct_messages/all", "/api/direct_messages/all",
"/api/direct_messages/conversation", "/api/direct_messages/conversation",
@ -258,12 +280,11 @@ Rectangle{
"/api/lists/statuses", "/api/lists/statuses",
"/api/statuses/update", "/api/statuses/update",
"/api/direct_messages/new" "/api/direct_messages/new"
]; ];
if(newsApiArray.includes(api) && expectScreenUpdate==true){ if(newsApiArray.includes(api) && expectScreenUpdate==true){
expectScreenUpdate=false; expectScreenUpdate=false;
Service.processNews(api,data) Service.processNews(api,data)
root.replySignal("") //root.replySignal("")
expectScreenUpdate=false;
} }
} }
} }
@ -282,7 +303,7 @@ Rectangle{
} }
Timer {id:replytimer; interval: 1000; running: false; repeat: false Timer {id:replytimer; interval: 1000; running: false; repeat: false
onTriggered: { onTriggered: {print("replytimer")
newsBusy.running=true; newsBusy.running=true;
if(newstab.newstabstatus=="Conversation"){ if(newstab.newstabstatus=="Conversation"){
showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)} showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)}
@ -344,6 +365,17 @@ Rectangle{
} }
} }
BusyIndicator{
id: newsBusy
anchors.horizontalCenter: newsStack.horizontalCenter
anchors.top:parent.top
anchors.topMargin: mm
width: 2*root.fontFactor*osSettings.bigFontSize
height: 2*root.fontFactor*osSettings.bigFontSize
z:2
running: false
}
ListView { ListView {
id: newsView id: newsView
property real oldContentY:0 property real oldContentY:0
@ -450,6 +482,33 @@ Rectangle{
source: "qrc:/js/newsworker.js" source: "qrc:/js/newsworker.js"
} }
Text {
id: closeButton
//Svisible: !(globaloptions.defaultNewsTypes.indexOf(newsSwipeview.stacktype)>-1)
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
width: root.fontFactor*osSettings.bigFontSize*2
height: root.fontFactor*osSettings.bigFontSize*2
font.bold: true
font.family: fontAwesome.name
font.pointSize: osSettings.bigFontSize
HoverHandler{id:closehover}
ToolTip.visible: closehover.hovered
ToolTip.text: qsTr("Close this timeline")
text: "\uf057"
MouseArea{
anchors.fill: parent
onClicked: {
newstabitem.newstypes.splice(newsSwipeview.currentIndex,1)
newstabbar.removeItem(newstabbar.contentChildren[newstabbar.currentIndex]);
newstabbar.currentIndex=0;
newsSwipeview.removeItem(newsStack)
newsSwipeview.currentIndex=0;
}
}
}
Rectangle{ Rectangle{
id:downloadNotice id:downloadNotice
@ -476,6 +535,7 @@ Rectangle{
} }
Component.onCompleted: { Component.onCompleted: {
print("globaloptions.defaultNewsTypes.indexOf(newsSwipeview.stacktype)>-1 " +(globaloptions.defaultNewsTypes.indexOf(newsSwipeview.stacktype)>-1))
root.newstypeSignal.connect(newstypeHandling); root.newstypeSignal.connect(newstypeHandling);
root.contactdetailsSignal.connect(showContact); root.contactdetailsSignal.connect(showContact);
root.newsSignal.connect(showNews); root.newsSignal.connect(showNews);

View file

@ -41,6 +41,7 @@ Page{
id:newstabitem id:newstabitem
width:rootstack.width width:rootstack.width
height: rootstack.height height: rootstack.height
property var newstypes: globaloptions.hasOwnProperty("defaultNewsTypes")?globaloptions.defaultNewsTypes:["Home","Replies","DirectMessages","Notifications"]
Timer {id:contacttimer; interval: 50; running: false; repeat: false Timer {id:contacttimer; interval: 50; running: false; repeat: false
onTriggered: { onTriggered: {
@ -126,6 +127,24 @@ Page{
messageWindow.show(); messageWindow.show();
} }
function getIcon(typerequest){
switch (typerequest){
case "Home": return "\uf015"
case "Favorites": return "\uf005";
case "Replies": return "\uf0ec";
case "DirectMessages": return "\uf0e0";
case "Public Timeline": return "\uf0ac";
case "Group News": return "\uf0c0";
case "Search": return "\uf002";
case "Notifications": return "\uf0f3";
}
}
function addToolbutton(buttontype){
var component = Qt.createComponent("qrc:/qml/newsqml/NewsTabbutton.qml");
var tabcomp = component.createObject(newstabbar,{"buttontype":buttontype});
newstabbar.addItem(tabcomp);
}
// CalendarTab{ // CalendarTab{
// visible: wideScreen&&rootstackView.depth<2 // visible: wideScreen&&rootstackView.depth<2
// width: newstabitem.width/3 // width: newstabitem.width/3
@ -140,7 +159,7 @@ Page{
// anchors.left: newsSwipeview.right // anchors.left: newsSwipeview.right
// } // }
MessageSend{} //MessageSend{}
BlueButton{ BlueButton{
z:2 z:2
@ -184,64 +203,13 @@ Page{
id: newstabbar id: newstabbar
x: leftDrawer.width x: leftDrawer.width
width: newsSwipeview.width width: newsSwipeview.width
height: contentHeight+2
spacing: 1 spacing: 1
position: TabBar.Header position: TabBar.Header
onCurrentIndexChanged: { onCurrentIndexChanged: {
newsSwipeview.currentIndex=newstabbar.currentIndex; newsSwipeview.currentIndex=newstabbar.currentIndex;
} }
TabButton { clip: true
font.family: fontAwesome.name
font.pointSize : osSettings.bigFontSize
width: newstabbar.width/5
text: "\uf015"
background:Rectangle{
anchors.fill: parent
color: osSettings.backgroundDimColor
border.color: newsSwipeview.currentIndex==0?osSettings.accentColor:color
}
ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Home")
onDoubleClicked: {newstypeSignal("refresh")}
}
TabButton {
font.family: fontAwesome.name
font.pointSize: osSettings.bigFontSize
width: newstabbar.width/5
text: "\uf0ec"
background:Rectangle{
anchors.fill: parent
color: osSettings.backgroundDimColor
border.color: newsSwipeview.currentIndex==1?osSettings.accentColor:color
}
ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Replies")
}
TabButton {
font.family: fontAwesome.name
font.pointSize: osSettings.bigFontSize
width: newstabbar.width/5
text: "\uf0e0"
background:Rectangle{
anchors.fill: parent
color: osSettings.backgroundDimColor
border.color: newsSwipeview.currentIndex==2?osSettings.accentColor:color
}
ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Direct Messages")
}
TabButton {
font.family: fontAwesome.name
font.pointSize: osSettings.bigFontSize
width: newstabbar.width/5
text: "\uf0f3"
background:Rectangle{
anchors.fill: parent
color: osSettings.backgroundDimColor
border.color: newsSwipeview.currentIndex==3?osSettings.accentColor:color
}
ToolTip.visible: pressed || hovered
ToolTip.text: qsTr("Notifications")
}
} }
SwipeView{ SwipeView{
@ -255,38 +223,22 @@ Page{
function onDirectMessage(friend){currentIndex=2} function onDirectMessage(friend){currentIndex=2}
onCurrentIndexChanged: { onCurrentIndexChanged: {
switch(currentIndex){ if(newstypes[currentIndex]){stacktype=newstypes[currentIndex]}
case 0: stacktype="Home";break; else{stacktype="Home"}
case 1: stacktype="Replies";break;
case 2: stacktype="DirectMessages";break;
case 3: stacktype="Notifications";break;
default: stacktype="Home";
}
} }
//anchors.fill: parent
Loader{ Loader{
id: friendstimeline
source:(newsSwipeview.currentIndex==0)? "qrc:/qml/newsqml/NewsStack.qml":"" source:(newsSwipeview.currentIndex==0)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="Home"
} }
Loader{ Loader{
id: replies
//property string stacktype:"Replies"
source:(newsSwipeview.currentIndex==1)? "qrc:/qml/newsqml/NewsStack.qml":"" source:(newsSwipeview.currentIndex==1)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="Replies"
} }
Loader{ Loader{
id: directmessages //property var friend:({})
property var friend:({})
source:(newsSwipeview.currentIndex==2)? "qrc:/qml/newsqml/NewsStack.qml":"" source:(newsSwipeview.currentIndex==2)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="DirectMessages"
} }
Loader{ Loader{
id: notifications
//property string stacktype:"Notifications"
source:(newsSwipeview.currentIndex==3)? "qrc:/qml/newsqml/NewsStack.qml":"" source:(newsSwipeview.currentIndex==3)? "qrc:/qml/newsqml/NewsStack.qml":""
//onLoaded: newsSwipeview.stacktype="Notifications"
} }
} }
@ -301,16 +253,20 @@ Page{
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
BusyIndicator{ Connections{
id: newsBusy target: root
anchors.horizontalCenter: newsSwipeview.horizontalCenter function onGlobaloptionsChanged(){
anchors.top:parent.top newstypes=globaloptions.defaultNewsTypes;
anchors.topMargin: mm while (newstabbar.count>0){
width: 2*root.fontFactor*osSettings.bigFontSize newstabbar.removeItem(newstabbar.contentData[0]);
height: 2*root.fontFactor*osSettings.bigFontSize }
z:2 for (let view in newstypes){
running: false addToolbutton(newstypes[view])
}
}
} }
Component.onCompleted: {root.directmessageSignal.connect(newsSwipeview.onDirectMessage)} Component.onCompleted: {
root.directmessageSignal.connect(newsSwipeview.onDirectMessage)
}
} }

View file

@ -0,0 +1,51 @@
// This file is part of Friendiqa
// https://git.friendi.ca/lubuwest/Friendiqa
// Copyright (C) 2020 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/>.
import QtQuick 2.15
import QtQuick.Controls 6.3
TabButton {
id: tabbutton
font.family: fontAwesome.name
font.pointSize : osSettings.bigFontSize
width: newstabbar.width/5
property string buttontype: ""
text: getIcon(buttontype)
background:Rectangle{
anchors.fill: parent
color: osSettings.backgroundDimColor
border.color: newstypes[newsSwipeview.currentIndex]==buttontype?osSettings.accentColor:color
}
ToolTip.delay: 500
ToolTip.visible: pressed || hovered
ToolTip.text: qsTr(buttontype)
onDoubleClicked: {newstypeSignal(buttontype)}
}