Fix split focusing being broken in certain circumstances when the "Show input when it's empty" setting was disabled (#3838)

Co-authored-by: Kasia <zneix@zneix.eu>
This commit is contained in:
pajlada
2022-06-26 18:53:09 +02:00
committed by GitHub
parent 8bdfbf7b87
commit 6599009e79
13 changed files with 151 additions and 57 deletions
+39 -7
View File
@@ -133,7 +133,10 @@ void SplitInput::scaleChangedEvent(float scale)
this->updateEmoteButton();
// set maximum height
this->setMaximumHeight(int(150 * this->scale()));
if (!this->hidden)
{
this->setMaximumHeight(this->scaledMaxHeight());
}
this->ui_.textEdit->setFont(
getApp()->fonts->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.textEditLength->setFont(
@@ -214,6 +217,11 @@ void SplitInput::openEmotePopup()
this->emotePopup_->activateWindow();
}
int SplitInput::scaledMaxHeight() const
{
return int(150 * this->scale());
}
void SplitInput::addShortcuts()
{
HotkeyController::HotkeyMap actions{
@@ -686,6 +694,35 @@ void SplitInput::insertText(const QString &text)
this->ui_.textEdit->insertPlainText(text);
}
void SplitInput::hide()
{
if (this->isHidden())
{
return;
}
this->hidden = true;
this->setMaximumHeight(0);
this->updateGeometry();
}
void SplitInput::show()
{
if (!this->isHidden())
{
return;
}
this->hidden = false;
this->setMaximumHeight(this->scaledMaxHeight());
this->updateGeometry();
}
bool SplitInput::isHidden() const
{
return this->hidden;
}
void SplitInput::editTextChanged()
{
auto app = getApp();
@@ -734,7 +771,7 @@ void SplitInput::editTextChanged()
this->ui_.textEditLength->setText(labelText);
}
void SplitInput::paintEvent(QPaintEvent *)
void SplitInput::paintEvent(QPaintEvent * /*event*/)
{
QPainter painter(this);
@@ -777,9 +814,4 @@ void SplitInput::resizeEvent(QResizeEvent *)
}
}
void SplitInput::mousePressEvent(QMouseEvent *)
{
this->split_->giveFocus(Qt::MouseFocusReason);
}
} // namespace chatterino