mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
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:
parent
ea42d822c2
commit
10ec1144eb
6 changed files with 82 additions and 89 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,3 +10,5 @@ Makefile*
|
||||||
*~
|
*~
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
*.pro.user
|
*.pro.user
|
||||||
|
.kdev4
|
||||||
|
*.kdev4
|
||||||
|
|
|
@ -73,13 +73,14 @@ void ApiLocalConnectionHandler::handlePendingRequests()
|
||||||
{
|
{
|
||||||
if(mLocalSocket->canReadLine())
|
if(mLocalSocket->canReadLine())
|
||||||
{
|
{
|
||||||
readPath:
|
readPath:
|
||||||
QString rString(mLocalSocket->readLine());
|
QString rString(mLocalSocket->readLine());
|
||||||
rString = rString.simplified();
|
rString = rString.simplified();
|
||||||
if (!rString.isEmpty())
|
if (!rString.isEmpty())
|
||||||
{
|
{
|
||||||
if(rString.startsWith("PUT", Qt::CaseInsensitive)) reqMeth = resource_api::Request::PUT;
|
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 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];
|
if(rString.contains(' ')) rString = rString.split(' ')[1];
|
||||||
|
|
||||||
reqPath = rString.toStdString();
|
reqPath = rString.toStdString();
|
||||||
|
|
|
@ -27,19 +27,30 @@ Item
|
||||||
|
|
||||||
ColumnLayout
|
ColumnLayout
|
||||||
{
|
{
|
||||||
id: colLayout
|
anchors.fill: parent
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.bottom: rowLayout.top
|
|
||||||
|
|
||||||
|
Button
|
||||||
TextField { id: myKeyField }
|
{
|
||||||
TextField { id: otherKeyField }
|
id: bottomButton
|
||||||
}
|
text: "Add trusted node"
|
||||||
|
onClicked:
|
||||||
RowLayout
|
{
|
||||||
{
|
console.log("retroshare addtrusted: ", otherKeyField.text)
|
||||||
id: rowLayout
|
var jsonData =
|
||||||
anchors.top: colLayout.bottom
|
{
|
||||||
|
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
|
Button
|
||||||
{
|
{
|
||||||
|
@ -60,29 +71,8 @@ Item
|
||||||
otherKeyField.paste()
|
otherKeyField.paste()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Button
|
TextField { id: myKeyField }
|
||||||
{
|
TextField { id: otherKeyField }
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ Item
|
||||||
property var qParent
|
property var qParent
|
||||||
property bool attemptLogin: false
|
property bool attemptLogin: false
|
||||||
property string password
|
property string password
|
||||||
|
property string sslid
|
||||||
|
|
||||||
states:
|
states:
|
||||||
[
|
[
|
||||||
|
@ -34,7 +35,7 @@ Item
|
||||||
{
|
{
|
||||||
name: "selectLocation"
|
name: "selectLocation"
|
||||||
PropertyChanges { target: locationsListView; visible: true }
|
PropertyChanges { target: locationsListView; visible: true }
|
||||||
PropertyChanges { target: bottomButton; visible: true }
|
PropertyChanges { target: bottomButton; visible: true }
|
||||||
PropertyChanges { target: loginView; visible: false }
|
PropertyChanges { target: loginView; visible: false }
|
||||||
},
|
},
|
||||||
State
|
State
|
||||||
|
@ -67,7 +68,8 @@ Item
|
||||||
onSubmit:
|
onSubmit:
|
||||||
{
|
{
|
||||||
locationView.password = password
|
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
|
locationView.attemptLogin = true
|
||||||
busyIndicator.running = true
|
busyIndicator.running = true
|
||||||
attemptTimer.start()
|
attemptTimer.start()
|
||||||
|
@ -148,10 +150,10 @@ Item
|
||||||
delegate: Button
|
delegate: Button
|
||||||
{
|
{
|
||||||
text: model.name
|
text: model.name
|
||||||
property string sslid: model.id
|
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
loginView.login = text
|
loginView.login = text
|
||||||
|
locationView.sslid = model.id
|
||||||
locationView.state = "login"
|
locationView.state = "login"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||||
|
import "jsonpath.js" as JSONPath
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
function refreshData() { rsApi.request("/peers", "") }
|
function refreshData() { rsApi.request("/peers/*", "") }
|
||||||
|
|
||||||
onFocusChanged: focus && refreshData()
|
onFocusChanged: focus && refreshData()
|
||||||
|
|
||||||
|
@ -45,7 +46,11 @@ Item
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: bottomButton.top
|
anchors.bottom: bottomButton.top
|
||||||
model: jsonModel.model
|
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
|
Button
|
||||||
|
@ -53,6 +58,6 @@ Item
|
||||||
id: bottomButton
|
id: bottomButton
|
||||||
text: "Add Trusted Node"
|
text: "Add Trusted Node"
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
onClicked: swipeView.currentIndex = addTrustedNodeView.SwipeView.index
|
onClicked: swipeView.currentIndex = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Controls 2.0
|
import QtQuick.Controls 1.4
|
||||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||||
|
|
||||||
ApplicationWindow
|
ApplicationWindow
|
||||||
|
@ -25,30 +25,34 @@ ApplicationWindow
|
||||||
id: mainWindow
|
id: mainWindow
|
||||||
visible: true
|
visible: true
|
||||||
title: qsTr("RSChat")
|
title: qsTr("RSChat")
|
||||||
|
width: 400
|
||||||
|
height: 400
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
id: mainView
|
id: mainView
|
||||||
anchors.fill: parent;
|
anchors.fill: parent
|
||||||
|
|
||||||
states:
|
states:
|
||||||
[
|
[
|
||||||
State
|
State
|
||||||
{
|
{
|
||||||
name: "waiting_account_select";
|
name: "waiting_account_select"
|
||||||
PropertyChanges { target: swipeView; currentIndex: locationsView.SwipeView.index }
|
PropertyChanges { target: swipeView; currentIndex: 0 }
|
||||||
},
|
PropertyChanges { target: locationsTab; enabled: true }
|
||||||
State
|
},
|
||||||
{
|
State
|
||||||
name: "running_ok"
|
{
|
||||||
//PropertyChanges { target: swipeView; currentIndex: contactsView.SwipeView.index }
|
name: "running_ok"
|
||||||
},
|
PropertyChanges { target: swipeView; currentIndex: 1 }
|
||||||
State
|
PropertyChanges { target: locationsTab; enabled: false }
|
||||||
{
|
},
|
||||||
name: "running_ok_no_full_control"
|
State
|
||||||
//PropertyChanges { target: swipeView; currentIndex: contactsView.SwipeView.index }
|
{
|
||||||
}
|
name: "running_ok_no_full_control"
|
||||||
]
|
PropertyChanges { target: swipeView; currentIndex: 1 }
|
||||||
|
PropertyChanges { target: locationsTab; enabled: false }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
LibresapiLocalClient
|
LibresapiLocalClient
|
||||||
{
|
{
|
||||||
|
@ -64,53 +68,42 @@ ApplicationWindow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwipeView
|
TabView
|
||||||
{
|
{
|
||||||
id: swipeView
|
id: swipeView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: true
|
visible: true
|
||||||
currentIndex: 0
|
currentIndex: 0
|
||||||
|
|
||||||
Locations
|
Tab
|
||||||
{
|
{
|
||||||
id: locationsView
|
title:"Locations"
|
||||||
visible: true
|
id: locationsTab
|
||||||
qParent: swipeView
|
Locations { onVisibleChanged: focus = visible }
|
||||||
}
|
}
|
||||||
|
|
||||||
TrustedNodesView { id: trustedNodesView }
|
Tab
|
||||||
|
|
||||||
Contacts
|
|
||||||
{
|
{
|
||||||
id: contactsView
|
title: "Trusted Nodes"
|
||||||
visible: true
|
TrustedNodesView { onVisibleChanged: focus = visible }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle
|
Tab
|
||||||
{
|
{
|
||||||
color: "red"
|
title: "Contacts"
|
||||||
width: 100
|
Contacts { onVisibleChanged: focus = visible }
|
||||||
height: 100
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle
|
Tab
|
||||||
{
|
{
|
||||||
color: "green"
|
title: "Add Node"
|
||||||
width: 100
|
AddTrustedNode { onVisibleChanged: focus = visible }
|
||||||
height: 100
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle
|
Tab
|
||||||
{
|
{
|
||||||
color: "blue"
|
title: "Blue"
|
||||||
width: 100
|
Rectangle { color: "blue"; anchors.fill: parent }
|
||||||
height: 100
|
|
||||||
}
|
|
||||||
|
|
||||||
AddTrustedNode
|
|
||||||
{
|
|
||||||
id: addTrustedNodeView
|
|
||||||
visible: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue