461
|
1 |
#include <QListWidget>
|
|
2 |
#include <QLineEdit>
|
|
3 |
|
|
4 |
#include "chatwidget.h"
|
|
5 |
|
|
6 |
HWChatWidget::HWChatWidget(QWidget* parent) :
|
|
7 |
QWidget(parent),
|
|
8 |
mainLayout(this)
|
|
9 |
{
|
|
10 |
mainLayout.setSpacing(1);
|
|
11 |
mainLayout.setMargin(1);
|
462
|
12 |
mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
|
464
|
13 |
mainLayout.setColumnStretch(0, 75);
|
|
14 |
mainLayout.setColumnStretch(1, 25);
|
461
|
15 |
|
|
16 |
chatEditLine = new QLineEdit(this);
|
|
17 |
connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
|
|
18 |
|
463
|
19 |
mainLayout.addWidget(chatEditLine, 1, 0, 1, 2);
|
462
|
20 |
|
461
|
21 |
chatText = new QListWidget(this);
|
|
22 |
chatText->setMinimumHeight(10);
|
462
|
23 |
chatText->setMinimumWidth(10);
|
463
|
24 |
chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
461
|
25 |
mainLayout.addWidget(chatText, 0, 0);
|
462
|
26 |
|
|
27 |
chatNicks = new QListWidget(this);
|
|
28 |
chatNicks->setMinimumHeight(10);
|
|
29 |
chatNicks->setMinimumWidth(10);
|
463
|
30 |
chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
462
|
31 |
mainLayout.addWidget(chatNicks, 0, 1);
|
461
|
32 |
}
|
|
33 |
|
|
34 |
void HWChatWidget::returnPressed()
|
|
35 |
{
|
|
36 |
emit chatLine(chatEditLine->text());
|
|
37 |
chatEditLine->clear();
|
|
38 |
}
|
|
39 |
|
|
40 |
void HWChatWidget::onChatStringFromNet(const QStringList& str)
|
|
41 |
{
|
|
42 |
QListWidget* w=chatText;
|
|
43 |
w->addItem(str[0]+": "+str[1]);
|
|
44 |
w->scrollToBottom();
|
|
45 |
w->setSelectionMode(QAbstractItemView::NoSelection);
|
|
46 |
}
|