fix message length label, fixes #140

This commit is contained in:
2017-12-17 02:40:05 +01:00
parent 202cdeaefb
commit 31a76e46d1

View file

@ -45,7 +45,7 @@ SplitInput::SplitInput(Split *_chatWidget, EmoteManager &emoteManager, WindowMan
this->vbox.addStretch(1); this->vbox.addStretch(1);
this->vbox.addWidget(&this->emotesLabel); this->vbox.addWidget(&this->emotesLabel);
this->textLengthLabel.setText("100"); this->textLengthLabel.setText("");
this->textLengthLabel.setAlignment(Qt::AlignRight); this->textLengthLabel.setAlignment(Qt::AlignRight);
this->emotesLabel.getLabel().setTextFormat(Qt::RichText); this->emotesLabel.getLabel().setTextFormat(Qt::RichText);
@ -220,6 +220,21 @@ void SplitInput::refreshTheme()
void SplitInput::editTextChanged() void SplitInput::editTextChanged()
{ {
QString text = this->textInput.toPlainText();
text = text.trimmed();
static QRegularExpression spaceRegex("\\s\\s+");
text = text.replace(spaceRegex, " ");
QString labelText;
if (text.length() == 0) {
labelText = "";
} else {
labelText = QString::number(text.length());
}
this->textLengthLabel.setText(labelText);
} }
void SplitInput::paintEvent(QPaintEvent *) void SplitInput::paintEvent(QPaintEvent *)