119 result.fill(Qt::transparent); |
120 result.fill(Qt::transparent); |
120 |
121 |
121 QPainter painter(&result); |
122 QPainter painter(&result); |
122 |
123 |
123 if(data(Ready).toBool()) |
124 if(data(Ready).toBool()) |
124 painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
125 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
125 |
126 |
126 QString mainIconName(":/res/chat/"); |
127 QString mainIconName(":/res/chat/"); |
127 |
128 |
128 if(data(RoomAdmin).toBool()) |
129 if(data(RoomAdmin).toBool()) |
129 mainIconName += "roomadmin"; |
130 mainIconName += "roomadmin"; |
133 mainIconName += "hedgehog"; |
134 mainIconName += "hedgehog"; |
134 |
135 |
135 if(!data(Registered).toBool()) |
136 if(!data(Registered).toBool()) |
136 mainIconName += "_gray"; |
137 mainIconName += "_gray"; |
137 |
138 |
138 painter.drawPixmap(0, 0, 16, 16, QPixmap(mainIconName + ".png")); |
139 painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png")); |
139 |
140 |
140 if(data(Ignore).toBool()) |
141 if(data(Ignore).toBool()) |
141 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ignore.png")); |
142 painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/ignore.png")); |
142 else |
143 else |
143 if(data(Friend).toBool()) |
144 if(data(Friend).toBool()) |
144 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/friend.png")); |
145 painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/friend.png")); |
145 |
146 |
146 painter.end(); |
147 painter.end(); |
147 |
148 |
148 QIcon icon(result); |
149 QIcon icon(result); |
149 |
150 |
352 chatText->setOpenLinks(false); |
353 chatText->setOpenLinks(false); |
353 connect(chatText, SIGNAL(anchorClicked(const QUrl&)), |
354 connect(chatText, SIGNAL(anchorClicked(const QUrl&)), |
354 this, SLOT(linkClicked(const QUrl&))); |
355 this, SLOT(linkClicked(const QUrl&))); |
355 mainLayout.addWidget(chatText, 0, 0, 2, 1); |
356 mainLayout.addWidget(chatText, 0, 0, 2, 1); |
356 |
357 |
357 chatNicks = new QListWidget(this); |
358 chatNicks = new QListView(this); |
358 chatNicks->setIconSize(QSize(24, 16)); |
359 chatNicks->setIconSize(QSize(24, 16)); |
359 chatNicks->setMinimumHeight(10); |
360 chatNicks->setMinimumHeight(10); |
360 chatNicks->setMinimumWidth(10); |
361 chatNicks->setMinimumWidth(10); |
361 chatNicks->setSortingEnabled(true); |
362 //chatNicks->setSortingEnabled(true); |
362 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
363 chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
363 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
364 chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); |
364 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
365 connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), |
365 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
366 this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); |
366 connect(chatNicks, SIGNAL(currentRowChanged(int)), |
367 connect(chatNicks, SIGNAL(currentRowChanged(int)), |
412 QDesktopServices::openUrl(link); |
413 QDesktopServices::openUrl(link); |
413 if (link.scheme() == "hwnick") |
414 if (link.scheme() == "hwnick") |
414 { |
415 { |
415 // decode nick |
416 // decode nick |
416 QString nick = QString::fromUtf8(QByteArray::fromBase64(link.encodedQuery())); |
417 QString nick = QString::fromUtf8(QByteArray::fromBase64(link.encodedQuery())); |
417 QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
418 /*QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
418 |
419 |
419 bool isOffline = (items.size() < 1); |
420 bool isOffline = (items.size() < 1); |
420 |
421 |
421 QMenu * popup = new QMenu(this); |
422 QMenu * popup = new QMenu(this); |
422 |
423 |
445 if ((!isOffline) || (action->data().toBool())) |
446 if ((!isOffline) || (action->data().toBool())) |
446 popup->addAction(action); |
447 popup->addAction(action); |
447 } |
448 } |
448 |
449 |
449 // display menu popup at mouse cursor position |
450 // display menu popup at mouse cursor position |
450 popup->popup(QCursor::pos()); |
451 popup->popup(QCursor::pos());*/ |
451 } |
452 } |
452 } |
453 } |
453 |
454 |
454 void HWChatWidget::setShowFollow(bool enabled) |
455 void HWChatWidget::setShowFollow(bool enabled) |
455 { |
456 { |
529 item->setData(ListWidgetNickItem::Ignore, QVariant(ignoreList.contains(nick, Qt::CaseInsensitive))); |
530 item->setData(ListWidgetNickItem::Ignore, QVariant(ignoreList.contains(nick, Qt::CaseInsensitive))); |
530 } |
531 } |
531 |
532 |
532 void HWChatWidget::updateNickItems() |
533 void HWChatWidget::updateNickItems() |
533 { |
534 { |
534 for(int i = 0; i < chatNicks->count(); i++) |
535 /*for(int i = 0; i < chatNicks->count(); i++) |
535 updateNickItem(chatNicks->item(i)); |
536 updateNickItem(chatNicks->item(i)); |
536 |
537 |
537 chatNicks->sortItems(); |
538 chatNicks->sortItems();*/ |
538 } |
539 } |
539 |
540 |
540 void HWChatWidget::loadLists(const QString & nick) |
541 void HWChatWidget::loadLists(const QString & nick) |
541 { |
542 { |
542 loadList(ignoreList, nick.toLower() + "_ignore.txt"); |
543 loadList(ignoreList, nick.toLower() + "_ignore.txt"); |
698 return; |
699 return; |
699 } |
700 } |
700 |
701 |
701 QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored); |
702 QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored); |
702 updateNickItem(item); |
703 updateNickItem(item); |
703 chatNicks->addItem(item); |
704 /*chatNicks->addItem(item);*/ |
704 |
705 |
705 if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name |
706 if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name |
706 chatEditLine->addNickname(nick); |
707 chatEditLine->addNickname(nick); |
707 |
708 |
708 emit nickCountUpdate(chatNicks->count()); |
709 //emit nickCountUpdate(chatNicks->count()); |
709 |
710 |
710 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) |
711 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) |
711 { |
712 { |
712 SDLInteraction::instance().playSoundFile( |
713 SDLInteraction::instance().playSoundFile( |
713 m_helloSounds.at(rand() % m_helloSounds.size())); |
714 m_helloSounds.at(rand() % m_helloSounds.size())); |
716 |
717 |
717 void HWChatWidget::nickRemoved(const QString& nick) |
718 void HWChatWidget::nickRemoved(const QString& nick) |
718 { |
719 { |
719 chatEditLine->removeNickname(nick); |
720 chatEditLine->removeNickname(nick); |
720 |
721 |
721 foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) |
722 /*foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) |
722 chatNicks->takeItem(chatNicks->row(item)); |
723 chatNicks->takeItem(chatNicks->row(item));*/ |
723 |
724 |
724 emit nickCountUpdate(chatNicks->count()); |
725 //emit nickCountUpdate(chatNicks->count()); |
725 } |
726 } |
726 |
727 |
727 void HWChatWidget::clear() |
728 void HWChatWidget::clear() |
728 { |
729 { |
729 chatEditLine->reset(); |
730 chatEditLine->reset(); |
733 cmds << "/me" << "/discardStyleSheet" << "/saveStyleSheet"; |
734 cmds << "/me" << "/discardStyleSheet" << "/saveStyleSheet"; |
734 chatEditLine->addCommands(cmds); |
735 chatEditLine->addCommands(cmds); |
735 |
736 |
736 chatText->clear(); |
737 chatText->clear(); |
737 chatStrings.clear(); |
738 chatStrings.clear(); |
738 chatNicks->clear(); |
739 //chatNicks->clear(); |
739 |
740 |
740 // clear and re compile regexp for highlighting |
741 // clear and re compile regexp for highlighting |
741 m_highlights.clear(); |
742 m_highlights.clear(); |
742 |
743 |
743 QString hlRegExp("^(.* )?%1[^-a-z0-9_]*( .*)?$"); |
744 QString hlRegExp("^(.* )?%1[^-a-z0-9_]*( .*)?$"); |
780 } |
781 } |
781 } |
782 } |
782 |
783 |
783 void HWChatWidget::onKick() |
784 void HWChatWidget::onKick() |
784 { |
785 { |
785 QListWidgetItem * curritem = chatNicks->currentItem(); |
786 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
786 if (curritem) |
787 if (curritem) |
787 emit kick(curritem->text()); |
788 emit kick(curritem->text());*/ |
788 } |
789 } |
789 |
790 |
790 void HWChatWidget::onBan() |
791 void HWChatWidget::onBan() |
791 { |
792 { |
792 QListWidgetItem * curritem = chatNicks->currentItem(); |
793 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
793 if (curritem) |
794 if (curritem) |
794 emit ban(curritem->text()); |
795 emit ban(curritem->text());*/ |
795 } |
796 } |
796 |
797 |
797 void HWChatWidget::onInfo() |
798 void HWChatWidget::onInfo() |
798 { |
799 { |
799 QListWidgetItem * curritem = chatNicks->currentItem(); |
800 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
800 if (curritem) |
801 if (curritem) |
801 emit info(curritem->text()); |
802 emit info(curritem->text());*/ |
802 } |
803 } |
803 |
804 |
804 void HWChatWidget::onFollow() |
805 void HWChatWidget::onFollow() |
805 { |
806 { |
806 QListWidgetItem * curritem = chatNicks->currentItem(); |
807 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
807 if (curritem) |
808 if (curritem) |
808 emit follow(curritem->text()); |
809 emit follow(curritem->text());*/ |
809 } |
810 } |
810 |
811 |
811 void HWChatWidget::onIgnore() |
812 void HWChatWidget::onIgnore() |
812 { |
813 { |
813 QListWidgetItem * curritem = chatNicks->currentItem(); |
814 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
814 QString nick = ""; |
815 QString nick = ""; |
815 if(curritem != NULL) |
816 if(curritem != NULL) |
816 nick = curritem->text(); |
817 nick = curritem->text(); |
817 else |
818 else |
818 nick = m_clickedNick; |
819 nick = m_clickedNick; |
841 if(curritem != NULL) |
842 if(curritem != NULL) |
842 { |
843 { |
843 updateNickItem(curritem); // update icon/sort order/etc |
844 updateNickItem(curritem); // update icon/sort order/etc |
844 chatNicks->sortItems(); |
845 chatNicks->sortItems(); |
845 chatNickSelected(0); // update context menu |
846 chatNickSelected(0); // update context menu |
846 } |
847 }*/ |
847 } |
848 } |
848 |
849 |
849 void HWChatWidget::onFriend() |
850 void HWChatWidget::onFriend() |
850 { |
851 { |
851 QListWidgetItem * curritem = chatNicks->currentItem(); |
852 /*QListWidgetItem * curritem = chatNicks->currentItem(); |
852 QString nick = ""; |
853 QString nick = ""; |
853 if(curritem != NULL) |
854 if(curritem != NULL) |
854 nick = curritem->text(); |
855 nick = curritem->text(); |
855 else |
856 else |
856 nick = m_clickedNick; |
857 nick = m_clickedNick; |
935 |
936 |
936 if (m_isAdmin) |
937 if (m_isAdmin) |
937 { |
938 { |
938 acKick->setVisible(!isSelf); |
939 acKick->setVisible(!isSelf); |
939 acBan->setVisible(!isSelf); |
940 acBan->setVisible(!isSelf); |
940 } |
941 }*/ |
941 } |
942 } |
942 |
943 |
943 void HWChatWidget::setStatus(const QString & nick, ListWidgetNickItem::StateFlag flag, bool status) |
944 void HWChatWidget::setStatus(const QString & nick, ListWidgetNickItem::StateFlag flag, bool status) |
944 { |
945 { |
945 QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
946 /*QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly); |
946 |
947 |
947 if (items.size() == 1) |
948 if (items.size() == 1) |
948 { |
949 { |
949 items[0]->setData(flag, status); |
950 items[0]->setData(flag, status); |
950 updateNickItem(items[0]); |
951 updateNickItem(items[0]); |
951 } |
952 }*/ |
952 } |
953 } |
953 |
954 |
954 void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) |
955 void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) |
955 { |
956 { |
956 setStatus(nick, ListWidgetNickItem::Ready, isReady); |
957 setStatus(nick, ListWidgetNickItem::Ready, isReady); |