2016-09-15 07:07:13 -04:00
|
|
|
/*
|
|
|
|
* RetroShare Android QML App
|
2017-03-17 12:22:58 -04:00
|
|
|
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
2016-09-15 07:07:13 -04:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-09-04 09:01:44 -04:00
|
|
|
|
|
|
|
import QtQuick 2.2
|
2016-10-26 14:37:28 -04:00
|
|
|
import QtQuick.Controls 1.4
|
2016-09-15 07:07:13 -04:00
|
|
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
|
|
|
|
|
|
|
ApplicationWindow
|
|
|
|
{
|
|
|
|
id: mainWindow
|
|
|
|
visible: true
|
2017-03-17 12:22:58 -04:00
|
|
|
title: "RetroShare"
|
2016-10-26 14:37:28 -04:00
|
|
|
width: 400
|
|
|
|
height: 400
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
toolBar: ToolBar
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
Image
|
|
|
|
{
|
|
|
|
id: rsIcon
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
height: Math.max(30, parent.height - 4)
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: "icons/retroshare06.png"
|
|
|
|
}
|
|
|
|
Label
|
|
|
|
{
|
|
|
|
text: "RetroShare"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: rsIcon.right
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
}
|
|
|
|
}
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
menuBar: MenuBar
|
|
|
|
{
|
|
|
|
Menu
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
MenuItem
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
text: "Trusted Nodes"
|
|
|
|
onTriggered:
|
|
|
|
stackView.push({item:"qrc:/qml/TrustedNodesView.qml"})
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
MenuItem
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
text: "StackView State"
|
|
|
|
onTriggered: console.log(stackView.state, stackView.enabled)
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
StackView
|
|
|
|
{
|
|
|
|
id: stackView
|
|
|
|
anchors.fill: parent
|
|
|
|
Keys.onReleased:
|
|
|
|
if (event.key === Qt.Key_Back && stackView.depth > 1)
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
stackView.pop();
|
|
|
|
event.accepted = true;
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
function checkCoreStatus()
|
|
|
|
{
|
|
|
|
function runStateCallback(par)
|
2016-09-16 06:04:49 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
var jsonReponse = JSON.parse(par.response)
|
|
|
|
var runState = jsonReponse.data.runstate
|
|
|
|
if(typeof(runState) === 'string') stackView.state = runState
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stackView.state = "core_down"
|
|
|
|
console.log("runStateCallback(...) core is down")
|
|
|
|
}
|
2016-09-16 06:04:49 -04:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
var ret = rsApi.request("/control/runstate/", "", runStateCallback)
|
|
|
|
if ( ret < 1 )
|
2016-09-16 06:04:49 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
console.log("checkCoreStatus() core is down")
|
|
|
|
stackView.state = "core_down"
|
2016-09-16 06:04:49 -04:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2016-09-16 06:04:49 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
Timer
|
|
|
|
{
|
|
|
|
id: refreshTimer
|
|
|
|
interval: 800
|
|
|
|
repeat: true
|
|
|
|
onTriggered: if(stackView.visible) stackView.checkCoreStatus()
|
|
|
|
Component.onCompleted: start()
|
|
|
|
}
|
2016-09-16 06:04:49 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
state: "core_down"
|
|
|
|
states: [
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "core_down"
|
|
|
|
PropertyChanges { target: stackView; enabled: false }
|
|
|
|
},
|
|
|
|
State
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
name: "waiting_account_select"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
2016-12-08 09:56:23 -05:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_account_select")
|
|
|
|
stackView.clear()
|
|
|
|
stackView.push({item:"qrc:/qml/Locations.qml"})
|
|
|
|
}
|
2016-12-08 09:56:23 -05:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
},
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "running_ok"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
|
|
|
{
|
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_account_select")
|
|
|
|
stackView.clear()
|
|
|
|
stackView.push({item: "qrc:/qml/Contacts.qml"})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "running_ok_no_full_control"
|
|
|
|
PropertyChanges { target: stackView; state: "running_ok" }
|
2016-09-27 08:05:14 -04:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
initialItem: Rectangle
|
|
|
|
{
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "green"
|
|
|
|
border.color: "black"
|
|
|
|
|
|
|
|
Text { text: "Connecting to core..." }
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
|
|
|
}
|
2016-09-04 09:01:44 -04:00
|
|
|
}
|