Browse Source

Polishing od call popup

Alexey Edelev 5 years ago
parent
commit
7d6a2dd733

+ 79 - 7
examples/addressbook/qml/CallPopup.qml

@@ -31,10 +31,11 @@ import qtprotobuf.examples 1.0
 Rectangle {
     id: root
     property CallStatus callStatus: null
-    visible: false
     color: "#B0BEC5"
     border.width: 1
     border.color: "#cfdfe7"
+    opacity: 0.0
+    visible: opacity > 0
     PrimaryText {
         id: _statusText
         text: _d.getCallStatusText()
@@ -44,25 +45,96 @@ Rectangle {
     }
     radius: 10
 
+    transform: Rotation {
+        id: _rotation
+        axis {
+            x: 1
+            y: 0
+            z: 0
+        }
+        origin {
+            x: root.width / 2
+            y: root.height / 2
+        }
+
+        angle: 0
+    }
+
     states: [
         State {
             name: "opened"
             when: callStatus.status === CallStatus.Active || callStatus.status === CallStatus.Ended
-            PropertyChanges {
-                target: root
-                visible: true
-            }
         },
         State {
             name: "closed"
             when: callStatus.status !== CallStatus.Active && callStatus.status !== CallStatus.Ended
-            PropertyChanges {
+        }
+    ]
+
+    transitions: [
+        Transition {
+            from: "opened"
+            to: "closed"
+
+            NumberAnimation {
+                target: root
+                property: "opacity"
+                duration: 300
+                from: 1.0
+                to: 0.0
+            }
+
+
+            NumberAnimation {
+                target: root
+                property: "anchors.verticalCenterOffset"
+                duration: 300
+                from: 0
+                to: 50
+            }
+
+            NumberAnimation {
+                target: _rotation
+                property: "angle"
+                duration: 300
+                from: 0
+                to: -45
+            }
+        },
+        Transition {
+            from: "closed"
+            to: "opened"
+
+            NumberAnimation {
                 target: root
-                visible: false
+                property: "anchors.verticalCenterOffset"
+                duration: 300
+                from: 50
+                to: 0
+            }
+
+            NumberAnimation {
+                target: root
+                property: "opacity"
+                duration: 300
+                from: 0.0
+                to: 1.0
+            }
+
+            NumberAnimation {
+                target: _rotation
+                property: "angle"
+                duration: 300
+                from: -45
+                to: 0
             }
         }
     ]
 
+    MouseArea {
+        anchors.fill: parent
+    }
+
     FloatingRoundButton {
         id: _hangButton
         primaryColor: "#d31a5b"

+ 1 - 0
examples/addressbook/qml/ContactDetails.qml

@@ -147,6 +147,7 @@ StackItem {
     FloatingRoundButton {
         id: call
         enabled: _homePhoneField.text.length > 0
+                 && abEngine.callStatus.status !== CallStatus.Active && abEngine.callStatus.status !== CallStatus.Ended
         anchors.right: parent.right
         anchors.bottom: parent.bottom
         anchors.margins: 10

+ 4 - 0
examples/addressbookserver/main.cpp

@@ -98,6 +98,10 @@ public:
 
     ::grpc::Status endCall(grpc::ServerContext *, const None *, SimpleResult *) override
     {
+        if (m_lastCallStatus.status() != CallStatus::Active) {
+            return ::grpc::Status();
+        }
+
         std::cout << "Call ended" << std::endl;
         m_lastCallStatus.set_status(CallStatus::Ended);
         for(unsigned int i = 0; i < (m_callClients.size() - 1); i++) {