Fixed adjustment of menu with single item.
This commit is contained in:
parent
e14bc4681d
commit
9d57ba47b0
1 changed files with 15 additions and 13 deletions
|
|
@ -126,22 +126,24 @@ not_null<QAction*> Menu::addAction(base::unique_qptr<ItemBase> widget) {
|
||||||
}
|
}
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
|
|
||||||
widget->minWidthValue(
|
const auto raw = widget.get();
|
||||||
) | rpl::start_with_next([=](int minWidth) {
|
_actionWidgets.push_back(std::move(widget));
|
||||||
|
|
||||||
|
raw->minWidthValue(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
const auto newWidth = _forceWidth
|
const auto newWidth = _forceWidth
|
||||||
? _forceWidth
|
? _forceWidth
|
||||||
: _actionWidgets.empty()
|
: std::clamp(
|
||||||
? _st.widthMin
|
_actionWidgets.empty()
|
||||||
: std::max(
|
? 0
|
||||||
minWidth,
|
: (*ranges::max_element(
|
||||||
(*ranges::max_element(
|
_actionWidgets,
|
||||||
_actionWidgets,
|
std::less<>(),
|
||||||
std::less<>(),
|
&ItemBase::minWidth))->minWidth(),
|
||||||
&ItemBase::minWidth))->minWidth());
|
_st.widthMin,
|
||||||
|
_st.widthMax);
|
||||||
resizeFromInner(newWidth, height());
|
resizeFromInner(newWidth, height());
|
||||||
}, widget->lifetime());
|
}, raw->lifetime());
|
||||||
|
|
||||||
_actionWidgets.push_back(std::move(widget));
|
|
||||||
|
|
||||||
const auto newHeight = ranges::accumulate(
|
const auto newHeight = ranges::accumulate(
|
||||||
_actionWidgets,
|
_actionWidgets,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue