source/MainGUI.cpp
/**
 * Slot to build the requested context menu for the friendlist.
 *
 * @param pos The position of the mouse event.
 */
Slot to build the requested context menu for the friendlist.
@param pos The position of the mouse event.
Slot to build the requested context menu for the friendlist . @param pos The position of the mouse event .
void MainGUI::onFriendsContextMenu (const QPoint& pos)
{
    QPoint globalPos = widget.friendList->mapToGlobal(pos);
    QListWidgetItem* item = widget.friendList->itemAt(pos);
    if (!item)
    {
        return;
    }
    QMenu menu;
    menu.addAction(QIcon(":/images/Mail.png"), "Whisper");
    menu.addAction(QIcon(":/images/User.png"), "Whois");
    menu.addAction(QIcon(":/images/Chat Bubble.png"), "Whisper all");
    menu.addAction(QIcon(":/images/Applications.png"), "Copy name");
    menu.addAction(QIcon(":/images/Remove.png"), "Remove friend");
    if (gproxy->m_BNET->GetInGame())
    {
        menu.addAction(QIcon(":/images/Edit.png"), "!stats");
        menu.addAction(QIcon(":/images/Edit Alt.png"), "!statsdota");
    }
    QAction* action = menu.exec(globalPos);
    if (action)
    {
        if (action->text() == "Whisper")
        {
            widget.inputTextArea->setPlainText("/w " + item->text() + " ");
            widget.inputTextArea->setFocus();
            widget.inputTextArea->moveCursor(QTextCursor::End);
        }
        else if (action->text() == "Whois")
        {
            gproxy->m_BNET->QueueChatCommand("/whois " + item->text(), false);
        }
        else if (action->text() == "Whisper all")
        {
            widget.inputTextArea->setPlainText("/f m ");
            widget.inputTextArea->setFocus();
            widget.inputTextArea->moveCursor(QTextCursor::End);
        }
        else if (action->text() == "Copy name")
        {
            QApplication::clipboard()->setText(item->text());
        }
        else if (action->text() == "!stats" || action->text() == "!statsdota")
        {
            gproxy->sendGamemessage(action->text() + " " + item->text());
        }
        else if (action->text() == "Remove friend")
        {
            gproxy->m_BNET->QueueChatCommand("/friends remove "
                    + item->text(), false);
        }
        else
        {
            addMessage(ColoredMessage("[ERROR] Not yet implemented!", ColoredMessage::ERROR), false);
        }
    }
}
void MainGUI :: onFriendsContextMenu ( const QPoint & pos ) { QPoint globalPos = widget . friendList -> mapToGlobal ( pos ) ; QListWidgetItem * item = widget . friendList -> itemAt ( pos ) ; if ( ! item ) { return ; } QMenu menu ; menu . addAction ( QIcon ( " " ) , " " ) ; menu . addAction ( QIcon ( " " ) , " " ) ; menu . addAction ( QIcon ( " " ) , " " ) ; menu . addAction ( QIcon ( " " ) , " " ) ; menu . addAction ( QIcon ( " " ) , " " ) ; if ( gproxy -> m_BNET -> GetInGame ( ) ) { menu . addAction ( QIcon ( " " ) , " " ) ; menu . addAction ( QIcon ( " " ) , " " ) ; } QAction * action = menu . exec ( globalPos ) ; if ( action ) { if ( action -> text ( ) == " " ) { widget . inputTextArea -> setPlainText ( " " + item -> text ( ) + " " ) ; widget . inputTextArea -> setFocus ( ) ; widget . inputTextArea -> moveCursor ( QTextCursor :: End ) ; } else if ( action -> text ( ) == " " ) { gproxy -> m_BNET -> QueueChatCommand ( " " + item -> text ( ) , false ) ; } else if ( action -> text ( ) == " " ) { widget . inputTextArea -> setPlainText ( " " ) ; widget . inputTextArea -> setFocus ( ) ; widget . inputTextArea -> moveCursor ( QTextCursor :: End ) ; } else if ( action -> text ( ) == " " ) { QApplication :: clipboard ( ) -> setText ( item -> text ( ) ) ; } else if ( action -> text ( ) == " " || action -> text ( ) == " " ) { gproxy -> sendGamemessage ( action -> text ( ) + " " + item -> text ( ) ) ; } else if ( action -> text ( ) == " " ) { gproxy -> m_BNET -> QueueChatCommand ( " " + item -> text ( ) , false ) ; } else { addMessage ( ColoredMessage ( " " , ColoredMessage :: ERROR ) , false ) ; } } }
Slot to build the requested context menu for the friendlist.
Slot to build the requested context menu for the friendlist .