Remote canvas: UI fixes
This commit is contained in:
parent
3b3c99777d
commit
d052dc2576
10 changed files with 167 additions and 25 deletions
|
@ -33,6 +33,8 @@
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include "jsonutils.h"
|
#include "jsonutils.h"
|
||||||
#include "canvasconnection.h"
|
#include "canvasconnection.h"
|
||||||
|
@ -52,6 +54,14 @@ ApplicationController::ApplicationController(QObject *parent)
|
||||||
setStatus(Idle);
|
setStatus(Idle);
|
||||||
rebuildConfigData();
|
rebuildConfigData();
|
||||||
rebuildSnapshotData();
|
rebuildSnapshotData();
|
||||||
|
|
||||||
|
m_uiIdleTimer = new QTimer(this);
|
||||||
|
m_uiIdleTimer->setInterval(10 * 1000);
|
||||||
|
connect(m_uiIdleTimer, &QTimer::timeout, this,
|
||||||
|
&ApplicationController::onUIIdleTimeout);
|
||||||
|
m_uiIdleTimer->start();
|
||||||
|
|
||||||
|
qApp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationController::~ApplicationController()
|
ApplicationController::~ApplicationController()
|
||||||
|
@ -319,6 +329,14 @@ void ApplicationController::openCanvas(QString path)
|
||||||
emit activeCanvasesChanged();
|
emit activeCanvasesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationController::closeCanvas(CanvasConnection *canvas)
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_activeCanvases.indexOf(canvas) >= 0);
|
||||||
|
m_activeCanvases.removeOne(canvas);
|
||||||
|
canvas->deleteLater();
|
||||||
|
emit activeCanvasesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
QString ApplicationController::host() const
|
QString ApplicationController::host() const
|
||||||
{
|
{
|
||||||
return m_host;
|
return m_host;
|
||||||
|
@ -344,6 +362,14 @@ QNetworkAccessManager *ApplicationController::netAccess() const
|
||||||
return m_netAccess;
|
return m_netAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationController::showUI() const
|
||||||
|
{
|
||||||
|
if (m_blockUIIdle)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return m_showUI;
|
||||||
|
}
|
||||||
|
|
||||||
void ApplicationController::setHost(QString host)
|
void ApplicationController::setHost(QString host)
|
||||||
{
|
{
|
||||||
if (m_host == host)
|
if (m_host == host)
|
||||||
|
@ -407,6 +433,12 @@ void ApplicationController::onFinishedGetCanvasList()
|
||||||
setStatus(SuccessfulQuery);
|
setStatus(SuccessfulQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationController::onUIIdleTimeout()
|
||||||
|
{
|
||||||
|
m_showUI = false;
|
||||||
|
emit showUIChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void ApplicationController::setStatus(ApplicationController::Status newStatus)
|
void ApplicationController::setStatus(ApplicationController::Status newStatus)
|
||||||
{
|
{
|
||||||
if (newStatus == m_status)
|
if (newStatus == m_status)
|
||||||
|
@ -498,3 +530,28 @@ QByteArray ApplicationController::createSnapshot(QString name) const
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationController::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(obj);
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::MouseButtonPress:
|
||||||
|
case QEvent::TouchUpdate:
|
||||||
|
case QEvent::MouseMove:
|
||||||
|
case QEvent::TouchBegin:
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
case QEvent::KeyRelease:
|
||||||
|
if (!m_showUI) {
|
||||||
|
m_showUI = true;
|
||||||
|
emit showUIChanged();
|
||||||
|
} else {
|
||||||
|
m_uiIdleTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; //process as normal
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
class CanvasConnection;
|
class CanvasConnection;
|
||||||
class QWindow;
|
class QWindow;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class ApplicationController : public QObject
|
class ApplicationController : public QObject
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,8 @@ class ApplicationController : public QObject
|
||||||
|
|
||||||
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
|
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool showUI READ showUI NOTIFY showUIChanged)
|
||||||
|
Q_PROPERTY(bool blockUIIdle READ blockUIIdle WRITE setBlockUIIdle NOTIFY blockUIIdleChanged)
|
||||||
public:
|
public:
|
||||||
explicit ApplicationController(QObject *parent = nullptr);
|
explicit ApplicationController(QObject *parent = nullptr);
|
||||||
~ApplicationController();
|
~ApplicationController();
|
||||||
|
@ -68,6 +71,7 @@ public:
|
||||||
Q_INVOKABLE void saveConfigChanges(int index);
|
Q_INVOKABLE void saveConfigChanges(int index);
|
||||||
|
|
||||||
Q_INVOKABLE void openCanvas(QString path);
|
Q_INVOKABLE void openCanvas(QString path);
|
||||||
|
Q_INVOKABLE void closeCanvas(CanvasConnection* canvas);
|
||||||
|
|
||||||
Q_INVOKABLE void saveSnapshot(QString snapshotName);
|
Q_INVOKABLE void saveSnapshot(QString snapshotName);
|
||||||
Q_INVOKABLE void restoreSnapshot(int index);
|
Q_INVOKABLE void restoreSnapshot(int index);
|
||||||
|
@ -104,6 +108,13 @@ public:
|
||||||
return m_snapshots;
|
return m_snapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool showUI() const;
|
||||||
|
|
||||||
|
bool blockUIIdle() const
|
||||||
|
{
|
||||||
|
return m_blockUIIdle;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void hostChanged(QString host);
|
void hostChanged(QString host);
|
||||||
|
@ -119,13 +130,29 @@ signals:
|
||||||
|
|
||||||
void snapshotListChanged();
|
void snapshotListChanged();
|
||||||
|
|
||||||
|
void showUIChanged();
|
||||||
|
void blockUIIdleChanged(bool blockUIIdle);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHost(QString host);
|
void setHost(QString host);
|
||||||
|
|
||||||
void setPort(unsigned int port);
|
void setPort(unsigned int port);
|
||||||
|
|
||||||
|
void setBlockUIIdle(bool blockUIIdle)
|
||||||
|
{
|
||||||
|
if (m_blockUIIdle == blockUIIdle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_blockUIIdle = blockUIIdle;
|
||||||
|
emit blockUIIdleChanged(m_blockUIIdle);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFinishedGetCanvasList();
|
void onFinishedGetCanvasList();
|
||||||
|
void onUIIdleTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setStatus(Status newStatus);
|
void setStatus(Status newStatus);
|
||||||
|
@ -155,6 +182,9 @@ private:
|
||||||
Qt::WindowState m_windowState = Qt::WindowNoState;
|
Qt::WindowState m_windowState = Qt::WindowNoState;
|
||||||
|
|
||||||
bool m_daemonMode = false;
|
bool m_daemonMode = false;
|
||||||
|
bool m_showUI = true;
|
||||||
|
bool m_blockUIIdle = false;
|
||||||
|
QTimer* m_uiIdleTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPLICATIONCONTROLLER_H
|
#endif // APPLICATIONCONTROLLER_H
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
<file>qml/LoadSavePanel.qml</file>
|
<file>qml/LoadSavePanel.qml</file>
|
||||||
<file>qml/VerticalTabPanel.qml</file>
|
<file>qml/VerticalTabPanel.qml</file>
|
||||||
<file>qml/SnapshotsPanel.qml</file>
|
<file>qml/SnapshotsPanel.qml</file>
|
||||||
|
<file>qml/CanvasMenu.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -6,6 +6,8 @@ Item {
|
||||||
property bool showDecorations: true
|
property bool showDecorations: true
|
||||||
property alias canvas: paintedDisplay.canvas
|
property alias canvas: paintedDisplay.canvas
|
||||||
property bool showUi: true
|
property bool showUi: true
|
||||||
|
property bool showMenu: false
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
|
@ -74,6 +76,10 @@ Item {
|
||||||
onReleased: {
|
onReleased: {
|
||||||
root.saveGeometry();
|
root.saveGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPressAndHold: {
|
||||||
|
root.showMenu = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -108,6 +114,7 @@ Item {
|
||||||
color: "orange"
|
color: "orange"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "Canvas"
|
text: "Canvas"
|
||||||
|
visible: !root.showMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -133,5 +140,14 @@ Item {
|
||||||
color: "white"
|
color: "white"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CanvasMenu {
|
||||||
|
anchors.fill:parent
|
||||||
|
visible: root.showMenu
|
||||||
|
onMenuBack: root.showMenu = false
|
||||||
|
onCloseCanvas: _application.closeCanvas(canvas);
|
||||||
|
onReconnectCanvas: canvas.reconnect();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
utils/fgqcanvas/qml/CanvasMenu.qml
Normal file
41
utils/fgqcanvas/qml/CanvasMenu.qml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
signal menuBack();
|
||||||
|
signal closeCanvas();
|
||||||
|
signal reconnectCanvas();
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: buttons.childrenRect.width + 20
|
||||||
|
height: buttons.childrenRect.height + 20
|
||||||
|
border.width: 1
|
||||||
|
border.color: "orange"
|
||||||
|
color: "#5f5f5f"
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: buttons
|
||||||
|
spacing: 30
|
||||||
|
|
||||||
|
Button {
|
||||||
|
label: qsTr("Back")
|
||||||
|
onClicked: root.menuBack();
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
label: qsTr("Close")
|
||||||
|
onClicked: root.closeCanvas();
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
label: qsTr("Reconnect")
|
||||||
|
onClicked: root.reconnectCanvas();
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
} // of buttons column
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,11 @@ Item {
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActiveFocusChanged: {
|
||||||
|
if (activeFocus) {
|
||||||
|
selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick 2.0
|
||||||
import FlightGear 1.0 as FG
|
import FlightGear 1.0 as FG
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
id: root
|
||||||
|
signal requestPanelClose();
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: savePanel
|
id: savePanel
|
||||||
|
@ -116,6 +118,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
_application.restoreConfig(model.index)
|
_application.restoreConfig(model.index)
|
||||||
|
root.requestPanelClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
drag.target: delegateFrame
|
drag.target: delegateFrame
|
||||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick 2.0
|
||||||
import FlightGear 1.0 as FG
|
import FlightGear 1.0 as FG
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
id: root
|
||||||
|
signal requestPanelClose();
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: savePanel
|
id: savePanel
|
||||||
|
@ -106,6 +108,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
_application.restoreSnapshot(model.index);
|
_application.restoreSnapshot(model.index);
|
||||||
|
root.requestPanelClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
drag.target: delegateFrame
|
drag.target: delegateFrame
|
||||||
|
|
|
@ -26,9 +26,15 @@ Item {
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
id: loader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: (activeTab >= 0) ? tabs[activeTab] : null
|
sourceComponent: (activeTab >= 0) ? tabs[activeTab] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: loader.item
|
||||||
|
onRequestPanelClose: root.activeTab = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -42,7 +48,7 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: splitterDrag
|
id: splitterDrag
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width* 3
|
width: parent.width * 25
|
||||||
|
|
||||||
drag.target: contentBox
|
drag.target: contentBox
|
||||||
drag.axis: Drag.XAxis
|
drag.axis: Drag.XAxis
|
||||||
|
|
|
@ -2,24 +2,21 @@ import QtQuick 2.0
|
||||||
import FlightGear 1.0 as FG
|
import FlightGear 1.0 as FG
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
property bool uiVisible: true
|
|
||||||
width: 1024
|
width: 1024
|
||||||
height: 768
|
height: 768
|
||||||
color: "black"
|
color: "black"
|
||||||
|
|
||||||
property double __uiOpacity: uiVisible ? 1.0 : 0.0
|
property double __uiOpacity: _application.showUI ? 1.0 : 0.0
|
||||||
property bool __uiVisible: true
|
property bool __uiVisible: true
|
||||||
|
|
||||||
Behavior on __uiOpacity {
|
Behavior on __uiOpacity {
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
ScriptAction { script: if (uiVisible) __uiVisible = true; }
|
ScriptAction { script: if (_application.showUI) __uiVisible = true; }
|
||||||
NumberAnimation { duration: 250 }
|
NumberAnimation { duration: 400 }
|
||||||
ScriptAction { script: if (!uiVisible) __uiVisible = false; }
|
ScriptAction { script: if (!_application.showUI) __uiVisible = false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: idleTimer.start();
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
opacity: __uiOpacity * 0.5
|
opacity: __uiOpacity * 0.5
|
||||||
source: "qrc:///images/checkerboard"
|
source: "qrc:///images/checkerboard"
|
||||||
|
@ -28,23 +25,6 @@ Rectangle {
|
||||||
visible: __uiVisible
|
visible: __uiVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
uiVisible = !uiVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
hoverEnabled: uiVisible
|
|
||||||
onMouseXChanged: idleTimer.restart()
|
|
||||||
onMouseYChanged: idleTimer.restart()
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: idleTimer
|
|
||||||
interval: 1000 * 10
|
|
||||||
onTriggered: { uiVisible = false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: _application.activeCanvases
|
model: _application.activeCanvases
|
||||||
delegate: CanvasFrame {
|
delegate: CanvasFrame {
|
||||||
|
|
Loading…
Add table
Reference in a new issue