76 chatNicks->setSortingEnabled(true); |
76 chatNicks->setSortingEnabled(true); |
77 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
77 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
78 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
78 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
79 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
79 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
80 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
80 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
|
81 connect(chatNicks, SIGNAL(itemClicked(QListWidgetItem *)), |
|
82 this, SLOT(chatNickClicked(QListWidgetItem *))); |
81 |
83 |
82 mainLayout.addWidget(chatNicks, 0, 1); |
84 mainLayout.addWidget(chatNicks, 0, 1); |
83 |
85 |
84 acInfo = new QAction(QAction::tr("Info"), chatNicks); |
86 acInfo = new QAction(QAction::tr("Info"), chatNicks); |
85 connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); |
87 connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); |
89 connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); |
91 connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); |
90 acFollow = new QAction(QAction::tr("Follow"), chatNicks); |
92 acFollow = new QAction(QAction::tr("Follow"), chatNicks); |
91 connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); |
93 connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); |
92 acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); |
94 acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); |
93 connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); |
95 connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); |
94 acFriend = new QAction(QAction::tr("Friend"), chatNicks); |
96 acFriend = new QAction(QAction::tr("Add friend"), chatNicks); |
95 connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); |
97 connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); |
96 |
98 |
97 chatNicks->insertAction(0, acInfo); |
99 chatNicks->insertAction(0, acInfo); |
98 chatNicks->insertAction(0, acFollow); |
100 chatNicks->insertAction(0, acFollow); |
99 chatNicks->insertAction(0, acIgnore); |
101 chatNicks->insertAction(0, acIgnore); |
179 void HWChatWidget::returnPressed() |
181 void HWChatWidget::returnPressed() |
180 { |
182 { |
181 emit chatLine(chatEditLine->text()); |
183 emit chatLine(chatEditLine->text()); |
182 chatEditLine->clear(); |
184 chatEditLine->clear(); |
183 } |
185 } |
184 #include <QMessageBox> |
186 |
185 void HWChatWidget::onChatString(const QString& str) |
187 void HWChatWidget::onChatString(const QString& str) |
186 { |
188 { |
187 if (chatStrings.size() > 250) |
189 if (chatStrings.size() > 250) |
188 chatStrings.removeFirst(); |
190 chatStrings.removeFirst(); |
189 |
191 |
326 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item) |
328 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item) |
327 { |
329 { |
328 if (item) onFollow(); |
330 if (item) onFollow(); |
329 } |
331 } |
330 |
332 |
|
333 void HWChatWidget::chatNickClicked(QListWidgetItem * item) |
|
334 { |
|
335 if (!item) |
|
336 return; |
|
337 |
|
338 // update context menu labels according to possible action |
|
339 if(ignoreList.contains(item->text(), Qt::CaseInsensitive)) |
|
340 acIgnore->setText(QAction::tr("Unignore")); |
|
341 else |
|
342 acIgnore->setText(QAction::tr("Ignore")); |
|
343 |
|
344 if(friendsList.contains(item->text(), Qt::CaseInsensitive)) |
|
345 acFriend->setText(QAction::tr("Remove friend")); |
|
346 else |
|
347 acFriend->setText(QAction::tr("Add friend")); |
|
348 } |
|
349 |
331 void HWChatWidget::setShowReady(bool s) |
350 void HWChatWidget::setShowReady(bool s) |
332 { |
351 { |
333 showReady = s; |
352 showReady = s; |
334 } |
353 } |
335 |
354 |
340 { |
359 { |
341 qWarning("Bug: cannot find user in chat"); |
360 qWarning("Bug: cannot find user in chat"); |
342 return; |
361 return; |
343 } |
362 } |
344 |
363 |
345 /*if(isReady) |
|
346 items[0]->setIcon(QIcon(":/res/lightbulb_on.png")); |
|
347 else |
|
348 items[0]->setIcon(QIcon(":/res/lightbulb_off.png"));*/ |
|
349 |
|
350 items[0]->setData(Qt::UserRole, isReady); // bulb status |
364 items[0]->setData(Qt::UserRole, isReady); // bulb status |
351 updateIcon(items[0]); |
365 updateIcon(items[0]); |
352 |
366 |
353 // ensure we're still showing the status bulbs |
367 // ensure we're still showing the status bulbs |
354 showReady = true; |
368 showReady = true; |