source/MainGUI.cpp
/**
 * A key on the input text area was pressed.
 * 
 * @param event The occurred key event.
 * @return Wheter this event should be delegated to the text area.
 */
A key on the input text area was pressed.

@param event The occurred key event.
@return Wheter this event should be delegated to the text area.
A key on the input text area was pressed . @param event The occurred key event . @return Wheter this event should be delegated to the text area .
bool MainGUI::onInputTextAreaKeyPressed (QKeyEvent* event)
{
    if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
    {
        if (widget.inputTextArea->toPlainText().length() == 0)
        {
            return true;
        }
        if (event->modifiers() != Qt::ShiftModifier)
        {
            QString input = widget.inputTextArea->toPlainText();
            widget.inputTextArea->clear();
            QStringList lines = input.split('\n');
            if(lines.first().toLower().startsWith("/w ") and lines.first().size() > 3 ){
                for(int count = 1; count < lines.size(); ++count)           
                lines[count] = lines.first().mid(0,lines.first().indexOf(' ',lines.first().indexOf(' ',0) + 1) ) + ' ' +  lines[count];
            }
            foreach(QString line, lines)
            {
                if (!line.isEmpty())
                {
                    processInput(line);
                }
            }
            return true;
        }
    }
    else if (event->key() == Qt::Key_Space 
            && widget.inputTextArea->toPlainText().toLower() == "/r"
            && !gproxy->m_BNET->GetReplyTarget().empty())
    {
        widget.inputTextArea->setPlainText("/w "
                + QString::fromStdString(gproxy->m_BNET->GetReplyTarget()));
        widget.inputTextArea->moveCursor(QTextCursor::End);
    }
    return false;
}
bool MainGUI :: onInputTextAreaKeyPressed ( QKeyEvent * event ) { if ( event -> key ( ) == Qt :: Key_Enter || event -> key ( ) == Qt :: Key_Return ) { if ( widget . inputTextArea -> toPlainText ( ) . length ( ) == 0 ) { return true ; } if ( event -> modifiers ( ) != Qt :: ShiftModifier ) { QString input = widget . inputTextArea -> toPlainText ( ) ; widget . inputTextArea -> clear ( ) ; QStringList lines = input . split ( ' \n ' ) ; if ( lines . first ( ) . toLower ( ) . startsWith ( " " ) and lines . first ( ) . size ( ) > 3 ) { for ( int count = 1 ; count < lines . size ( ) ; ++ count ) lines [ count ] = lines . first ( ) . mid ( 0 , lines . first ( ) . indexOf ( ' ' , lines . first ( ) . indexOf ( ' ' , 0 ) + 1 ) ) + ' ' + lines [ count ] ; } foreach ( QString line , lines ) { if ( ! line . isEmpty ( ) ) { processInput ( line ) ; } } return true ; } } else if ( event -> key ( ) == Qt :: Key_Space && widget . inputTextArea -> toPlainText ( ) . toLower ( ) == " " && ! gproxy -> m_BNET -> GetReplyTarget ( ) . empty ( ) ) { widget . inputTextArea -> setPlainText ( " " + QString :: fromStdString ( gproxy -> m_BNET -> GetReplyTarget ( ) ) ) ; widget . inputTextArea -> moveCursor ( QTextCursor :: End ) ; } return false ; }
A key on the input text area was pressed.
A key on the input text area was pressed .
// Do not delegate this event (add text) to the text area. // Fix of not sending whispers correctly when you have \n on the input text // Detect Whisper // Add /w [NAME] command on each line // Do not delegate this event (add text) to the text area.