summaryrefslogtreecommitdiff
path: root/controller.cxx
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-07 15:40:47 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-07 15:40:47 +0800
commit16bc24b796de76ec1a5fa66dcfe2129a2b02d370 (patch)
treecc27194eca692f7a77adb86c723e25e34dfaeac8 /controller.cxx
parent48895cf915d4c1be2534588f18f58ea78079d6ae (diff)
Changed controller's parent to the engine
to give more flexibility
Diffstat (limited to 'controller.cxx')
-rw-r--r--controller.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/controller.cxx b/controller.cxx
index 4e518f4..757d475 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -1,14 +1,19 @@
+#include <QQmlApplicationEngine>
#include "worker.hxx"
#include "controller.hxx"
-Controller::Controller(QObject* parent) :
- QObject{parent}
+Controller::Controller(QObject* parent) : QObject{parent}
{
Worker* worker = new Worker{};
worker->moveToThread(&thread);
connect(&thread, &QThread::finished, worker, &QObject::deleteLater);
- connect(parent, SIGNAL(logIn(QString, QString)),
+
+ auto engine = dynamic_cast<QQmlApplicationEngine*>(parent);
+ auto rootObjects = engine->rootObjects();
+ auto appWindow = rootObjects[0];
+ connect(appWindow, SIGNAL(logIn(QString, QString)),
worker, SLOT(logIn(QString, QString)));
+
thread.start();
}