QTfrontend/chatwidget.cpp
changeset 1587 b8a3d449bed7
parent 1584 90f6a5abad17
child 1588 0988ae7771d3
equal deleted inserted replaced
1586:2c6f1d1f43c1 1587:b8a3d449bed7
    20 #include <QTextBrowser>
    20 #include <QTextBrowser>
    21 #include <QListWidget>
    21 #include <QListWidget>
    22 #include <QLineEdit>
    22 #include <QLineEdit>
    23 #include <QAction>
    23 #include <QAction>
    24 #include <QApplication>
    24 #include <QApplication>
       
    25 #include <QTextDocument>
    25 
    26 
    26 #include "chatwidget.h"
    27 #include "chatwidget.h"
    27 
    28 
    28 HWChatWidget::HWChatWidget(QWidget* parent) :
    29 HWChatWidget::HWChatWidget(QWidget* parent) :
    29   QWidget(parent),
    30   QWidget(parent),
    68 	emit chatLine(chatEditLine->text());
    69 	emit chatLine(chatEditLine->text());
    69 	chatEditLine->clear();
    70 	chatEditLine->clear();
    70 }
    71 }
    71 
    72 
    72 void HWChatWidget::onChatString(const QString& str)
    73 void HWChatWidget::onChatString(const QString& str)
       
    74 {
       
    75 	if (chatStrings.size() > 250)
       
    76 		chatStrings.removeFirst();
       
    77 	
       
    78 	chatStrings.append(Qt::escape(str));
       
    79 	
       
    80 	chatText->setHtml(chatStrings.join("<br>"));
       
    81 
       
    82 	chatText->moveCursor(QTextCursor::End);
       
    83 }
       
    84 
       
    85 void HWChatWidget::onServerMessage(const QString& str)
    73 {
    86 {
    74 	if (chatStrings.size() > 250)
    87 	if (chatStrings.size() > 250)
    75 		chatStrings.removeFirst();
    88 		chatStrings.removeFirst();
    76 	
    89 	
    77 	chatStrings.append(str);
    90 	chatStrings.append(str);