qmlFrontend/qml/qmlFrontend/Chat.qml
branchqmlfrontend
changeset 11423 e045dc60c37e
parent 11416 78d6b99ddcb0
child 11424 86c13e5662f1
equal deleted inserted replaced
11422:c6c6a4b32cea 11423:e045dc60c37e
    41                          onClicked: ;
    41                          onClicked: ;
    42                     }
    42                     }
    43                 }
    43                 }
    44                 Text {
    44                 Text {
    45                     color: "#ffffff"
    45                     color: "#ffffff"
    46                     text: name
    46                     text: line
    47 
    47 
    48                     MouseArea {
    48                     MouseArea {
    49                          z: 1
    49                          z: 1
    50                          anchors.fill: parent
    50                          anchors.fill: parent
    51                          onClicked: ;
    51                          onClicked: ;
    54             }
    54             }
    55 
    55 
    56         }
    56         }
    57 
    57 
    58         function addLine(nickname, line) {
    58         function addLine(nickname, line) {
    59             chatLinesModel.append({"nick" : nickname, "name": line})
    59             chatLinesModel.append({"nick" : nickname, "line": line})
    60             if(chatLinesModel.count > 200)
    60             if(chatLinesModel.count > 200)
    61                 chatLinesModel.remove(0)
    61                 chatLinesModel.remove(0)
    62             chatLines.currentIndex = chatLinesModel.count - 1
    62             chatLines.currentIndex = chatLinesModel.count - 1
    63         }
    63         }
    64 
    64 
   116 
   116 
   117         }
   117         }
   118 
   118 
   119         Connections {
   119         Connections {
   120             target: HWEngine
   120             target: HWEngine
   121             onLobbyClientAdded: chatClientsModel.append({"isAdmin": false, "name": clientName})
   121             onLobbyClientAdded: {
       
   122                 chatClientsModel.append({"isAdmin": false, "name": clientName})
       
   123                 chatLines.addLine("***", qsTr("%1 joined").arg(clientName))
       
   124             }
   122             onLobbyClientRemoved: {
   125             onLobbyClientRemoved: {
   123                 var i = chatClientsModel.count - 1;
   126                 var i = chatClientsModel.count - 1;
   124                 while ((i >= 0) && (chatClientsModel.get(i).name !== clientName)) --i;
   127                 while ((i >= 0) && (chatClientsModel.get(i).name !== clientName)) --i;
   125 
   128 
   126                 if(i >= 0) chatClientsModel.remove(i, 1);
   129                 if(i >= 0) {
       
   130                     chatClientsModel.remove(i, 1);
       
   131                     chatLines.addLine("***", qsTr("%1 quit (%2)").arg(clientName).arg(reason))
       
   132                 }
   127             }
   133             }
   128         }
   134         }
   129     }
   135     }
   130 }
   136 }
   131 
   137