From 0ed25cd9cd46ba4c3f64eb5e8866becaa07f5344 Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Wed, 7 Jul 2021 15:42:42 +0200 Subject: Various small improvements to readability --- src/main.cpp | 4 ++-- src/main.qml | 2 +- src/main_qmladaptor.cpp | 19 ++++++++----------- src/main_qmladaptor.h | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b85c3fc..a72e42b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ #include #include +#include "DBusAPI.h" #include "RWADBusAdaptor.cpp" #include "session.h" #include "scenes/add_server_wizard/add_server_wizard.h" @@ -82,9 +83,8 @@ int main(int argc, char *argv[]) { QQmlApplicationEngine engine(&app); - QScopedPointer main_gui (new MainQMLAdaptor(&app, &engine)); - // Make mainqmladaptor available to QML + QScopedPointer main_gui (new MainQMLAdaptor(&app, &engine)); engine.rootContext()->setContextProperty("mainqmladaptor", main_gui.data()); QScopedPointer _dbus_api (new DBusAPI()); diff --git a/src/main.qml b/src/main.qml index 8a19d54..12c4668 100644 --- a/src/main.qml +++ b/src/main.qml @@ -212,8 +212,8 @@ ApplicationWindow { width: parent.width height: 50 model: mainqmladaptor.rwaHostModel - textRole: "alias" + onCurrentIndexChanged: { var rwa_host = mainqmladaptor.rwaHostModel sidebar_drawer.rwaHostSelected(rwa_host[currentIndex].uuid) diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp index d75b15c..5fcce5f 100644 --- a/src/main_qmladaptor.cpp +++ b/src/main_qmladaptor.cpp @@ -128,7 +128,8 @@ void MainQMLAdaptor::get_web_app_hosts_response(QJsonDocument *doc) { bool MainQMLAdaptor::setConnectButtonEnabled(bool enabled) { // Find item via 'objectName' - QQuickItem *item = _engine->rootObjects().at(0)->findChild("start_support_button"); + QQuickItem *scene_remote_control = _engine->rootObjects().at(0)->findChild("Scene_remote_control"); + QQuickItem *item = scene_remote_control->findChild("start_support_button"); if (item) { item->setProperty("enabled", enabled); if (item->property("checked").toBool()) { @@ -146,7 +147,8 @@ bool MainQMLAdaptor::setConnectButtonEnabled(bool enabled) { bool MainQMLAdaptor::setConnectButtonChecked(bool checked) { // Find item via 'objectName' - QQuickItem *item = _engine->rootObjects().at(0)->findChild("start_support_button"); + QQuickItem *scene_remote_control = _engine->rootObjects().at(0)->findChild("Scene_remote_control"); + QQuickItem *item = scene_remote_control->findChild("start_support_button"); if (item) { item->setProperty("checked", checked); } else { @@ -159,7 +161,8 @@ bool MainQMLAdaptor::setConnectButtonChecked(bool checked) { bool MainQMLAdaptor::setStatus(QString status) { // Find item via 'objectName' - QQuickItem *item = _engine->rootObjects().at(0)->findChild("dbus_api_status_text"); + QQuickItem *scene_remote_control = _engine->rootObjects().at(0)->findChild("Scene_remote_control"); + QQuickItem *item = scene_remote_control->findChild("dbus_api_status_text"); if (item) { item->setProperty("text", status); } else { @@ -203,7 +206,8 @@ bool MainQMLAdaptor::getShowMessageDialog() { bool MainQMLAdaptor::setStatusIndicator(bool active, QColor color) { // Find item via 'objectName' - QQuickItem *item = _engine->rootObjects().at(0)->findChild("dbus_api_status_indicator"); + QQuickItem *scene_remote_control = _engine->rootObjects().at(0)->findChild("Scene_remote_control"); + QQuickItem *item = scene_remote_control->findChild("dbus_api_status_indicator"); if (item) { item->setProperty("active", active); item->setProperty("color", color); @@ -256,10 +260,3 @@ void MainQMLAdaptor::onCloseHandler() { void MainQMLAdaptor::showToast(QString text, uint durationMs) { emit showToastSignal(text, QString::number(durationMs)); } - -//void MainQMLAdaptor::onCloseHandler() { -// qDebug() << "Inside MainQMLAdaptor::onCloseHandler()"; - -// // Sending onClose signal to main and there to Session::onCloseHandler() -// emit MainQMLAdaptor::onCloseSignal(); -//} diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h index 8701fc9..05de1fd 100644 --- a/src/main_qmladaptor.h +++ b/src/main_qmladaptor.h @@ -61,7 +61,7 @@ class MainQMLAdaptor : public QObject public: explicit MainQMLAdaptor(QObject *parent, QQmlApplicationEngine *engine = nullptr); -// void setSession(Session session); +// void setSession(Session session); bool setConnectButtonEnabled(bool enabled); bool setConnectButtonChecked(bool checked); -- cgit v1.2.3