Fix resizing LinkButton with padding.
This commit is contained in:
parent
372543de6e
commit
eab785a1c8
3 changed files with 11 additions and 4 deletions
|
|
@ -25,9 +25,7 @@ LinkButton::LinkButton(
|
|||
, _st(st)
|
||||
, _text(text)
|
||||
, _textWidth(st.font->width(_text)) {
|
||||
resize(
|
||||
naturalWidth(),
|
||||
_st.padding.top() + _st.font->height + _st.padding.bottom());
|
||||
resizeToText();
|
||||
setCursor(style::cur_pointer);
|
||||
}
|
||||
|
||||
|
|
@ -59,10 +57,16 @@ void LinkButton::paintEvent(QPaintEvent *e) {
|
|||
void LinkButton::setText(const QString &text) {
|
||||
_text = text;
|
||||
_textWidth = _st.font->width(_text);
|
||||
resize(naturalWidth(), _st.font->height);
|
||||
resizeToText();
|
||||
update();
|
||||
}
|
||||
|
||||
void LinkButton::resizeToText() {
|
||||
resize(
|
||||
naturalWidth(),
|
||||
_st.padding.top() + _st.font->height + _st.padding.bottom());
|
||||
}
|
||||
|
||||
void LinkButton::setColorOverride(std::optional<QColor> textFg) {
|
||||
_textFgOverride = textFg;
|
||||
update();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ protected:
|
|||
void onStateChanged(State was, StateChangeSource source) override;
|
||||
|
||||
private:
|
||||
void resizeToText();
|
||||
|
||||
const style::LinkButton &_st;
|
||||
QString _text;
|
||||
int _textWidth = 0;
|
||||
|
|
|
|||
|
|
@ -1016,6 +1016,7 @@ SettingsSlider {
|
|||
labelStyle: TextStyle;
|
||||
labelFg: color;
|
||||
labelFgActive: color;
|
||||
strictSkip: pixels;
|
||||
duration: int;
|
||||
rippleBottomSkip: pixels;
|
||||
rippleBg: color;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue