Beispiel #1
0
bool FriendsDialog::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == ui.lineEdit) {
        if (event->type() == QEvent::KeyPress) {
            updateStatusTyping() ;

            QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
            if (keyEvent && (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)) {
                // Enter pressed
                if (Settings->getChatSendMessageWithCtrlReturn()) {
                    if (keyEvent->modifiers() & Qt::ControlModifier) {
                        // send message with Ctrl+Enter
                        sendMsg();
                        return true; // eat event
                    }
                } else {
                    if (keyEvent->modifiers() & Qt::ControlModifier) {
                        // insert return
                        ui.lineEdit->textCursor().insertText("\n");
                    } else {
                        // send message with Enter
                        sendMsg();
                    }
                    return true; // eat event
                }
            }
        }
    }
    // pass the event on to the parent class
    return RsAutoUpdatePage::eventFilter(obj, event);
}
void PopupChatDialog::checkChat()
{
	/* if <return> at the end of the text -> we can send it! */
	QTextEdit *chatWidget = ui.chattextEdit;
	std::string txt = chatWidget->toPlainText().toStdString();
	if ('\n' == txt[txt.length()-1] && txt.length()-1 == txt.find('\n')) /* only if on first line! */
		sendChat();
	else
		updateStatusTyping() ;
}
Beispiel #3
0
bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
{
	if (obj == ui->chatTextEdit) {
		if (event->type() == QEvent::KeyPress) {
			updateStatusTyping();

			QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
			if (keyEvent && (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)) {
				// Enter pressed
				if (Settings->getChatSendMessageWithCtrlReturn()) {
					if (keyEvent->modifiers() & Qt::ControlModifier) {
						// send message with Ctrl+Enter
						sendChat();
						return true; // eat event
					}
				} else {
					if (keyEvent->modifiers() & Qt::ControlModifier) {
						// insert return
						ui->chatTextEdit->textCursor().insertText("\n");
					} else {
						// send message with Enter
						sendChat();
					}
					return true; // eat event
				}
			}
		}
	} else {
		if (event->type() == QEvent::WindowActivate) {
			if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
				newMessages = false;
				emit infoChanged(this);
				focusDialog();
			}
		}
	}
	// pass the event on to the parent class
	return QWidget::eventFilter(obj, event);
}