diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-07-08 15:54:20 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-07-08 15:54:20 +0200 |
commit | 0f73c7ff3f8a84bcacf077644d6a199301f58945 (patch) | |
tree | 272431fb633d18803ac73dbb6aeff881496e5bb2 /src/scenes | |
parent | dc3b77a1e3c8b8ff9a9299fd17c13b0428f1fa14 (diff) | |
download | RWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.tar.gz RWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.tar.bz2 RWA.Support.DesktopApp-0f73c7ff3f8a84bcacf077644d6a199301f58945.zip |
User can decide on host_alias now.
Diffstat (limited to 'src/scenes')
-rw-r--r-- | src/scenes/add_server_wizard/Scene_step_1.qml | 105 | ||||
-rw-r--r-- | src/scenes/add_server_wizard/add_server_wizard.cpp | 43 | ||||
-rw-r--r-- | src/scenes/add_server_wizard/add_server_wizard.h | 7 |
3 files changed, 112 insertions, 43 deletions
diff --git a/src/scenes/add_server_wizard/Scene_step_1.qml b/src/scenes/add_server_wizard/Scene_step_1.qml index a80e4f4..abd761d 100644 --- a/src/scenes/add_server_wizard/Scene_step_1.qml +++ b/src/scenes/add_server_wizard/Scene_step_1.qml @@ -42,11 +42,11 @@ Item { anchors.rightMargin: 15 onClicked: { - add_server_wizard.processStep1(host_url.text) + add_server_wizard.processStep1(host_url.text, host_alias.text) } } - Text { + /*Text { color: Material.foreground id: step_indicator @@ -61,7 +61,7 @@ Item { horizontalAlignment: Text.AlignHCenter anchors.left: parent.left anchors.margins: 5 - } + }*/ Text { color: Material.foreground @@ -74,12 +74,12 @@ Item { "administrator about it please.\nBefore you can "+ "start any remote sessions you will have to "+ "be approved for remote support.") - font.pointSize: 13 + font.pointSize: 12 anchors.right: parent.right anchors.rightMargin: 15 anchors.leftMargin: 15 - anchors.top: step_indicator.bottom - anchors.topMargin: 30 + anchors.top: parent.top //step_indicator.bottom + anchors.topMargin: 15 wrapMode: Text.WordWrap anchors.left: parent.left @@ -160,7 +160,7 @@ Item { Text { color: Material.foreground - text: qsTr("RWA-server address") + text: qsTr("RWA host address") anchors.left: parent.left anchors.leftMargin: 15 anchors.verticalCenterOffset: - host_url.height / 2 @@ -176,6 +176,97 @@ Item { } } } + + TextField { + id: host_alias + selectByMouse: true + placeholderText: qsTr("My example host") + + font.pixelSize: 16 + color: Material.foreground + + padding: 15 + topPadding: 15 + + anchors.top: host_url.bottom + anchors.topMargin: 30 + anchors.left: parent.left + anchors.leftMargin: 15 + anchors.right: parent.right + anchors.margins: 30 + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onHoveredChanged: { + if (containsMouse) { + host_alias_background.state = "hovered" + } else if (!host_alias.focus) { + host_alias_background.state = "unhovered" + } + } + onClicked: { + host_alias.forceActiveFocus(); + } + } + + onFocusChanged: { + host_alias_background.state = host_alias.focus ? "hovered" : "unhovered" + } + + background: Rectangle { + id: host_alias_background + color: Material.background + border.color: Material.foreground + border.width: 1 + radius: 4 + + states: [ + State { + name: "hovered" + PropertyChanges { + target: host_alias_background + border.color: "#0178EF" + } + }, + State { + name: "unhovered" + PropertyChanges { + target: host_alias_background + border.color: Material.foreground + } + } + ] + transitions: [ + Transition { + from: "*" + to: "*" + PropertyAnimation { + property: "border.color" + duration: 100 + easing.type: Easing.Linear + } + } + ] + + Text { + color: Material.foreground + text: qsTr("RWA host alias") + anchors.left: parent.left + anchors.leftMargin: 15 + anchors.verticalCenterOffset: - host_alias.height / 2 + anchors.verticalCenter: parent.verticalCenter + leftPadding: 5 + + Rectangle { + color: Material.background + width: parent.width + 5 + 3 + height: parent.height + z: -1 + } + } + } + } } } diff --git a/src/scenes/add_server_wizard/add_server_wizard.cpp b/src/scenes/add_server_wizard/add_server_wizard.cpp index d06108c..09db898 100644 --- a/src/scenes/add_server_wizard/add_server_wizard.cpp +++ b/src/scenes/add_server_wizard/add_server_wizard.cpp @@ -40,15 +40,17 @@ Add_Server_wizard::Add_Server_wizard(QObject *parent, MainQMLAdaptor *main_gui) SLOT(add_web_app_host_response(QJsonDocument*))); } -void Add_Server_wizard::processStep1(QString host_url) { - qDebug() << "Processing Step 1 with args: " << host_url; +void Add_Server_wizard::processStep1(QString host_url, QString host_alias) { + qDebug() << "Processing Step 1 with args: " << host_url << host_alias; - if(host_url == "") { - emit step1Failed(tr("This field can't be empty!")); + if(host_alias == "" || host_url == "") { + QString reason = tr("Both textfields can't be empty!"); + emit step1Failed(reason); + qDebug().noquote() << reason; return; } - return add_server(host_url); + return add_server(host_url, host_alias); } void Add_Server_wizard::processStep2() { @@ -58,8 +60,8 @@ void Add_Server_wizard::processStep2() { emit step2Success(); } -void Add_Server_wizard::add_server(QString host_url) { - _dbus_api->add_web_app_host_request(host_url); +void Add_Server_wizard::add_server(QString host_url, QString host_alias) { + _dbus_api->add_web_app_host_request(host_url, host_alias); } void Add_Server_wizard::add_web_app_host_response(QJsonDocument *doc) { @@ -70,32 +72,7 @@ void Add_Server_wizard::add_web_app_host_response(QJsonDocument *doc) { // Status of request QString request_status = mainMap["status"].toString(); if (request_status == "success") { - // Building host_object - QJsonObject host_object = jObject.value(QString("host")).toObject(); - - QString host_uuid = host_object["uuid"].toString(); - QString host_alias = host_object["alias"].toString(); - QString host_url = host_object["url"].toString(); - - if (host_url == "" || host_uuid == "") { - // This two values are required and can't be omitted. - QString reason = tr("Response of D-Bus service lacks necessary host object."); - qCritical().noquote() << tr("An error occured while adding a new host:") - << reason; - emit step1Failed(reason); - - return; - } - - if (host_alias == "") { - qDebug().noquote() << QString("An alias for the host wasn't delivered " - "so just use '%0' as alias.").arg(host_url); - host_alias = host_url; - } - - // Now built RWAHost object. - QScopedPointer<RWAHost> rwa_host (new RWAHost(host_uuid, host_alias, host_url)); - _main_gui->addRWAHost(rwa_host.data()); + _dbus_api->get_web_app_hosts_request(); qInfo() << "Successfully added a new RWAHost."; emit step1Success(); diff --git a/src/scenes/add_server_wizard/add_server_wizard.h b/src/scenes/add_server_wizard/add_server_wizard.h index e4d62df..03af824 100644 --- a/src/scenes/add_server_wizard/add_server_wizard.h +++ b/src/scenes/add_server_wizard/add_server_wizard.h @@ -37,8 +37,9 @@ class Add_Server_wizard : public QObject Q_OBJECT public: explicit Add_Server_wizard(QObject *parent = nullptr, - MainQMLAdaptor *main_gui = nullptr); - void add_server(QString host_url); + MainQMLAdaptor *main_gui = nullptr, + DBusAPI *dbus_api = nullptr); + void add_server(QString host_url, QString host_alias); private: DBusAPI *_dbus_api; @@ -51,7 +52,7 @@ signals: void step2Failed(QString reason); public slots: - void processStep1(QString host_url); + void processStep1(QString host_url, QString host_alias); void processStep2(); void add_web_app_host_response(QJsonDocument *doc); |