aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp14
-rw-r--r--src/main_qmladaptor.cpp5
-rw-r--r--src/main_qmladaptor.h4
-rw-r--r--src/scenes/add_server_wizard/add_server_wizard.cpp6
4 files changed, 20 insertions, 9 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a72e42b..7f86b6d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -83,16 +83,18 @@ int main(int argc, char *argv[]) {
QQmlApplicationEngine engine(&app);
+ QScopedPointer<DBusAPI> dbus_api (new DBusAPI());
+
// Make mainqmladaptor available to QML
- QScopedPointer<MainQMLAdaptor> main_gui (new MainQMLAdaptor(&app, &engine));
+ QScopedPointer<MainQMLAdaptor> main_gui (new MainQMLAdaptor(&app, &engine, dbus_api.data()));
engine.rootContext()->setContextProperty("mainqmladaptor", main_gui.data());
- QScopedPointer<DBusAPI> _dbus_api (new DBusAPI());
- QObject::connect(_dbus_api.data(),
+ QObject::connect(dbus_api.data(),
SIGNAL(serviceGetWebAppHostsResponse(QJsonDocument*)),
main_gui.data(),
SLOT(get_web_app_hosts_response(QJsonDocument*)));
- _dbus_api.data()->get_web_app_hosts_request();
+ dbus_api.data()->get_web_app_hosts_request();
+
engine.load(QUrl(QStringLiteral("qrc:/src/main.qml")));
if (engine.rootObjects().isEmpty())
@@ -116,7 +118,9 @@ int main(int argc, char *argv[]) {
SLOT(onRwaHostSelected(QString)));
// Make add_server_wizard available to QML
- QScopedPointer<Add_Server_wizard> wizard (new Add_Server_wizard(&app, main_gui.data()));
+ QScopedPointer<Add_Server_wizard> wizard (new Add_Server_wizard(&app,
+ main_gui.data(),
+ dbus_api.data()));
engine.rootContext()->setContextProperty("add_server_wizard", wizard.data());
return app.exec();
diff --git a/src/main_qmladaptor.cpp b/src/main_qmladaptor.cpp
index c1d3f14..2dec33c 100644
--- a/src/main_qmladaptor.cpp
+++ b/src/main_qmladaptor.cpp
@@ -26,10 +26,13 @@
#include "main_qmladaptor.h"
-MainQMLAdaptor::MainQMLAdaptor(QObject *parent, QQmlApplicationEngine* engine) : QObject(parent) {
+MainQMLAdaptor::MainQMLAdaptor(QObject *parent, QQmlApplicationEngine* engine,
+ DBusAPI *dbus_api) : QObject(parent) {
Q_ASSERT(engine != nullptr);
+ Q_ASSERT(dbus_api != nullptr);
_engine = engine;
+ _dbus_api = dbus_api;
_rwaHostModel = new QList<QObject*>;
}
diff --git a/src/main_qmladaptor.h b/src/main_qmladaptor.h
index a289a74..48923d5 100644
--- a/src/main_qmladaptor.h
+++ b/src/main_qmladaptor.h
@@ -37,6 +37,7 @@
#include <QJsonArray>
#include "RWAHost.h"
+#include "DBusAPI.h"
class MainQMLAdaptor : public QObject
{
@@ -59,7 +60,8 @@ class MainQMLAdaptor : public QObject
Q_PROPERTY(QMessageBox::Icon _messageDialogIcon READ getMessageDialogIcon NOTIFY messageDialogIconChanged)
public:
- explicit MainQMLAdaptor(QObject *parent, QQmlApplicationEngine *engine = nullptr);
+ explicit MainQMLAdaptor(QObject *parent, QQmlApplicationEngine *engine = nullptr,
+ DBusAPI *dbus_api = nullptr);
void setRWAHostModel(QList<QObject*> *rwa_hosts);
diff --git a/src/scenes/add_server_wizard/add_server_wizard.cpp b/src/scenes/add_server_wizard/add_server_wizard.cpp
index 09db898..a5bee47 100644
--- a/src/scenes/add_server_wizard/add_server_wizard.cpp
+++ b/src/scenes/add_server_wizard/add_server_wizard.cpp
@@ -27,10 +27,12 @@
#include "../../RWADBusAdaptor.h"
#include "../../RWAHost.h"
-Add_Server_wizard::Add_Server_wizard(QObject *parent, MainQMLAdaptor *main_gui) : QObject(parent) {
+Add_Server_wizard::Add_Server_wizard(QObject *parent,
+ MainQMLAdaptor *main_gui, DBusAPI *dbus_api) : QObject(parent) {
Q_ASSERT(main_gui != nullptr);
+ Q_ASSERT(dbus_api != nullptr);
- _dbus_api = new DBusAPI();
+ _dbus_api = dbus_api;
_main_gui = main_gui;
// _dbus_api --serviceAddWebAppHostResponse-> this.add_web_app_host_response()