diff options
-rw-r--r-- | controller.cxx | 6 | ||||
-rw-r--r-- | controller.hxx | 4 | ||||
-rw-r--r-- | main.cxx | 11 | ||||
-rw-r--r-- | pages/Password.qml | 2 | ||||
m--------- | rtclient | 0 | ||||
-rw-r--r-- | worker.cxx | 5 | ||||
-rw-r--r-- | worker.hxx | 4 |
7 files changed, 27 insertions, 5 deletions
diff --git a/controller.cxx b/controller.cxx index d1271b9..015d4ac 100644 --- a/controller.cxx +++ b/controller.cxx @@ -6,9 +6,15 @@ Controller::Controller() Worker* worker = new Worker{}; worker->moveToThread(&thread); connect(&thread, &QThread::finished, worker, &QObject::deleteLater); + connect(this, &Controller::credentialsObtained, worker, &Worker::logIn); thread.start(); } +void Controller::logIn(QString const& name, QString const& password) +{ + emit credentialsObtained(name, password); +} + Controller::~Controller() { thread.quit(); diff --git a/controller.hxx b/controller.hxx index e293ec4..8b98328 100644 --- a/controller.hxx +++ b/controller.hxx @@ -10,6 +10,10 @@ class Controller : public QObject public: Controller(); ~Controller(); + Q_INVOKABLE void logIn(QString const& name, QString const& password); + + signals: + void credentialsObtained(QString const& name, QString const& password); private: QThread thread; @@ -12,13 +12,14 @@ int main(int argc, char* argv[]) qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.user", 0, 1, "User", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) - - User* user = new User{}; - return user; + return new User{}; + }); + qmlRegisterSingletonType<User>("id.co.darapsa.kelakon.rtclient", 0, 1, "RTClient", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + return new Controller{}; }); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - Controller controller{}; - return app.exec(); } diff --git a/pages/Password.qml b/pages/Password.qml index 0edb294..a499a65 100644 --- a/pages/Password.qml +++ b/pages/Password.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import id.co.darapsa.kelakon.user 0.1 +import id.co.darapsa.kelakon.rtclient 0.1 PasswordForm { width: stackView.width @@ -13,6 +14,7 @@ PasswordForm { createPassButton { onClicked: { User.password = passTextField.text + RTClient.logIn(User.emailAddress, User.password) } } } diff --git a/rtclient b/rtclient -Subproject 89cd9ab12cb2aa09f92e312cd0418a036dc0ed8 +Subproject 16b8e66c64ee8acd6ea2ce34372e52406a990d2 @@ -7,6 +7,11 @@ Worker::Worker(QObject* parent) : rtclient_init(); } +void Worker::logIn(QString const& name, QString const& password) +{ + rtclient_login(name.toLatin1().constData(), password.toLatin1().constData()); +} + Worker::~Worker() { rtclient_cleanup(); @@ -6,9 +6,13 @@ class Worker : public QObject { Q_OBJECT + public: explicit Worker(QObject* parent = nullptr); virtual ~Worker(); + + public slots: + void logIn(QString const& name, QString const& password); }; #endif // WORKER_HXX |