From a1cd315ac88a2ffbb40c96427d07f424cc05a4db Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 8 Apr 2018 14:33:45 +0200 Subject: [PATCH] Fixes #288 arrow up behaviour --- src/widgets/helper/splitinput.cpp | 15 ++++++++++++++- src/widgets/helper/splitinput.hpp | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/widgets/helper/splitinput.cpp b/src/widgets/helper/splitinput.cpp index 3a8a21827..69a94e185 100644 --- a/src/widgets/helper/splitinput.cpp +++ b/src/widgets/helper/splitinput.cpp @@ -150,6 +150,7 @@ void SplitInput::installKeyPressedEvent() event->accept(); if (!(event->modifiers() == Qt::ControlModifier)) { + this->currMsg = QString(); this->ui.textEdit->setText(QString()); this->prevIndex = 0; } else if (this->ui.textEdit->toPlainText() == @@ -170,8 +171,16 @@ void SplitInput::installKeyPressedEvent() page->requestFocus(reqX, reqY); } else { if (this->prevMsg.size() && this->prevIndex) { + if (this->prevIndex == (this->prevMsg.size())) { + this->currMsg = ui.textEdit->toPlainText(); + } + this->prevIndex--; this->ui.textEdit->setText(this->prevMsg.at(this->prevIndex)); + + QTextCursor cursor = this->ui.textEdit->textCursor(); + cursor.movePosition(QTextCursor::End); + this->ui.textEdit->setTextCursor(cursor); } } } else if (event->key() == Qt::Key_Down) { @@ -192,8 +201,12 @@ void SplitInput::installKeyPressedEvent() this->ui.textEdit->setText(this->prevMsg.at(this->prevIndex)); } else { this->prevIndex = this->prevMsg.size(); - this->ui.textEdit->setText(QString()); + this->ui.textEdit->setText(this->currMsg); } + + QTextCursor cursor = this->ui.textEdit->textCursor(); + cursor.movePosition(QTextCursor::End); + this->ui.textEdit->setTextCursor(cursor); } } else if (event->key() == Qt::Key_Left) { if (event->modifiers() == Qt::AltModifier) { diff --git a/src/widgets/helper/splitinput.hpp b/src/widgets/helper/splitinput.hpp index 9718b984e..a4c9e45c8 100644 --- a/src/widgets/helper/splitinput.hpp +++ b/src/widgets/helper/splitinput.hpp @@ -59,6 +59,7 @@ private: // QLabel textLengthLabel; // RippleEffectLabel emotesLabel; QStringList prevMsg; + QString currMsg; int prevIndex = 0; void initLayout();