From fe0a17cc38d21c0c0cfb45f5d8f08c6e72f9e409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Thu, 12 Sep 2019 17:48:38 +0800 Subject: Move the QML login signal from appWindow to login --- Login.qml | 3 +++ controller.cxx | 4 +++- main.qml | 8 +++++--- pages/ConfirmPassword.qml | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Login.qml b/Login.qml index 1e450ce..17f60d1 100644 --- a/Login.qml +++ b/Login.qml @@ -1,6 +1,9 @@ import QtQuick 2.12 LoginForm { + signal logIn(string name, string password) + + objectName: "login" width: appWindow.width height: appWindow.height diff --git a/controller.cxx b/controller.cxx index 9d77cf4..3b4b4de 100644 --- a/controller.cxx +++ b/controller.cxx @@ -12,7 +12,9 @@ Controller::Controller(QObject* parent) : QObject{parent} auto engine = dynamic_cast(parent); auto rootObjects = engine->rootObjects(); auto appWindow = rootObjects[0]; - connect(appWindow, SIGNAL(logIn(QString, QString)), + + auto loginView = appWindow->findChild("login"); + connect(loginView, SIGNAL(logIn(QString, QString)), worker, SLOT(logIn(QString, QString))); auto user = engine->singletonInstance(User::typeId); diff --git a/main.qml b/main.qml index bf800b6..7499b81 100644 --- a/main.qml +++ b/main.qml @@ -3,14 +3,14 @@ import QtQuick.Controls 2.12 import QtQuick.Controls.Material 2.12 ApplicationWindow { + property alias login: login + id: appWindow width: 360 height: 640 visible: true Material.accent: Material.DeepPurple - signal logIn(string name, string password) - Drawer { id: drawer width: 0.8 * appWindow.width @@ -21,6 +21,8 @@ ApplicationWindow { id: stackView anchors.fill : parent - initialItem: Login {} + initialItem: Login { + id: login + } } } diff --git a/pages/ConfirmPassword.qml b/pages/ConfirmPassword.qml index 51390f9..3e1df7a 100644 --- a/pages/ConfirmPassword.qml +++ b/pages/ConfirmPassword.qml @@ -13,7 +13,7 @@ PasswordForm { createPassButton { text: qsTr("Confirm password") onClicked: { - appWindow.logIn(User.name, User.password) + login.logIn(User.name, User.password) stackView.push("qrc:/pages/CreateProfile.qml") } } -- cgit v1.2.3