mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
* Implemented CTRL-Enter not erasing the input * Added arrow Up and Down cycling through past messages. * Disabled CTRL+Enter adding messages more than once.
This commit is contained in:
parent
3bf111a091
commit
23eb42013b
|
@ -57,10 +57,34 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget)
|
|||
if (c == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
c->sendMessage(textInput.toPlainText());
|
||||
prevMsg.append(textInput.toPlainText());
|
||||
event->accept();
|
||||
if(!(event->modifiers() == Qt::ControlModifier))
|
||||
{
|
||||
textInput.setText(QString());
|
||||
prevIndex = 0;
|
||||
}
|
||||
else if(textInput.toPlainText() == prevMsg.at(prevMsg.size()-1))
|
||||
{
|
||||
prevMsg.removeLast();
|
||||
}
|
||||
prevIndex = prevMsg.size();
|
||||
}
|
||||
else if(event->key() == Qt::Key_Up){
|
||||
if(prevMsg.size() && prevIndex){
|
||||
prevIndex--;
|
||||
textInput.setText(prevMsg.at(prevIndex));
|
||||
}
|
||||
}
|
||||
else if(event->key() == Qt::Key_Down){
|
||||
if(prevIndex != (prevMsg.size() - 1) && prevIndex != prevMsg.size()){
|
||||
prevIndex++;
|
||||
textInput.setText(prevMsg.at(prevIndex));
|
||||
} else {
|
||||
prevIndex = prevMsg.size();
|
||||
textInput.setText(QString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ private:
|
|||
ResizingTextEdit textInput;
|
||||
QLabel textLengthLabel;
|
||||
ChatWidgetHeaderButton emotesLabel;
|
||||
|
||||
QStringList prevMsg;
|
||||
unsigned int prevIndex = 0;
|
||||
virtual void refreshTheme() override;
|
||||
|
||||
private slots:
|
||||
|
|
Loading…
Reference in a new issue