mirror of https://github.com/procxx/kepka.git
parent
04617e4a12
commit
7be286751b
|
@ -17,10 +17,10 @@ Widget::Widget(QWidget *parent, const Config &config) : TWidget(parent)
|
|||
, _multiline(config.multiline)
|
||||
, _maxWidth((config.maxWidth > 0) ? config.maxWidth : st::toastMaxWidth)
|
||||
, _padding((config.padding.left() > 0) ? config.padding : st::toastPadding)
|
||||
, _maxTextWidth(_maxWidth - _padding.left() - _padding.right())
|
||||
, _maxTextWidth(widthWithoutPadding(_maxWidth))
|
||||
, _maxTextHeight(
|
||||
st::toastTextStyle.font->height * (_multiline ? config.maxLines : 1))
|
||||
, _text(_multiline ? config.minWidth : QFIXED_MAX) {
|
||||
, _text(_multiline ? widthWithoutPadding(config.minWidth) : QFIXED_MAX) {
|
||||
const auto toastOptions = TextParseOptions{
|
||||
TextParseMultiline,
|
||||
_maxTextWidth,
|
||||
|
@ -42,7 +42,7 @@ void Widget::onParentResized() {
|
|||
auto newWidth = _maxWidth;
|
||||
accumulate_min(newWidth, _padding.left() + _text.maxWidth() + _padding.right());
|
||||
accumulate_min(newWidth, parentWidget()->width() - 2 * st::toastMinMargin);
|
||||
_textWidth = newWidth - _padding.left() - _padding.right();
|
||||
_textWidth = widthWithoutPadding(newWidth);
|
||||
const auto textHeight = _multiline
|
||||
? qMin(_text.countHeight(_textWidth), _maxTextHeight)
|
||||
: _text.minHeight();
|
||||
|
|
|
@ -28,6 +28,10 @@ protected:
|
|||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
inline int widthWithoutPadding(int w) {
|
||||
return w - _padding.left() - _padding.right();
|
||||
}
|
||||
|
||||
float64 _shownLevel = 0;
|
||||
bool _multiline = false;
|
||||
int _maxWidth = 0;
|
||||
|
|
Loading…
Reference in New Issue