#ifndef WRITING_BOX_H
#define WRITING_BOX_H

#include <QtGui>

/// Widget for writing messages in ChatWidget
/** Widget for writing messages in ChatWidget. It is standard QPlainTextEdit, but
it does not uses enter as a line break, but as a signal to send message
*/
class WritingTextBox : public QPlainTextEdit {
	Q_OBJECT
public:
	WritingTextBox(QWidget * parent) : QPlainTextEdit(parent) {
	}
protected:
	virtual void keyPressEvent (QKeyEvent * keyEvent) {		
		if (keyEvent->modifiers() != Qt::ControlModifier && (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)) {
			emit confirmMessageSignal();
		}
		else {
			QPlainTextEdit::keyPressEvent(keyEvent);
		}
	}
signals:
	void confirmMessageSignal();
};

#endif