mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
parent
ef9aedb2cd
commit
151ff057a6
3 changed files with 30 additions and 0 deletions
|
@ -198,6 +198,11 @@ void SplitInput::clearSelection()
|
|||
this->textInput.setTextCursor(c);
|
||||
}
|
||||
|
||||
QString SplitInput::getInputText() const
|
||||
{
|
||||
return this->textInput.toPlainText();
|
||||
}
|
||||
|
||||
void SplitInput::refreshTheme()
|
||||
{
|
||||
QPalette palette;
|
||||
|
@ -213,6 +218,8 @@ void SplitInput::editTextChanged()
|
|||
{
|
||||
QString text = this->textInput.toPlainText();
|
||||
|
||||
this->textChanged.invoke(text);
|
||||
|
||||
text = text.trimmed();
|
||||
static QRegularExpression spaceRegex("\\s\\s+");
|
||||
text = text.replace(spaceRegex, " ");
|
||||
|
|
|
@ -26,6 +26,9 @@ public:
|
|||
SplitInput(Split *_chatWidget);
|
||||
|
||||
void clearSelection();
|
||||
QString getInputText() const;
|
||||
|
||||
pajlada::Signals::Signal<const QString &> textChanged;
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
|
|
|
@ -96,6 +96,26 @@ Split::Split(ChannelManager &_channelManager, SplitContainer *parent)
|
|||
this->input.clearSelection();
|
||||
}
|
||||
});
|
||||
|
||||
this->input.textChanged.connect([this](const QString &newText) {
|
||||
if (!SettingsManager::getInstance().hideEmptyInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newText.length() == 0) {
|
||||
this->input.hide();
|
||||
} else if (this->input.isHidden()) {
|
||||
this->input.show();
|
||||
}
|
||||
});
|
||||
|
||||
SettingsManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) {
|
||||
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
||||
this->input.hide();
|
||||
} else {
|
||||
this->input.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Split::~Split()
|
||||
|
|
Loading…
Reference in a new issue