From: Philippe Lelong Date: Tue, 20 Dec 2016 09:19:29 +0000 (+0100) Subject: Add logout button in home screen X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=staging%2FHomeScreen.git;a=commitdiff_plain;h=3b90fc6e1d569d568d4158aae700b077e2ad824b Add logout button in home screen Signed-off-by: Philippe Lelong --- diff --git a/HomeScreen/qml/Home.qml b/HomeScreen/qml/Home.qml index 756efb9..ed0d949 100644 --- a/HomeScreen/qml/Home.qml +++ b/HomeScreen/qml/Home.qml @@ -24,6 +24,7 @@ Item { id: root property int pid: -1 signal languageChanged + signal disconnect Image { anchors.fill: parent @@ -82,14 +83,15 @@ Item { Text { id: helloText anchors.centerIn: parent - color: "white" - text: "No Authenticated User" + color: 'white' + text: 'No Authenticated User' font.pixelSize: 40 - font.family: "Roboto" + font.family: 'Roboto' SequentialAnimation on font.letterSpacing { id: animation1 loops: 1; NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 } + running: false onRunningChanged: { if(running) { hello.visible = true @@ -103,6 +105,7 @@ Item { SequentialAnimation on opacity { id: animation2 loops: 1; + running: false NumberAnimation { from: 1; to: 0; duration: 2600 } PauseAnimation { duration: 400 } } @@ -176,4 +179,33 @@ Item { } } } + Image { + id: logout + width: sourceSize.width + height: sourceSize.height + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.bottomMargin: 10 + anchors.rightMargin: 20 + source: './images/Logout-01.png' + visible: true + MouseArea { + anchors.fill: parent + onClicked: { + rotateLogout.start() + disconnect() + helloText.text= 'No Authenticated User' + + } + } + RotationAnimator { + id: rotateLogout + target: logout; + from: 0; + to: 360; + loops: 1 + duration: 500 + running: false + } + } } diff --git a/HomeScreen/qml/images/Home/Logout-01.png b/HomeScreen/qml/images/Home/Logout-01.png new file mode 100755 index 0000000..0183565 Binary files /dev/null and b/HomeScreen/qml/images/Home/Logout-01.png differ diff --git a/HomeScreen/qml/images/Home/home.qrc b/HomeScreen/qml/images/Home/home.qrc index 8bef69d..a9d1dc3 100644 --- a/HomeScreen/qml/images/Home/home.qrc +++ b/HomeScreen/qml/images/Home/home.qrc @@ -23,5 +23,6 @@ visa.png french_flag.png us_flag.png + Logout-01.png diff --git a/HomeScreen/src2/usermanagement.cpp b/HomeScreen/src2/usermanagement.cpp index 23550e4..5daa1f5 100644 --- a/HomeScreen/src2/usermanagement.cpp +++ b/HomeScreen/src2/usermanagement.cpp @@ -5,6 +5,8 @@ UserManagement::UserManagement(QObject *root) : QObject() { home = root->findChild("Home"); + QObject::connect(home, SIGNAL(disconnect()), + this, SLOT(slot_disconnect())); logo = root->findChild("Logo_colour"); shortcutArea = root->findChild("ShortcutArea"); statusArea = root->findChild("StatusArea"); @@ -24,6 +26,19 @@ UserManagement::UserManagement(QObject *root) : QObject() launchServer(); #endif } +void UserManagement::slot_disconnect() +{ + appModel->changeOrder(-1); + timerRed.stop(); + slot_turnOffRed(); + QMetaObject::invokeMethod(home, "languageChanged"); + QMetaObject::invokeMethod(shortcutArea, "languageChanged", Q_ARG(QVariant, "en")); + QMetaObject::invokeMethod(statusArea, "languageChanged", Q_ARG(QVariant, "en")); + QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false), Q_ARG(QVariant, "")); + QMetaObject::invokeMethod(home, "changeFlag", Q_ARG(QVariant, "./images/us_flag.png")); +} + void UserManagement::setUser(const User &user) { int hash = qHash(user.name + user.first_name); @@ -293,6 +308,10 @@ void UserManagement::slot_timerTest() { if(!pSocket) return; + if(sequence > 3) { + timerTest.stop(); + return; + } pSocket->sendTextMessage("[5,\"agl-identity-agent/event\",{\"event\":\"agl-identity-agent\/event\",\"data\":{\"eventName\":\"incoming\",\"accountid\":\"D2:D4:71:0D:B5:F1\",\"nickname\":\"D2:D4:71:0D:B5:F1\"},\"jtype\":\"afb-event\"}]"); pSocket->sendTextMessage("[5,\"agl-identity-agent/event\",{\"event\":\"agl-identity-agent\/event\",\"data\":{\"eventName\":\"login\",\"accountid\":\"null\"},\"jtype\":\"afb-event\"}]"); } diff --git a/HomeScreen/src2/usermanagement.h b/HomeScreen/src2/usermanagement.h index 085549d..b374719 100644 --- a/HomeScreen/src2/usermanagement.h +++ b/HomeScreen/src2/usermanagement.h @@ -62,6 +62,7 @@ public slots: void slot_timerTest(); #endif void slot_turnOffRed(); + void slot_disconnect(); private: QObject *home; QObject *shortcutArea;