summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Prabowo Kamal <erik@darapsa.co.id>2019-08-30 18:53:52 +0800
committerErik Prabowo Kamal <erik@darapsa.co.id>2019-08-30 18:53:52 +0800
commit07c432faf992781868f4d24b417c9cabb52a33d5 (patch)
treeb1b8c262509ce932e1169d9aa59c516de1bb31a5
parent2235e4736994ae902e6cff167c5550168c0a37bb (diff)
Managed to post login credentials to the RT server
For now, it's just to get a response
-rw-r--r--controller.cxx6
-rw-r--r--controller.hxx4
-rw-r--r--main.cxx11
-rw-r--r--pages/Password.qml2
m---------rtclient0
-rw-r--r--worker.cxx5
-rw-r--r--worker.hxx4
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;
diff --git a/main.cxx b/main.cxx
index 0b52736..a29e917 100644
--- a/main.cxx
+++ b/main.cxx
@@ -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
diff --git a/worker.cxx b/worker.cxx
index 8c915f8..19ae358 100644
--- a/worker.cxx
+++ b/worker.cxx
@@ -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();
diff --git a/worker.hxx b/worker.hxx
index cdb2811..660361e 100644
--- a/worker.hxx
+++ b/worker.hxx
@@ -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