qmlFrontend/qml/qmlFrontend/Chat.qml
branchqmlfrontend
changeset 11416 78d6b99ddcb0
parent 11415 05cf35103206
child 11423 e045dc60c37e
--- a/qmlFrontend/qml/qmlFrontend/Chat.qml	Thu Nov 19 23:04:53 2015 +0300
+++ b/qmlFrontend/qml/qmlFrontend/Chat.qml	Thu Nov 19 23:32:28 2015 +0300
@@ -14,7 +14,7 @@
         x: 0
         y: 0
         width: parent.width - clientsList.width
-        height: parent.height
+        height: parent.height - input.height
         focus: true
         clip: true
         highlightFollowsCurrentItem: true
@@ -55,14 +55,31 @@
 
         }
 
+        function addLine(nickname, line) {
+            chatLinesModel.append({"nick" : nickname, "name": line})
+            if(chatLinesModel.count > 200)
+                chatLinesModel.remove(0)
+            chatLines.currentIndex = chatLinesModel.count - 1
+        }
+
         Connections {
             target: HWEngine
-            onLobbyChatLine: {
-                chatLinesModel.append({"nick" : nickname, "name": line})
-                if(chatLinesModel.count > 200)
-                    chatLinesModel.remove(0)
-                chatLines.currentIndex = chatLinesModel.count - 1
-            }
+            onLobbyChatLine: chatLines.addLine(nickname, line)
+        }
+    }
+
+    TextInput {
+        id: input
+        x: 0
+        y: chatLines.height
+        width: chatLines.width
+        height: 24
+        color: "#eccd2f"
+
+        onAccepted: {
+            HWEngine.sendChatMessage(text)
+            chatLines.addLine("me", text)
+            text = ""
         }
     }
 
@@ -101,9 +118,7 @@
 
         Connections {
             target: HWEngine
-            onLobbyClientAdded: {
-                chatClientsModel.append({"isAdmin": false, "name": clientName})
-            }
+            onLobbyClientAdded: chatClientsModel.append({"isAdmin": false, "name": clientName})
             onLobbyClientRemoved: {
                 var i = chatClientsModel.count - 1;
                 while ((i >= 0) && (chatClientsModel.get(i).name !== clientName)) --i;