mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Improve popup menu dimensions.
This commit is contained in:
parent
a377364621
commit
2733b12cff
1 changed files with 25 additions and 15 deletions
|
@ -233,14 +233,6 @@ Action::Action(
|
|||
|
||||
setAcceptBoth(true);
|
||||
initResizeHook(parent->sizeValue());
|
||||
resolveMinWidth();
|
||||
|
||||
_userpics->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
_userpicsWidth = width;
|
||||
refreshDimensions();
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
std::move(
|
||||
content
|
||||
|
@ -263,6 +255,15 @@ Action::Action(
|
|||
update();
|
||||
}, lifetime());
|
||||
|
||||
resolveMinWidth();
|
||||
|
||||
_userpics->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
_userpicsWidth = width;
|
||||
refreshDimensions();
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
Painter p(this);
|
||||
|
@ -295,14 +296,20 @@ void Action::resolveMinWidth() {
|
|||
const auto width = [&](const QString &text) {
|
||||
return _st.itemStyle.font->width(text);
|
||||
};
|
||||
const auto maxTextWidth = std::max({
|
||||
width(tr::lng_context_seen_reacted(
|
||||
const auto maxText = (_content.type == WhoReadType::Listened)
|
||||
? tr::lng_context_seen_listened(tr::now, lt_count, 999)
|
||||
: (_content.type == WhoReadType::Watched)
|
||||
? tr::lng_context_seen_watched(tr::now, lt_count, 999)
|
||||
: (_content.type == WhoReadType::Seen)
|
||||
? tr::lng_context_seen_text(tr::now, lt_count, 999)
|
||||
: QString();
|
||||
const auto maxReacted = (_content.fullReactionsCount > 0)
|
||||
? tr::lng_context_seen_reacted(
|
||||
tr::now,
|
||||
lt_count_short,
|
||||
999'999'999)),
|
||||
width(tr::lng_context_seen_text(tr::now, lt_count, 999)),
|
||||
width(tr::lng_context_seen_listened(tr::now, lt_count, 999)),
|
||||
width(tr::lng_context_seen_watched(tr::now, lt_count, 999)) });
|
||||
_content.fullReactionsCount)
|
||||
: QString();
|
||||
const auto maxTextWidth = std::max(width(maxText), width(maxReacted));
|
||||
const auto maxWidth = st::defaultWhoRead.itemPadding.left()
|
||||
+ maxIconWidth
|
||||
+ maxTextWidth
|
||||
|
@ -480,6 +487,9 @@ void Action::refreshText() {
|
|||
}
|
||||
|
||||
void Action::refreshDimensions() {
|
||||
if (!minWidth()) {
|
||||
return;
|
||||
}
|
||||
const auto textWidth = _text.maxWidth();
|
||||
const auto &padding = st::defaultWhoRead.itemPadding;
|
||||
|
||||
|
@ -491,7 +501,7 @@ void Action::refreshDimensions() {
|
|||
const auto w = std::clamp(
|
||||
goodWidth,
|
||||
_st.widthMin,
|
||||
minWidth());
|
||||
std::max(minWidth(), _st.widthMin));
|
||||
_textWidth = w - (goodWidth - textWidth);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue