summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-21 07:56:19 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-21 07:56:19 +0800
commit66136b7dfa06a150089fdddd0705aef60aeada4a (patch)
tree9819c772d59762fc710275bdfed410cb60c1b883
parenta0653a4b7d95ed0217e7bcb9176b3f950f21fef8 (diff)
User show slot result gets checked first by controller
and only if the result is not null, implying the login is successful, then it will do a ticket search based on the logged in user's name.
-rw-r--r--LoginPassword.qml9
-rw-r--r--Onboarding.qml1
-rw-r--r--controller.cxx43
-rw-r--r--controller.hxx9
m---------qrtclient0
5 files changed, 40 insertions, 22 deletions
diff --git a/LoginPassword.qml b/LoginPassword.qml
index 8b65a11..d2e8064 100644
--- a/LoginPassword.qml
+++ b/LoginPassword.qml
@@ -4,20 +4,15 @@ import "larva/features"
LoginPasswordForm {
emailTextLabel.text: User.name
-
- passwordTextField.onTextChanged: {
+ passwordTextField.onTextChanged:
if (!passwordTextField.text || !continueButton.enabled)
continueButton.enabled = !continueButton.enabled
- }
continueButton {
icon.source: "assets/arrow-forward-24px.svg"
onClicked: {
User.password = passwordTextField.text
- onClicked: {
- onboarding.logIn(User.name, User.password)
- onboarding.ticketSearch(User.name)
- }
+ onboarding.logIn(User.name, User.password)
}
}
}
diff --git a/Onboarding.qml b/Onboarding.qml
index f66f491..9e54625 100644
--- a/Onboarding.qml
+++ b/Onboarding.qml
@@ -4,7 +4,6 @@ import "larva/features"
OnboardingForm {
signal logIn(string name, string password)
signal ticketNew(string queue, string requestor)
- signal ticketSearch(string name)
function pushHome() {
pageView.push("Home.qml")
}
diff --git a/controller.cxx b/controller.cxx
index 8e832b7..5ffe31f 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -13,38 +13,53 @@ Controller::Controller(QObject* parent) : QObject{parent}
auto engine = static_cast<QQmlApplicationEngine*>(parent);
auto rootObjects = engine->rootObjects();
auto appWindow = rootObjects[0];
-
auto onboardingView = appWindow->findChild<QObject*>("onboarding");
- connect(onboardingView, SIGNAL(logIn(QString, QString))
- , client, SLOT(logIn(QString, QString)));
- connect(client, SIGNAL(loggedIn(QString))
- , client, SLOT(userShow(QString)));
- connect(onboardingView, SIGNAL(ticketNew(QString, QString))
- , client, SLOT(ticketNew(QString, QString)));
- connect(onboardingView, SIGNAL(ticketSearch(QString))
- , client, SLOT(ticketSearch(QString)));
-
using RTClient::User;
auto typeId = qmlRegisterSingletonType<User>("KelakonUser", 0, 1, "User"
- , [](QQmlEngine *engine,
- QJSEngine *scriptEngine) -> QObject* {
+ , [](QQmlEngine *engine
+ , QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new User;
});
auto user = engine->singletonInstance<User*>(typeId);
+ taskList = new RTClient::TicketList;
+ engine->rootContext()->setContextProperty("taskList", taskList);
+
+ connect(onboardingView, SIGNAL(logIn(QString, QString))
+ , client, SLOT(logIn(QString, QString)));
+
+ connect(client, SIGNAL(loggedIn(QString))
+ , client, SLOT(userShow(QString)));
+
connect(client, SIGNAL(userShown(rtclient_user*))
+ , this, SLOT(check(rtclient_user*)));
+
+ connect(this, SIGNAL(checked(rtclient_user*))
, user, SLOT(update(rtclient_user*)));
- taskList = new RTClient::TicketList;
- engine->rootContext()->setContextProperty("taskList", taskList);
+ connect(this, SIGNAL(checked(QString))
+ , client, SLOT(ticketSearch(QString)));
+
connect(client, SIGNAL(ticketSearched(rtclient_ticketlist*))
, taskList, SLOT(update(rtclient_ticketlist*)));
+
+ connect(onboardingView, SIGNAL(ticketNew(QString, QString))
+ , client, SLOT(ticketNew(QString, QString)));
+
connect(taskList, SIGNAL(updated()), onboardingView, SLOT(pushHome()));
thread.start();
}
+void Controller::check(rtclient_user* user)
+{
+ if (user) {
+ emit checked(QString{user->name});
+ emit checked(user);
+ }
+}
+
Controller::~Controller()
{
thread.quit();
diff --git a/controller.hxx b/controller.hxx
index dcfdb7c..8eb4017 100644
--- a/controller.hxx
+++ b/controller.hxx
@@ -4,6 +4,8 @@
#include <QThread>
#include <qrtclient/ticket.hxx>
+struct rtclient_user;
+
class Controller : public QObject
{
Q_OBJECT
@@ -12,6 +14,13 @@ class Controller : public QObject
Controller(QObject* parent = nullptr);
~Controller();
+ signals:
+ void checked(rtclient_user* user);
+ void checked(QString const& name);
+
+ private slots:
+ void check(rtclient_user* user);
+
private:
QThread thread;
RTClient::TicketList* taskList;
diff --git a/qrtclient b/qrtclient
-Subproject c45c7b8eae9ade41b6c9bfa02a4b7d6ff329e86
+Subproject 6aba4774d836194e913e56c0c85fa30407d0e5c