1
0
Fork 0

FGQCanvas: in-app help page

This commit is contained in:
James Turner 2018-11-08 09:40:53 +01:00
parent 2cd3036488
commit 56495485e2
9 changed files with 121 additions and 7 deletions

View file

@ -35,6 +35,7 @@
#include <QWindow>
#include <QTimer>
#include <QGuiApplication>
#include <QSettings>
#include "jsonutils.h"
#include "canvasconnection.h"
@ -44,8 +45,10 @@ ApplicationController::ApplicationController(QObject *parent)
, m_status(Idle)
{
m_netAccess = new QNetworkAccessManager;
m_host = "localhost";
m_port = 8080;
QSettings settings;
m_host = settings.value("last-host", "localhost").toString();
m_port = settings.value("last-port", 8080).toUInt();
QNetworkDiskCache* cache = new QNetworkDiskCache;
cache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
@ -245,10 +248,14 @@ void ApplicationController::query()
if (m_host.isEmpty() || (m_port == 0))
return;
QSettings settings;
settings.setValue("last-host", m_host);
settings.setValue("last-port", m_port);
QUrl queryUrl;
queryUrl.setScheme("http");
queryUrl.setHost(m_host);
queryUrl.setPort(m_port);
queryUrl.setPort(static_cast<int>(m_port));
queryUrl.setPath("/json/canvas/by-index");
queryUrl.setQuery("d=2");
@ -370,6 +377,19 @@ bool ApplicationController::showUI() const
return m_showUI;
}
QString ApplicationController::gettingStartedText() const
{
QFile f(":/doc/gettingStarted.html");
f.open(QIODevice::ReadOnly);
return QString::fromUtf8(f.readAll());
}
bool ApplicationController::showGettingStarted() const
{
QSettings settings;
return settings.value("show-getting-started", true).toBool();
}
void ApplicationController::setHost(QString host)
{
if (m_host == host)
@ -390,6 +410,16 @@ void ApplicationController::setPort(unsigned int port)
setStatus(Idle);
}
void ApplicationController::setShowGettingStarted(bool show)
{
QSettings settings;
if (settings.value("show-getting-started", true).toBool() == show)
return;
settings.setValue("show-getting-started", show);
emit showGettingStartedChanged(show);
}
QJsonObject jsonPropNodeFindChild(QJsonObject obj, QByteArray name)
{
Q_FOREACH (QJsonValue v, obj.value("children").toArray()) {

View file

@ -49,6 +49,9 @@ class ApplicationController : public QObject
Q_PROPERTY(bool showUI READ showUI NOTIFY showUIChanged)
Q_PROPERTY(bool blockUIIdle READ blockUIIdle WRITE setBlockUIIdle NOTIFY blockUIIdleChanged)
Q_PROPERTY(QString gettingStartedText READ gettingStartedText CONSTANT)
Q_PROPERTY(bool showGettingStarted READ showGettingStarted WRITE setShowGettingStarted NOTIFY showGettingStartedChanged)
public:
explicit ApplicationController(QObject *parent = nullptr);
~ApplicationController();
@ -115,6 +118,10 @@ public:
return m_blockUIIdle;
}
QString gettingStartedText() const;
bool showGettingStarted() const;
signals:
void hostChanged(QString host);
@ -133,6 +140,8 @@ signals:
void showUIChanged();
void blockUIIdleChanged(bool blockUIIdle);
void showGettingStartedChanged(bool showGettingStarted);
public slots:
void setHost(QString host);
@ -147,6 +156,8 @@ public slots:
emit blockUIIdleChanged(m_blockUIIdle);
}
void setShowGettingStarted(bool showGettingStarted);
protected:
bool eventFilter(QObject* obj, QEvent* event) override;

View file

@ -0,0 +1,11 @@
<h2>FlightGear Remote Canvas</h2>
<p>Remote-canvas connects to a running FlightGear instance via a WebSocket
connection. FlightGear must have been started with the <tt>--httpd</tt> option.
Enter the IP address or hostname of the computer running FlightGear, and
choose the 'Query' option to select a canvas.
</p>
<p>Several canvases can be added, moved and resized. Be patient when
connecting, especially over WiFi. A configuration of canvases and their sizes
can be saved and loaded, useful for dedicated setups.</p>
<p>Press and hold on a canvas to bring up a menu for it - this allows a
canvas to be closed, or to reconnect to the FlightGear instance</p>

View file

@ -47,8 +47,8 @@ RESOURCES += \
OTHER_FILES += \
qml/*
qml/* \
doc/*
#Q_XCODE_DEVELOPMENT_TEAM.name = DEVELOPMENT_TEAM
#Q_XCODE_DEVELOPMENT_TEAM.value = "James Turner"

View file

@ -10,5 +10,7 @@
<file>qml/VerticalTabPanel.qml</file>
<file>qml/SnapshotsPanel.qml</file>
<file>qml/CanvasMenu.qml</file>
<file>qml/GetStarted.qml</file>
<file>doc/gettingStarted.html</file>
</qresource>
</RCC>

View file

@ -0,0 +1,56 @@
import QtQuick 2.0
Rectangle {
id: root
border.width: 1
border.color: "orange"
color: "#1f1f1f"
height: contentBox.childrenRect.height + 40
width: 600
Component.onCompleted: {
if (!_application.showGettingStarted) {
root.visible = false;
}
}
Column {
id: contentBox
width: parent.width - 20
y: 20
spacing: 20
anchors {
horizontalCenter: parent.horizontalCenter
}
Text {
width: parent.width
text: _application.gettingStartedText
wrapMode: Text.WordWrap
color: "white"
}
Row {
id: buttonRow
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
height: childrenRect.height
Button {
label: qsTr("Okay")
onClicked: root.visible = false
width: 150
}
Button {
label: qsTr("Don't show again")
onClicked: {
_application.showGettingStarted = false;
root.visible = false
}
width: 150
}
}
}
}

View file

@ -71,7 +71,7 @@ Item {
color: "#1f1f1f"
width: delegateFrame.width
height: delegateFrame.height
clip: true
Button {
id: deleteButton

View file

@ -5,7 +5,7 @@ Item {
property int activeTab: -1
property var tabs: []
property var titles: []
property int __panelWidth: 200
property int __panelWidth: 250
readonly property int panelWidth: __panelWidth
@ -34,6 +34,7 @@ Item {
Connections {
target: loader.item
onRequestPanelClose: root.activeTab = -1;
ignoreUnknownSignals: true
}
}

View file

@ -57,6 +57,9 @@ Rectangle {
SnapshotsPanel { }
}
GetStarted {
anchors.centerIn: parent
}
}