Simplify QML to work better on both Desktop and Phone

- Set request method to GET by default in ApiLocalConnectionHandler to avoid
/peers request fail randomly
- Use TabView instead of SwipeView to not depend on Qt 5.7.0 (latest version)
- AddTrustedNode simplified layout to avoid unexpected behaviour on some phones
- Locations add sslid property to root Item to avoid unexpected behaviour when
multiple locations are available
- TrustedNodesView color connected friends with green and offline with grey
- Ignore kdevelop 4 files
This commit is contained in:
Gio 2016-10-26 20:37:28 +02:00
parent ea42d822c2
commit 10ec1144eb
6 changed files with 82 additions and 89 deletions

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ Makefile*
*~
Thumbs.db
*.pro.user
.kdev4
*.kdev4

View File

@ -73,13 +73,14 @@ void ApiLocalConnectionHandler::handlePendingRequests()
{
if(mLocalSocket->canReadLine())
{
readPath:
readPath:
QString rString(mLocalSocket->readLine());
rString = rString.simplified();
if (!rString.isEmpty())
{
if(rString.startsWith("PUT", Qt::CaseInsensitive)) reqMeth = resource_api::Request::PUT;
else if (rString.startsWith("DELETE", Qt::CaseInsensitive)) reqMeth = resource_api::Request::DELETE_AA;
else reqMeth = resource_api::Request::GET;
if(rString.contains(' ')) rString = rString.split(' ')[1];
reqPath = rString.toStdString();

View File

@ -27,19 +27,30 @@ Item
ColumnLayout
{
id: colLayout
anchors.top: parent.top
anchors.bottom: rowLayout.top
anchors.fill: parent
TextField { id: myKeyField }
TextField { id: otherKeyField }
}
RowLayout
{
id: rowLayout
anchors.top: colLayout.bottom
Button
{
id: bottomButton
text: "Add trusted node"
onClicked:
{
console.log("retroshare addtrusted: ", otherKeyField.text)
var jsonData =
{
cert_string: otherKeyField.text,
flags:
{
allow_direct_download: true,
allow_push: false,
require_whitelist: false,
}
}
console.log("retroshare addtrusted jsonData: ", JSON.stringify(jsonData))
//rsApi.request("/peers/examine_cert/", JSON.stringify({ cert_string: otherKeyField.text }))
rsApi.request("PUT /peers", JSON.stringify(jsonData))
}
}
Button
{
@ -60,29 +71,8 @@ Item
otherKeyField.paste()
}
}
}
Button
{
id: bottomButton
text: "Add trusted node"
anchors.bottom: parent.bottom
onClicked:
{
console.log("retroshare addtrusted: ", otherKeyField.text)
var jsonData =
{
cert_string: otherKeyField.text,
flags:
{
allow_direct_download: true,
allow_push: false,
require_whitelist: false,
}
}
console.log("retroshare addtrusted jsonData: ", JSON.stringify(jsonData))
//rsApi.request("/peers/examine_cert/", JSON.stringify({ cert_string: otherKeyField.text }))
rsApi.request("PUT /peers", JSON.stringify(jsonData))
}
TextField { id: myKeyField }
TextField { id: otherKeyField }
}
}

View File

@ -27,6 +27,7 @@ Item
property var qParent
property bool attemptLogin: false
property string password
property string sslid
states:
[
@ -34,7 +35,7 @@ Item
{
name: "selectLocation"
PropertyChanges { target: locationsListView; visible: true }
PropertyChanges { target: bottomButton; visible: true }
PropertyChanges { target: bottomButton; visible: true }
PropertyChanges { target: loginView; visible: false }
},
State
@ -67,7 +68,8 @@ Item
onSubmit:
{
locationView.password = password
rsApi.request("/control/login/", JSON.stringify({id: locationsListView.currentItem.sslid}))
console.log("locationView.sslid: ", locationView.sslid)
rsApi.request("/control/login/", JSON.stringify({id: locationView.sslid}))
locationView.attemptLogin = true
busyIndicator.running = true
attemptTimer.start()
@ -148,10 +150,10 @@ Item
delegate: Button
{
text: model.name
property string sslid: model.id
onClicked:
{
loginView.login = text
locationView.sslid = model.id
locationView.state = "login"
}
}

View File

@ -19,10 +19,11 @@
import QtQuick 2.0
import QtQuick.Controls 1.4
import org.retroshare.qml_components.LibresapiLocalClient 1.0
import "jsonpath.js" as JSONPath
Item
{
function refreshData() { rsApi.request("/peers", "") }
function refreshData() { rsApi.request("/peers/*", "") }
onFocusChanged: focus && refreshData()
@ -45,7 +46,11 @@ Item
anchors.top: parent.top
anchors.bottom: bottomButton.top
model: jsonModel.model
delegate: Text { text: model.name }
delegate: Text
{
text: model.name
onTextChanged: color = JSONPath.jsonPath(JSON.parse(jsonModel.json), "$.data[?(@.pgp_id=='"+model.pgp_id+"')].locations[*].is_online").reduce(function(cur,acc){return cur || acc}, false) ? "lime" : "darkslategray"
}
}
Button
@ -53,6 +58,6 @@ Item
id: bottomButton
text: "Add Trusted Node"
anchors.bottom: parent.bottom
onClicked: swipeView.currentIndex = addTrustedNodeView.SwipeView.index
onClicked: swipeView.currentIndex = 3
}
}

View File

@ -17,7 +17,7 @@
*/
import QtQuick 2.2
import QtQuick.Controls 2.0
import QtQuick.Controls 1.4
import org.retroshare.qml_components.LibresapiLocalClient 1.0
ApplicationWindow
@ -25,30 +25,34 @@ ApplicationWindow
id: mainWindow
visible: true
title: qsTr("RSChat")
width: 400
height: 400
Rectangle
{
id: mainView
anchors.fill: parent;
anchors.fill: parent
states:
[
State
{
name: "waiting_account_select";
PropertyChanges { target: swipeView; currentIndex: locationsView.SwipeView.index }
},
State
{
name: "running_ok"
//PropertyChanges { target: swipeView; currentIndex: contactsView.SwipeView.index }
},
State
{
name: "running_ok_no_full_control"
//PropertyChanges { target: swipeView; currentIndex: contactsView.SwipeView.index }
}
]
State
{
name: "waiting_account_select"
PropertyChanges { target: swipeView; currentIndex: 0 }
PropertyChanges { target: locationsTab; enabled: true }
},
State
{
name: "running_ok"
PropertyChanges { target: swipeView; currentIndex: 1 }
PropertyChanges { target: locationsTab; enabled: false }
},
State
{
name: "running_ok_no_full_control"
PropertyChanges { target: swipeView; currentIndex: 1 }
PropertyChanges { target: locationsTab; enabled: false }
}
]
LibresapiLocalClient
{
@ -64,53 +68,42 @@ ApplicationWindow
}
}
SwipeView
TabView
{
id: swipeView
anchors.fill: parent
visible: true
currentIndex: 0
Locations
Tab
{
id: locationsView
visible: true
qParent: swipeView
title:"Locations"
id: locationsTab
Locations { onVisibleChanged: focus = visible }
}
TrustedNodesView { id: trustedNodesView }
Contacts
Tab
{
id: contactsView
visible: true
title: "Trusted Nodes"
TrustedNodesView { onVisibleChanged: focus = visible }
}
Rectangle
Tab
{
color: "red"
width: 100
height: 100
title: "Contacts"
Contacts { onVisibleChanged: focus = visible }
}
Rectangle
Tab
{
color: "green"
width: 100
height: 100
title: "Add Node"
AddTrustedNode { onVisibleChanged: focus = visible }
}
Rectangle
Tab
{
color: "blue"
width: 100
height: 100
}
AddTrustedNode
{
id: addTrustedNodeView
visible: true
title: "Blue"
Rectangle { color: "blue"; anchors.fill: parent }
}
}
}