1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'pr1053'

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-26 14:01:20 +01:00
commit 1b2b4a1267
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 5 additions and 22 deletions

View File

@ -25,32 +25,17 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
}
void ChatTextEdit::keyPressEvent(QKeyEvent * event)
{
{
int key = event->key();
if ((key == Qt::Key_Enter || key == Qt::Key_Return) && !(event->modifiers() && Qt::ShiftModifier))
emit enterPressed();
else if (key == Qt::Key_Tab)
emit tabPressed();
/**
If message box is empty, it will paste previous message on arrow up
if message box is not empty,
it will copy current(2) text and paste previous(1) message,
to paste previous message(2) press arrow down,
press arrow down twice to clear mesage box,
only previous message(1) is available to paste now.
*/
else if (key == Qt::Key_Up && this->toPlainText().isEmpty())
this->setText(lastMessage);
else if (key == Qt::Key_Up && !this->toPlainText().isEmpty()
&& lastMessage != this->toPlainText())
{
currentMessage = this->toPlainText();
this->setText(lastMessage);
}
else if (key == Qt::Key_Down && !currentMessage.isEmpty())
{
this->setPlainText(currentMessage);
currentMessage.clear();
this->setFocus();
this->moveCursor(QTextCursor::MoveOperation::End,QTextCursor::MoveMode::MoveAnchor);
}
else
{

View File

@ -31,11 +31,9 @@ signals:
void enterPressed();
void tabPressed();
void keyPressed();
private:
QString lastMessage,
currentMessage;
private:
QString lastMessage;
};
#endif // CHATTEXTEDIT_H