diff options
-rw-r--r-- | src/DBusAPI.cpp | 18 | ||||
-rw-r--r-- | src/DBusAPI.h | 3 | ||||
-rw-r--r-- | src/Toast.qml | 13 | ||||
-rw-r--r-- | src/main.cpp | 19 | ||||
-rw-r--r-- | src/main.qml | 17 | ||||
-rw-r--r-- | src/main_qmladaptor.cpp | 20 | ||||
-rw-r--r-- | src/scenes/Scene_no_server_available.qml | 3 | ||||
-rw-r--r-- | src/scenes/Scene_placeholder.qml | 3 | ||||
-rw-r--r-- | src/scenes/Scene_remote_view.qml | 5 | ||||
-rw-r--r-- | src/scenes/Scene_settings.qml | 5 | ||||
-rw-r--r-- | src/scenes/add_server_wizard/Scene_step_1.qml | 15 |
11 files changed, 75 insertions, 46 deletions
diff --git a/src/DBusAPI.cpp b/src/DBusAPI.cpp index 760935b..83f38cb 100644 --- a/src/DBusAPI.cpp +++ b/src/DBusAPI.cpp @@ -60,7 +60,7 @@ void DBusAPI::start_request(RWAHost *host) { qDebug() << "Requesting D-Bus service to start a new session on host:" << host->alias(); - // Make an asynchrous 'start' call (Response will be sent to 'start_reply') + // Make an asynchronous 'start' call (Response will be sent to 'start_reply') QDBusPendingCall async = _dbus_rwa->asyncCall("start", host->uuid()); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -125,7 +125,7 @@ void DBusAPI::stop_request(RWAHost *host, QString session_id) { .arg(session_id) .arg(host->alias()); - // Make an asynchrous 'start' call (Response will be sent to 'stop_reply') + // Make an asynchronous 'stop' call (Response will be sent to 'stop_reply') QDBusPendingCall async = _dbus_rwa->asyncCall("stop", host->uuid(), session_id_number); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -182,14 +182,14 @@ void DBusAPI::status_request(RWAHost *host, QString session_id) { // Sanity Check if(ok == false){ - qWarning() << QString("Unable to parse '%0' as long long!").arg(session_id); + qWarning().noquote() << QString("Unable to parse session_id '%0' as long long!").arg(session_id); return; } qDebug().noquote() << QString("Requesting D-Bus service for status of session " "#'%0' on host '%1'").arg(session_id).arg(host->alias()); - // Make an asynchrous 'start' call (Response will be sent to 'status_reply') + // Make an asynchronous 'start' call (Response will be sent to 'status_reply') QDBusPendingCall async = _dbus_rwa->asyncCall("status", host->uuid(), session_id_number); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -213,14 +213,14 @@ void DBusAPI::refresh_status_request(RWAHost *host, QString session_id) { // Sanity Check if(ok == false){ - qWarning() << QString("Unable to parse '%0' as long long!").arg(session_id); + qWarning().noquote() << QString("Unable to parse session_id '%0' as long long!").arg(session_id); return; } qDebug().noquote() << QString("Requesting D-Bus service for refresh_status of session " "#'%0' on host '%1'").arg(session_id).arg(host->alias()); - // Make an asynchrous 'start' call (Response will be sent to 'status_reply') + // Make an asynchronous 'start' call (Response will be sent to 'status_reply') QDBusPendingCall async = _dbus_rwa->asyncCall("refresh_status", host->uuid(), session_id_number); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -269,7 +269,7 @@ void DBusAPI::get_web_app_hosts_request() { qDebug().noquote() << QString("Requesting D-Bus service to list " "all remote web app hosts"); - // Make an asynchrous 'get_web_app_hosts' call + // Make an asynchronous 'get_web_app_hosts' call // Response will be sent to 'get_web_app_hosts_reply' QDBusPendingCall async = _dbus_rwa->asyncCall("get_web_app_hosts"); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -291,7 +291,7 @@ void DBusAPI::add_web_app_host_request(QString host_url, QString host_alias) { qDebug().noquote() << QString("Requesting D-Bus service to register new " "remote web app host '%0' with url '%1'").arg(host_alias).arg(host_url); - // Make an asynchrous 'add_web_app_host' call + // Make an asynchronous 'add_web_app_host' call // Response will be sent to 'add_web_app_host_reply' QDBusPendingCall async = _dbus_rwa->asyncCall("add_web_app_host", host_url, host_alias); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); @@ -311,7 +311,7 @@ void DBusAPI::remove_web_app_host_request(QString host_uuid) { qDebug().noquote() << QString("Requesting D-Bus service to list " "all remote web app hosts"); - // Make an asynchrous 'remove_web_app_host' call + // Make an asynchronous 'remove_web_app_host' call // Response will be sent to 'remove_web_app_host_reply' QDBusPendingCall async = _dbus_rwa->asyncCall("remove_web_app_host", host_uuid); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); diff --git a/src/DBusAPI.h b/src/DBusAPI.h index a25fb64..63dbe68 100644 --- a/src/DBusAPI.h +++ b/src/DBusAPI.h @@ -32,8 +32,7 @@ #include "RWAHost.h" #include "RWADBusAdaptor.h" -class DBusAPI : public QObject -{ +class DBusAPI : public QObject { Q_OBJECT public: explicit DBusAPI(); diff --git a/src/Toast.qml b/src/Toast.qml index 60e238c..0de53a9 100644 --- a/src/Toast.qml +++ b/src/Toast.qml @@ -36,7 +36,8 @@ import QtQuick.Controls.Material 2.3 */ /** - * @brief An Android-like timed message text in a box that self-destroys when finished if desired + * @brief An Android-like timed message text in + * a box that self-destroys when finished if desired */ Control { @@ -52,16 +53,18 @@ Control { */ function show(text, duration) { message.text = text; - if (typeof duration !== "undefined") { // checks if parameter was passed + + // checks if parameter was passed + if (typeof duration !== "undefined") { time = Math.max(duration, 2 * fadeTime); - } - else { + } else { time = defaultTime; } animation.start(); } - property bool selfDestroying: false // whether this Toast will self-destroy when it is finished + // whether this Toast will self-destroy when it is finished + property bool selfDestroying: false /** * Private diff --git a/src/main.cpp b/src/main.cpp index bb83d45..7139883 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,13 +40,12 @@ #include "RWADBusAdaptor.cpp" #include "session.h" #include "scenes/add_server_wizard/add_server_wizard.h" +#include "scenes/remote_control/remote_control_manager.h" #include "RWAHostModel.h" #include "RWAHost.h" -#define BUILD_TIME __DATE__ " " __TIME__ - int main(int argc, char *argv[]) { - qDebug() << "This app was built on: " << BUILD_TIME; + qDebug() << "This app was built on: " << __DATE__ << __TIME__; // We don't want users to have multiple instances of this app running QString tmpDirPath = QDir::tempPath() + "/rwa.support.desktopapp"; @@ -85,8 +84,11 @@ int main(int argc, char *argv[]) { QScopedPointer<DBusAPI> dbus_api (new DBusAPI()); - // Make mainqmladaptor available to QML - QScopedPointer<MainQMLAdaptor> main_gui (new MainQMLAdaptor(&app, &engine, dbus_api.data())); + // Make 'mainqmladaptor' available to QML + QScopedPointer<MainQMLAdaptor> main_gui ( + new MainQMLAdaptor(&app, &engine, dbus_api.data()) + ); + engine.rootContext()->setContextProperty("mainqmladaptor", main_gui.data()); QObject::connect(dbus_api.data(), @@ -100,10 +102,6 @@ int main(int argc, char *argv[]) { if (engine.rootObjects().isEmpty()) return -1; - //QScopedPointer<RWAHost> rwa_host (new RWAHost("b9e09715-fe1d-4419-9b57-a0bd5b181ff0", "Lokaler Server", "http://localhost:8000")); - //QScopedPointer<Session> session (new Session(&app, main_gui.data(), rwa_host.data())); - //session.data()->start(); - QObject::connect(main_gui.data(), SIGNAL(minimizeWindow()), engine.rootObjects().takeFirst(), @@ -114,7 +112,8 @@ int main(int argc, char *argv[]) { engine.rootObjects().takeFirst(), SLOT(showWindow())); - QObject::connect(engine.rootObjects().takeFirst()->findChild<QObject*>("sidebar_drawer"), + QObject::connect(engine.rootObjects().takeFirst()-> + findChild<QObject*>("sidebar_drawer"), SIGNAL(rwaHostSelected(QString)), main_gui.data(), SLOT(onRwaHostSelected(QString))); diff --git a/src/main.qml b/src/main.qml index 102df11..03f9c5f 100644 --- a/src/main.qml +++ b/src/main.qml @@ -114,7 +114,7 @@ ApplicationWindow { Connections { target: mainqmladaptor - onShowMessageDialogChanged: { + function onShowMessageDialogChanged(show) { message_dialog.visible = show } } @@ -153,21 +153,21 @@ ApplicationWindow { Connections { target: mainqmladaptor - onMessageDialogTextChanged: { + function onMessageDialogTextChanged(text) { message_dialog.text = text } } Connections { target: mainqmladaptor - onMessageDialogTitleChanged: { + function onMessageDialogTitleChanged(title) { message_dialog.title = title } } Connections { target: mainqmladaptor - onMessageDialogIconChanged: { + function onMessageDialogIconChanged(iconindex) { message_dialog.icon = iconindex } } @@ -185,7 +185,9 @@ ApplicationWindow { objectName: "sidebar_drawer" y: top_menu_bar_frame.height - width: !inPortrait ? Math.min(300, Math.max(200, window.width * 0.333)) : (window.width * 0.5) + width: !inPortrait ? + Math.min(300, Math.max(200, window.width * 0.333)) : + (window.width * 0.5) height: window.height - top_menu_bar_frame.height modal: inPortrait @@ -286,7 +288,10 @@ ApplicationWindow { } // Disabled till a RWAHost object is selected. - enabled: sidebar_drawer.rwaHostIsSelected + //enabled: sidebar_drawer.rwaHostIsSelected + + // But remote view is not implemented yet + enabled: false } ListItem { text: " " + qsTr("Add RWA-Server") diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp index 6d3a60c..7e85157 100644 --- a/src/main_qmladaptor.cpp +++ b/src/main_qmladaptor.cpp @@ -129,8 +129,8 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) { if (host_url == "" || host_uuid == "") { // This two values are required and can't be omitted. - QString reason = tr("A host object in the response of D-Bus " - "service lacks a necessary value. (host_url or host_uuid)"); + QString reason = tr("A host object in the response of D-Bus service lacks" + " a necessary value. (host_url or host_uuid)"); qCritical().noquote() << tr("An error occured while adding a new host:") << reason; @@ -162,7 +162,8 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) { atLeastOneHostAvailable = true; if (!found) { - qInfo().noquote() << QString(tr("Successfully added new RWAHost '%0'")).arg(rwa_host->alias()); + qInfo().noquote() << QString(tr("Successfully added new RWAHost '%0'")) + .arg(rwa_host->alias()); addRWAHost(rwa_host); } } @@ -233,7 +234,8 @@ void MainQMLAdaptor::main_content_pop(QString scene) { QObject *window = _engine->rootObjects().takeFirst(); Q_ASSERT(window != nullptr); - QObject *main_content = _engine->rootObjects().takeFirst()->findChild<QObject*>("main_content"); + QObject *main_content = _engine->rootObjects().takeFirst()-> + findChild<QObject*>("main_content"); Q_ASSERT(main_content != nullptr); QVariant to_cast = main_content->property("currentItem"); @@ -252,17 +254,21 @@ void MainQMLAdaptor::main_content_replace(QString scene) { QObject *window = _engine->rootObjects().takeFirst(); Q_ASSERT(window != nullptr); - QObject *main_content = _engine->rootObjects().takeFirst()->findChild<QObject*>("main_content"); + QObject *main_content = _engine->rootObjects().takeFirst()-> + findChild<QObject*>("main_content"); Q_ASSERT(main_content != nullptr); QVariant to_cast = main_content->property("currentItem"); QObject *obj = qvariant_cast<QObject *>(to_cast); if (obj) { QString scene_add_server_wizard = "Scene_step_1"; - if (!(scene.contains(obj->objectName()) || scene_add_server_wizard.contains(obj->objectName()))) { + if (!(scene.contains(obj->objectName()) || + scene_add_server_wizard.contains(obj->objectName()))) { QVariant arg = QVariant::fromValue(scene); - if(!QMetaObject::invokeMethod(window, "main_content_replace", Q_ARG(QVariant, arg))) + if (!QMetaObject::invokeMethod(window, "main_content_replace", + Q_ARG(QVariant, arg))) { qDebug() << "Failed to invoke replace"; + } } } } diff --git a/src/scenes/Scene_no_server_available.qml b/src/scenes/Scene_no_server_available.qml index 112c6e0..7b99b55 100644 --- a/src/scenes/Scene_no_server_available.qml +++ b/src/scenes/Scene_no_server_available.qml @@ -6,7 +6,8 @@ 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). + * This .qml file is a Scene which can be loaded through for + * example a StackView (main_content in main.qml). */ Item { diff --git a/src/scenes/Scene_placeholder.qml b/src/scenes/Scene_placeholder.qml index 29e15a9..f492e00 100644 --- a/src/scenes/Scene_placeholder.qml +++ b/src/scenes/Scene_placeholder.qml @@ -6,7 +6,8 @@ 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). + * This .qml file is a Scene which can be loaded through for + * example a StackView (main_content in main.qml). */ Item { diff --git a/src/scenes/Scene_remote_view.qml b/src/scenes/Scene_remote_view.qml index cea5ccf..436d8aa 100644 --- a/src/scenes/Scene_remote_view.qml +++ b/src/scenes/Scene_remote_view.qml @@ -5,6 +5,11 @@ 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_remote_view objectName: "Scene_remote_view" diff --git a/src/scenes/Scene_settings.qml b/src/scenes/Scene_settings.qml index 5a29071..e2f89da 100644 --- a/src/scenes/Scene_settings.qml +++ b/src/scenes/Scene_settings.qml @@ -5,6 +5,11 @@ 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_settings objectName: "Scene_settings" diff --git a/src/scenes/add_server_wizard/Scene_step_1.qml b/src/scenes/add_server_wizard/Scene_step_1.qml index abd761d..e57f8a4 100644 --- a/src/scenes/add_server_wizard/Scene_step_1.qml +++ b/src/scenes/add_server_wizard/Scene_step_1.qml @@ -5,7 +5,8 @@ import QtQuick.Controls 2.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). + * This .qml file is a Scene which can be loaded through for + * example a StackView (main_content in main.qml). */ Item { @@ -14,17 +15,21 @@ Item { Connections { target: add_server_wizard - onStep1Success: { + function onStep1Success() { // Go onto the first page of the stack. main_content_pop(null) - mainqmladaptor.showToast(qsTr("Successfully added remote web app host."), 5000); + mainqmladaptor.showToast(qsTr("Successfully added remote web app host."), + 5000, + ToastType.ToastSuccess); } } Connections { target: add_server_wizard - onStep1Failed: { - mainqmladaptor.showToast(reason, 3000); + function onStep1Failed(reason, toast_type) { + mainqmladaptor.showToast(reason, + 5000, + toast_type) } } |