aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-08 15:50:22 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-08 15:50:46 +0200
commitdc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14 (patch)
treef21a172dbc7e4ff1d304276a4025dfbe8973a6c4
parent0ed25cd9cd46ba4c3f64eb5e8866becaa07f5344 (diff)
downloadRWA.Support.DesktopApp-dc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14.tar.gz
RWA.Support.DesktopApp-dc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14.tar.bz2
RWA.Support.DesktopApp-dc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14.zip
Add: 'Scene_no_server_available.qml'
-rw-r--r--qml.qrc1
-rw-r--r--src/main.qml56
-rw-r--r--src/main_qmladaptor.cpp50
-rw-r--r--src/main_qmladaptor.h15
-rw-r--r--src/scenes/Scene_no_server_available.qml70
5 files changed, 163 insertions, 29 deletions
diff --git a/qml.qrc b/qml.qrc
index 07b6bd2..b472fe7 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -29,6 +29,7 @@
<file>src/scenes/Scene_remote_view.qml</file>
<file>src/scenes/Scene_settings.qml</file>
<file>src/scenes/Scene_placeholder.qml</file>
+ <file>src/scenes/Scene_no_server_available.qml</file>
<file>src/scenes/add_server_wizard/Scene_step_1.qml</file>
<file>src/scenes/add_server_wizard/add_server_wizard.cpp</file>
<file>src/scenes/add_server_wizard/add_server_wizard.h</file>
diff --git a/src/main.qml b/src/main.qml
index 12c4668..4494526 100644
--- a/src/main.qml
+++ b/src/main.qml
@@ -66,25 +66,25 @@ ApplicationWindow {
console.log("Opening window now...");
}
- function main_content_pop(item, operation) {
+ function main_content_pop(item) {
if(item) {
if(item.search(main_content.currentItem.objectName) >= 0) return
}
- return main_content.pop(item, operation)
+ return main_content.pop(item)
}
- function main_content_push(item, operation) {
+ function main_content_push(item) {
if(item) {
if(item.search(main_content.currentItem.objectName) >= 0) return
}
- return main_content.push(item, operation)
+ return main_content.push(item)
}
- function main_content_replace(item, operation) {
+ function main_content_replace(item) {
if(item) {
if(item.search(main_content.currentItem.objectName) >= 0) return
}
- return main_content.replace(item, operation)
+ return main_content.replace(item)
}
MessageDialog {
@@ -206,18 +206,29 @@ ApplicationWindow {
anchors.fill: parent
model: mainModel
- header: ComboBox {
- id: server_chooser
- objectName: "server_chooser"
- width: parent.width
+ header: Rectangle {
height: 50
- model: mainqmladaptor.rwaHostModel
- textRole: "alias"
+ width: parent.width
+ color: Material.background
+
+ ComboBox {
+ id: server_chooser
+ objectName: "server_chooser"
+
+ padding: 0
+ width: parent.width
+ height: 56 - y
+ y: -6
+ clip: false
+
+ model: mainqmladaptor.rwaHostModel
+ textRole: "alias"
- onCurrentIndexChanged: {
- var rwa_host = mainqmladaptor.rwaHostModel
- sidebar_drawer.rwaHostSelected(rwa_host[currentIndex].uuid)
- sidebar_drawer.rwaHostIsSelected = true
+ onCurrentIndexChanged: {
+ var rwa_host = mainqmladaptor.rwaHostModel
+ if (rwa_host[currentIndex] !== undefined)
+ sidebar_drawer.rwaHostSelected(rwa_host[currentIndex].uuid)
+ }
}
}
@@ -225,13 +236,15 @@ ApplicationWindow {
id: footer
text: " " + qsTr("Settings")
width: parent.width
+ enabled: false
onClicked: {
var scene_url = "scenes/Scene_placeholder.qml"
header_text.text = qsTr("Settings")
if(inPortrait) sidebar_drawer.close()
- main_content_replace(scene_url, StackView.Transition)
+ if(scene_url.search(main_content.currentItem.objectName) >= 0) return
+ main_content.replace(scene_url, StackView.Transition)
}
MenuSeparator {
@@ -251,7 +264,8 @@ ApplicationWindow {
header_text.text = qsTr("Allow remote control")
if(inPortrait) sidebar_drawer.close()
- main_content_replace(scene_url, StackView.Transition)
+ if(scene_url.search(main_content.currentItem.objectName) >= 0) return
+ main_content.replace(scene_url, StackView.Transition)
}
// Disabled till a RWAHost object is selected.
@@ -264,7 +278,8 @@ ApplicationWindow {
header_text.text = qsTr("Allow remote view")
if(inPortrait) sidebar_drawer.close()
- main_content_replace(scene_url, StackView.Transition)
+ if(scene_url.search(main_content.currentItem.objectName) >= 0) return
+ main_content.replace(scene_url, StackView.Transition)
}
// Disabled till a RWAHost object is selected.
@@ -277,7 +292,8 @@ ApplicationWindow {
header_text.text = qsTr("Server addition wizard")
if(inPortrait) sidebar_drawer.close()
- main_content_push(scene_url, StackView.ReplaceTransition)
+ if(scene_url.search(main_content.currentItem.objectName) >= 0) return
+ main_content.push(scene_url, StackView.ReplaceTransition)
}
}
}
diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp
index 5fcce5f..c1d3f14 100644
--- a/src/main_qmladaptor.cpp
+++ b/src/main_qmladaptor.cpp
@@ -49,12 +49,19 @@ void MainQMLAdaptor::onRwaHostSelected(QString host_uuid) {
Q_ASSERT(_host != nullptr);
qDebug() << "RWAHost was selected!" << _host->uuid() << "aka" << _host->alias();
-}
-void MainQMLAdaptor::setRWAHostModel(QList<QObject*> rwa_hosts) {
+ // Find item via 'objectName'
+ QObject *sidebar_drawer = _engine->rootObjects().takeFirst()->findChild<QObject*>("sidebar_drawer");
+ if (sidebar_drawer) {
+ sidebar_drawer->setProperty("rwaHostIsSelected", true);
+ } else {
+ qWarning() << "Unable to find 'sidebar_drawer' Item!";
+ }
+}
- _rwaHostModel = &rwa_hosts;
- emit rwaHostModelChanged(rwa_hosts);
+void MainQMLAdaptor::setRWAHostModel(QList<QObject*> *rwa_hosts) {
+ _rwaHostModel = rwa_hosts;
+ emit rwaHostModelChanged(*rwa_hosts);
}
void MainQMLAdaptor::addRWAHost(RWAHost *rwa_host) {
@@ -69,6 +76,10 @@ QList<QObject*> MainQMLAdaptor::getRWAHostModel() {
void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) {
Q_ASSERT(doc != nullptr);
+ delete _rwaHostModel;
+ setRWAHostModel(new QList<QObject*>);
+ bool atLeastOneHostAvailable = false;
+
// Get the QJsonObject
QJsonObject jObject = doc->object();
QVariantMap mainMap = jObject.toVariantMap();
@@ -90,7 +101,6 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) {
"service lacks a necessary value. (host_url or host_uuid)");
qCritical().noquote() << tr("An error occured while adding a new host:")
<< reason;
- //emit step1Failed(reason);
return;
}
@@ -104,6 +114,7 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) {
// Now built RWAHost object.
RWAHost *rwa_host = new RWAHost(host_uuid, host_alias, host_url);
addRWAHost(rwa_host);
+ atLeastOneHostAvailable = true;
qInfo().noquote() << QString(tr("Successfully added new RWAHost '%0'")).arg(rwa_host->alias());
}
@@ -124,6 +135,35 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) {
return;
}
+
+ if (!atLeastOneHostAvailable) {
+ main_content_replace("scenes/Scene_no_server_available.qml");
+ //addRWAHost(new RWAHost("-","Kein Server verfügbar!","-"));
+ }
+}
+
+void MainQMLAdaptor::main_content_push(QString scene) {
+ // Find item via 'objectName'
+ QObject *main_content = _engine->rootObjects().takeFirst()->findChild<QObject*>("main_content");
+ Q_ASSERT(main_content != nullptr);
+ QMetaObject::invokeMethod(main_content, "push", Q_ARG(QString, scene));
+}
+
+void MainQMLAdaptor::main_content_pop(QString scene) {
+ // Find item via 'objectName'
+ QObject *main_content = _engine->rootObjects().takeFirst()->findChild<QObject*>("main_content");
+ Q_ASSERT(main_content != nullptr);
+ QMetaObject::invokeMethod(main_content, "pop", Q_ARG(QString, scene));
+}
+
+void MainQMLAdaptor::main_content_replace(QString scene) {
+ // Find item via 'objectName'
+ QObject *window = _engine->rootObjects().takeFirst();
+ Q_ASSERT(window != nullptr);
+
+ QVariant arg = QVariant::fromValue(scene);
+ if(!QMetaObject::invokeMethod(window, "main_content_replace", Q_ARG(QVariant, arg)))
+ qDebug() << "Failed to invoke push";
}
bool MainQMLAdaptor::setConnectButtonEnabled(bool enabled) {
diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h
index 05de1fd..a289a74 100644
--- a/src/main_qmladaptor.h
+++ b/src/main_qmladaptor.h
@@ -42,7 +42,7 @@ class MainQMLAdaptor : public QObject
{
Q_OBJECT
// this makes url available as a QML property
- Q_PROPERTY(QList<QObject*> rwaHostModel READ getRWAHostModel WRITE setRWAHostModel NOTIFY rwaHostModelChanged)
+ Q_PROPERTY(QList<QObject*> rwaHostModel READ getRWAHostModel NOTIFY rwaHostModelChanged)
// this makes url available as a QML property
Q_PROPERTY(QString url READ getURL WRITE setURL NOTIFY urlChanged)
// this makes pin available as a QML property
@@ -61,11 +61,15 @@ class MainQMLAdaptor : public QObject
public:
explicit MainQMLAdaptor(QObject *parent, QQmlApplicationEngine *engine = nullptr);
-// void setSession(Session session);
+ void setRWAHostModel(QList<QObject*> *rwa_hosts);
bool setConnectButtonEnabled(bool enabled);
bool setConnectButtonChecked(bool checked);
+ void main_content_push(QString);
+ void main_content_pop(QString);
+ void main_content_replace(QString);
+
bool setStatusIndicator(bool active, QColor color = QColor(255,255,255));
bool setStatus(QString status);
@@ -100,7 +104,8 @@ protected:
QString _url;
QString _pin;
QString _session_id;
- QList<QObject*>* _rwaHostModel;
+ DBusAPI *_dbus_api;
+ QList<QObject*> *_rwaHostModel;
private:
QQmlApplicationEngine* _engine;
@@ -119,11 +124,13 @@ public slots:
void setPin(QString pin);
void setURL(QString URL);
void setSessionID(QString session_id);
- void setRWAHostModel(QList<QObject*>);
void addRWAHost(RWAHost *rwa_host);
QString getURL();
QString getPin();
QString getSessionID();
+
+ // No pointer because QML doesn't
+ // like this type much with pointer
QList<QObject*> getRWAHostModel();
void onRwaHostSelected(QString host_uuid);
diff --git a/src/scenes/Scene_no_server_available.qml b/src/scenes/Scene_no_server_available.qml
new file mode 100644
index 0000000..112c6e0
--- /dev/null
+++ b/src/scenes/Scene_no_server_available.qml
@@ -0,0 +1,70 @@
+import QtQuick 2.9
+import QtQuick.Window 2.2
+import QtQuick.Extras 1.4
+import QtQuick.Controls 2.2
+import QtQuick.Dialogs 1.2
+import QtQuick.Controls.Material 2.3
+
+/*!
+ This .qml file is a Scene which can be loaded through for example a StackView (main_content in main.qml).
+ */
+
+Item {
+ id: scene_no_server_available
+ objectName: "Scene_no_server_available"
+
+ Rectangle {
+ id: rectangle
+ anchors.fill: parent
+ color: Material.background
+
+ Text {
+ color: Material.foreground
+ id: title
+
+ text: qsTr("Welcome!")
+ font.pointSize: 20
+ font.bold: true
+ wrapMode: Text.WordWrap
+
+ horizontalAlignment: Text.AlignLeft
+
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 15
+ }
+
+ Text {
+ color: Material.foreground
+ anchors.top: title.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 15
+
+ horizontalAlignment: Text.AlignLeft
+ wrapMode: Text.WordWrap
+ /*: 'Add RWA-Server' has to be replaced with the correct translation in file main.qml .*/
+ font.pointSize: 13
+ text: qsTr("You need to add and select the remote \
+web app server to which you want to connect. \
+You can see a button to the left in the menu \
+which says 'Add RWA-Server'. Follow the steps \
+listed there and you can start your remote \
+support session afterwards using the buttons \
+above 'Add RWA-Server'.")
+ }
+ }
+}
+
+
+
+
+
+
+
+/*##^## Designer {
+ D{i:0;autoSize:true;height:480;width:640}
+}
+ ##^##*/