Refactor font update logic in SplitInput (#6473)
This commit is contained in:
@@ -213,15 +213,10 @@ void SplitInput::initLayout()
|
|||||||
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
|
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
|
||||||
&SplitInput::onTextChanged);
|
&SplitInput::onTextChanged);
|
||||||
|
|
||||||
this->managedConnections_.managedConnect(
|
this->managedConnections_.managedConnect(app->getFonts()->fontChanged,
|
||||||
app->getFonts()->fontChanged, [=, this]() {
|
[this] {
|
||||||
this->ui_.textEdit->setFont(
|
this->updateFonts();
|
||||||
app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
|
});
|
||||||
this->ui_.textEditLength->setFont(app->getFonts()->getFont(
|
|
||||||
FontStyle::TimestampMedium, this->scale()));
|
|
||||||
this->ui_.replyLabel->setFont(app->getFonts()->getFont(
|
|
||||||
FontStyle::ChatMediumBold, this->scale()));
|
|
||||||
});
|
|
||||||
|
|
||||||
// open emote popup
|
// open emote popup
|
||||||
QObject::connect(this->ui_.emoteButton, &Button::leftClicked, [this] {
|
QObject::connect(this->ui_.emoteButton, &Button::leftClicked, [this] {
|
||||||
@@ -277,15 +272,7 @@ void SplitInput::scaleChangedEvent(float scale)
|
|||||||
this->ui_.vbox->setSpacing(this->marginForTheme());
|
this->ui_.vbox->setSpacing(this->marginForTheme());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->ui_.textEdit->setFont(
|
this->updateFonts();
|
||||||
app->getFonts()->getFont(FontStyle::ChatMedium, scale));
|
|
||||||
|
|
||||||
// NOTE: We're using TimestampMedium here to get a font that uses the tnum font feature,
|
|
||||||
// meaning numbers get equal width & don't bounce around while the user is typing.
|
|
||||||
this->ui_.textEditLength->setFont(
|
|
||||||
app->getFonts()->getFont(FontStyle::TimestampMedium, scale));
|
|
||||||
this->ui_.replyLabel->setFont(
|
|
||||||
app->getFonts()->getFont(FontStyle::ChatMediumBold, scale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitInput::themeChangedEvent()
|
void SplitInput::themeChangedEvent()
|
||||||
@@ -1339,4 +1326,18 @@ void SplitInput::setBackgroundColor(QColor newColor)
|
|||||||
this->updateTextEditPalette();
|
this->updateTextEditPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitInput::updateFonts()
|
||||||
|
{
|
||||||
|
auto *app = getApp();
|
||||||
|
this->ui_.textEdit->setFont(
|
||||||
|
app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
|
||||||
|
|
||||||
|
// NOTE: We're using TimestampMedium here to get a font that uses the tnum font feature,
|
||||||
|
// meaning numbers get equal width & don't bounce around while the user is typing.
|
||||||
|
this->ui_.textEditLength->setFont(
|
||||||
|
app->getFonts()->getFont(FontStyle::TimestampMedium, this->scale()));
|
||||||
|
this->ui_.replyLabel->setFont(
|
||||||
|
app->getFonts()->getFont(FontStyle::ChatMediumBold, this->scale()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -188,6 +188,8 @@ protected:
|
|||||||
|
|
||||||
QPropertyAnimation backgroundColorAnimation;
|
QPropertyAnimation backgroundColorAnimation;
|
||||||
|
|
||||||
|
void updateFonts();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void editTextChanged();
|
void editTextChanged();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user