mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
arrow up to paste previous message
This commit is contained in:
parent
7f01288eb4
commit
fe8f6593c7
@ -143,6 +143,8 @@ void ChatForm::onSendTriggered()
|
||||
rec = Core::getInstance()->sendMessage(f->getFriendID(), qt_msg);
|
||||
|
||||
registerReceipt(rec, id, ma);
|
||||
|
||||
msgEdit->setLastMessage(msg); //set last message only when sending it
|
||||
}
|
||||
|
||||
msgEdit->clear();
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "chattextedit.h"
|
||||
#include <QKeyEvent>
|
||||
#include <QDebug>
|
||||
|
||||
ChatTextEdit::ChatTextEdit(QWidget *parent) :
|
||||
QTextEdit(parent)
|
||||
@ -31,9 +32,31 @@ void ChatTextEdit::keyPressEvent(QKeyEvent * event)
|
||||
emit enterPressed();
|
||||
else if (key == Qt::Key_Tab)
|
||||
emit tabPressed();
|
||||
else if (key == Qt::Key_Up && this->toPlainText().isEmpty())
|
||||
{
|
||||
this->setText(lastMessage);
|
||||
this->setFocus();
|
||||
}
|
||||
else if (key == Qt::Key_Up && !this->toPlainText().isEmpty())
|
||||
{
|
||||
currentMessage = this->toPlainText();
|
||||
this->setText(lastMessage);
|
||||
}
|
||||
else if (key == Qt::Key_Down && !currentMessage.isEmpty())
|
||||
{
|
||||
this->setPlainText(currentMessage);
|
||||
currentMessage.clear();
|
||||
}
|
||||
else if (key == Qt::Key_Down)
|
||||
this->clear();
|
||||
else
|
||||
{
|
||||
emit keyPressed();
|
||||
QTextEdit::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTextEdit::setLastMessage(QString lm)
|
||||
{
|
||||
lastMessage = lm;
|
||||
}
|
||||
|
@ -25,13 +25,16 @@ class ChatTextEdit : public QTextEdit
|
||||
public:
|
||||
explicit ChatTextEdit(QWidget *parent = 0);
|
||||
virtual void keyPressEvent(QKeyEvent * event) override;
|
||||
|
||||
void setLastMessage(QString lm);
|
||||
|
||||
signals:
|
||||
void enterPressed();
|
||||
void tabPressed();
|
||||
void keyPressed();
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QString lastMessage,
|
||||
currentMessage;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user