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)
|
, _st(st)
|
||||||
, _text(text)
|
, _text(text)
|
||||||
, _textWidth(st.font->width(_text)) {
|
, _textWidth(st.font->width(_text)) {
|
||||||
resize(
|
resizeToText();
|
||||||
naturalWidth(),
|
|
||||||
_st.padding.top() + _st.font->height + _st.padding.bottom());
|
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,10 +57,16 @@ void LinkButton::paintEvent(QPaintEvent *e) {
|
||||||
void LinkButton::setText(const QString &text) {
|
void LinkButton::setText(const QString &text) {
|
||||||
_text = text;
|
_text = text;
|
||||||
_textWidth = _st.font->width(_text);
|
_textWidth = _st.font->width(_text);
|
||||||
resize(naturalWidth(), _st.font->height);
|
resizeToText();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinkButton::resizeToText() {
|
||||||
|
resize(
|
||||||
|
naturalWidth(),
|
||||||
|
_st.padding.top() + _st.font->height + _st.padding.bottom());
|
||||||
|
}
|
||||||
|
|
||||||
void LinkButton::setColorOverride(std::optional<QColor> textFg) {
|
void LinkButton::setColorOverride(std::optional<QColor> textFg) {
|
||||||
_textFgOverride = textFg;
|
_textFgOverride = textFg;
|
||||||
update();
|
update();
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ protected:
|
||||||
void onStateChanged(State was, StateChangeSource source) override;
|
void onStateChanged(State was, StateChangeSource source) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void resizeToText();
|
||||||
|
|
||||||
const style::LinkButton &_st;
|
const style::LinkButton &_st;
|
||||||
QString _text;
|
QString _text;
|
||||||
int _textWidth = 0;
|
int _textWidth = 0;
|
||||||
|
|
|
||||||
|
|
@ -1016,6 +1016,7 @@ SettingsSlider {
|
||||||
labelStyle: TextStyle;
|
labelStyle: TextStyle;
|
||||||
labelFg: color;
|
labelFg: color;
|
||||||
labelFgActive: color;
|
labelFgActive: color;
|
||||||
|
strictSkip: pixels;
|
||||||
duration: int;
|
duration: int;
|
||||||
rippleBottomSkip: pixels;
|
rippleBottomSkip: pixels;
|
||||||
rippleBg: color;
|
rippleBg: color;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue