173 |
173 |
174 // matches class names that are referenced without hierachy |
174 // matches class names that are referenced without hierachy |
175 QRegExp nohierarchy("^.[^ .]+$"); |
175 QRegExp nohierarchy("^.[^ .]+$"); |
176 |
176 |
177 QStringList victims = QString(style). |
177 QStringList victims = QString(style). |
178 remove(displayed). // remove visible stuff |
178 remove(displayed). // remove visible stuff |
179 trimmed(). |
179 trimmed(). |
180 split(split). // get a list of the names |
180 split(split). // get a list of the names |
181 filter(nohierarchy). // only direct class names |
181 filter(nohierarchy). // only direct class names |
182 replaceInStrings(QRegExp("^."),""); // crop . |
182 replaceInStrings(QRegExp("^."),""); // crop . |
183 |
183 |
184 |
184 |
185 if (victims.contains("timestamp")) |
185 if (victims.contains("timestamp")) |
186 { |
186 { |
187 s_isTimeStamped = false; |
187 s_isTimeStamped = false; |
238 chatText->moveCursor(QTextCursor::End); |
238 chatText->moveCursor(QTextCursor::End); |
239 } |
239 } |
240 |
240 |
241 |
241 |
242 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : |
242 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : |
243 QWidget(parent), |
243 QWidget(parent), |
244 mainLayout(this) |
244 mainLayout(this) |
245 { |
245 { |
246 this->gameSettings = gameSettings; |
246 this->gameSettings = gameSettings; |
247 this->notify = notify; |
247 this->notify = notify; |
248 |
248 |
249 m_isAdmin = false; |
249 m_isAdmin = false; |
250 |
250 |
251 if(gameSettings->value("frontend/sound", true).toBool()) |
251 if(gameSettings->value("frontend/sound", true).toBool()) |
252 { |
252 { |
253 if (notify) |
253 if (notify) |
254 m_helloSound = HWDataManager::instance().findFileForRead( |
254 m_helloSound = HWDataManager::instance().findFileForRead( |
255 "Sounds/voices/Classic/Hello.ogg"); |
255 "Sounds/voices/Classic/Hello.ogg"); |
256 |
256 |
257 m_hilightSound = HWDataManager::instance().findFileForRead( |
257 m_hilightSound = HWDataManager::instance().findFileForRead( |
258 "Sounds/beep.ogg"); |
258 "Sounds/beep.ogg"); |
259 |
259 |
260 //m_hilightSound = m_helloSound;//"Sounds/beep.ogg"; |
260 //m_hilightSound = m_helloSound;//"Sounds/beep.ogg"; |
261 } |
261 } |
262 |
262 |
263 mainLayout.setSpacing(1); |
263 mainLayout.setSpacing(1); |
279 chatText->setMinimumHeight(20); |
279 chatText->setMinimumHeight(20); |
280 chatText->setMinimumWidth(10); |
280 chatText->setMinimumWidth(10); |
281 chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
281 chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
282 chatText->setOpenLinks(false); |
282 chatText->setOpenLinks(false); |
283 connect(chatText, SIGNAL(anchorClicked(const QUrl&)), |
283 connect(chatText, SIGNAL(anchorClicked(const QUrl&)), |
284 this, SLOT(linkClicked(const QUrl&))); |
284 this, SLOT(linkClicked(const QUrl&))); |
285 mainLayout.addWidget(chatText, 0, 0, 2, 1); |
285 mainLayout.addWidget(chatText, 0, 0, 2, 1); |
286 |
286 |
287 chatNicks = new QListWidget(this); |
287 chatNicks = new QListWidget(this); |
288 chatNicks->setMinimumHeight(10); |
288 chatNicks->setMinimumHeight(10); |
289 chatNicks->setMinimumWidth(10); |
289 chatNicks->setMinimumWidth(10); |
290 chatNicks->setSortingEnabled(true); |
290 chatNicks->setSortingEnabled(true); |
291 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
291 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
292 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
292 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
293 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
293 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
294 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
294 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
295 connect(chatNicks, SIGNAL(currentRowChanged(int)), |
295 connect(chatNicks, SIGNAL(currentRowChanged(int)), |
296 this, SLOT(chatNickSelected(int))); |
296 this, SLOT(chatNickSelected(int))); |
297 |
297 |
298 mainLayout.addWidget(chatNicks, 0, 1, 3, 1); |
298 mainLayout.addWidget(chatNicks, 0, 1, 3, 1); |
299 |
299 |
300 // the userData is used to flag things that are even available when user |
300 // the userData is used to flag things that are even available when user |
301 // is offline |
301 // is offline |
511 // it as host would convert it to it's lower case variant |
513 // it as host would convert it to it's lower case variant |
512 QString HWChatWidget::linkedNick(const QString & nickname) |
514 QString HWChatWidget::linkedNick(const QString & nickname) |
513 { |
515 { |
514 if (nickname != m_userNick) |
516 if (nickname != m_userNick) |
515 return QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg( |
517 return QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg( |
516 QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); |
518 QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); |
517 |
519 |
518 // unlinked nick (if own one) |
520 // unlinked nick (if own one) |
519 return QString("<span class=\"nick\">%1</span>").arg(Qt::escape(nickname)); |
521 return QString("<span class=\"nick\">%1</span>").arg(Qt::escape(nickname)); |
520 } |
522 } |
521 |
523 |
529 |
531 |
530 void HWChatWidget::onChatString(const QString& nick, const QString& str) |
532 void HWChatWidget::onChatString(const QString& nick, const QString& str) |
531 { |
533 { |
532 bool isFriend = false; |
534 bool isFriend = false; |
533 |
535 |
534 if (!nick.isEmpty()) { |
536 if (!nick.isEmpty()) |
|
537 { |
535 // don't show chat lines that are from ignored nicks |
538 // don't show chat lines that are from ignored nicks |
536 if (ignoreList.contains(nick, Qt::CaseInsensitive)) |
539 if (ignoreList.contains(nick, Qt::CaseInsensitive)) |
537 return; |
540 return; |
538 // friends will get special treatment, of course |
541 // friends will get special treatment, of course |
539 isFriend = friendsList.contains(nick, Qt::CaseInsensitive); |
542 isFriend = friendsList.contains(nick, Qt::CaseInsensitive); |
636 if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name |
639 if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name |
637 chatEditLine->addNickname(nick); |
640 chatEditLine->addNickname(nick); |
638 |
641 |
639 emit nickCountUpdate(chatNicks->count()); |
642 emit nickCountUpdate(chatNicks->count()); |
640 |
643 |
641 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { |
644 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) |
642 SDLInteraction::instance().playSoundFile(m_helloSound); |
645 { |
|
646 SDLInteraction::instance().playSoundFile(m_helloSound); |
643 } |
647 } |
644 } |
648 } |
645 |
649 |
646 void HWChatWidget::nickRemoved(const QString& nick) |
650 void HWChatWidget::nickRemoved(const QString& nick) |
647 { |
651 { |
648 chatEditLine->removeNickname(nick); |
652 chatEditLine->removeNickname(nick); |
649 |
653 |
650 foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) |
654 foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) |
651 chatNicks->takeItem(chatNicks->row(item)); |
655 chatNicks->takeItem(chatNicks->row(item)); |
652 |
656 |
653 emit nickCountUpdate(chatNicks->count()); |
657 emit nickCountUpdate(chatNicks->count()); |
654 } |
658 } |
655 |
659 |
656 void HWChatWidget::clear() |
660 void HWChatWidget::clear() |