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

Merge branch 'pr1048'

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-26 02:02:12 +01:00
commit 350da58337
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 34 additions and 3 deletions

View File

@ -143,6 +143,8 @@ void ChatForm::onSendTriggered()
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg); rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
registerReceipt(rec, id, ma); registerReceipt(rec, id, ma);
msgEdit->setLastMessage(msg); //set last message only when sending it
} }
msgEdit->clear(); msgEdit->clear();

View File

@ -31,9 +31,35 @@ void ChatTextEdit::keyPressEvent(QKeyEvent * event)
emit enterPressed(); emit enterPressed();
else if (key == Qt::Key_Tab) else if (key == Qt::Key_Tab)
emit tabPressed(); 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();
}
else else
{ {
emit keyPressed(); emit keyPressed();
QTextEdit::keyPressEvent(event); QTextEdit::keyPressEvent(event);
} }
} }
void ChatTextEdit::setLastMessage(QString lm)
{
lastMessage = lm;
}

View File

@ -25,13 +25,16 @@ class ChatTextEdit : public QTextEdit
public: public:
explicit ChatTextEdit(QWidget *parent = 0); explicit ChatTextEdit(QWidget *parent = 0);
virtual void keyPressEvent(QKeyEvent * event) override; virtual void keyPressEvent(QKeyEvent * event) override;
void setLastMessage(QString lm);
signals: signals:
void enterPressed(); void enterPressed();
void tabPressed(); void tabPressed();
void keyPressed(); void keyPressed();
public slots: private:
QString lastMessage,
currentMessage;
}; };