Add logout button in home screen
authorPhilippe Lelong <lelong.ph@meltemus.com>
Tue, 20 Dec 2016 09:19:29 +0000 (10:19 +0100)
committerPhilippe Lelong <lelong.ph@meltemus.com>
Tue, 20 Dec 2016 09:19:29 +0000 (10:19 +0100)
Signed-off-by: Philippe Lelong <lelong.ph@meltemus.com>
HomeScreen/qml/Home.qml
HomeScreen/qml/images/Home/Logout-01.png [new file with mode: 0755]
HomeScreen/qml/images/Home/home.qrc
HomeScreen/src2/usermanagement.cpp
HomeScreen/src2/usermanagement.h

index 7d6fb74..ba7e1af 100644 (file)
@@ -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 }
             }
@@ -175,4 +178,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 (executable)
index 0000000..0183565
Binary files /dev/null and b/HomeScreen/qml/images/Home/Logout-01.png differ
index 8bef69d..a9d1dc3 100644 (file)
@@ -23,5 +23,6 @@
         <file>visa.png</file>
         <file>french_flag.png</file>
         <file>us_flag.png</file>
+        <file>Logout-01.png</file>
     </qresource>
 </RCC>
index 23550e4..5daa1f5 100644 (file)
@@ -5,6 +5,8 @@
 UserManagement::UserManagement(QObject *root) : QObject()
 {
     home = root->findChild<QObject *>("Home");
+    QObject::connect(home, SIGNAL(disconnect()),
+                         this, SLOT(slot_disconnect()));
     logo = root->findChild<QObject *>("Logo_colour");
     shortcutArea = root->findChild<QObject *>("ShortcutArea");
     statusArea = root->findChild<QObject *>("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\"}]");
 }
index 085549d..b374719 100644 (file)
@@ -62,6 +62,7 @@ public slots:
     void slot_timerTest();
 #endif
     void slot_turnOffRed();
+    void slot_disconnect();
 private:
     QObject *home;
     QObject *shortcutArea;