mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Limit attached emoji phrase to two lines.
This commit is contained in:
parent
d80cf5d149
commit
7a61693034
2 changed files with 26 additions and 3 deletions
|
@ -1267,6 +1267,7 @@ void AddEmojiPacksAction(
|
|||
, _dummyAction(new QAction(parent)) {
|
||||
enableMouseSelecting();
|
||||
_text->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
updateMinWidth();
|
||||
parent->widthValue() | rpl::start_with_next([=](int width) {
|
||||
const auto top = st::historyHasCustomEmojiPosition.y();
|
||||
const auto skip = st::historyHasCustomEmojiPosition.x();
|
||||
|
@ -1297,6 +1298,28 @@ void AddEmojiPacksAction(
|
|||
RippleButton::paintRipple(p, 0, 0);
|
||||
}
|
||||
|
||||
void updateMinWidth() {
|
||||
const auto skip = st::historyHasCustomEmojiPosition.x();
|
||||
auto min = _text->naturalWidth() / 2;
|
||||
auto max = _text->naturalWidth() - skip;
|
||||
_text->resizeToWidth(max);
|
||||
const auto height = _text->height();
|
||||
_text->resizeToWidth(min);
|
||||
const auto heightMax = _text->height();
|
||||
if (heightMax > height) {
|
||||
while (min + 1 < max) {
|
||||
const auto middle = (max + min) / 2;
|
||||
_text->resizeToWidth(middle);
|
||||
if (_text->height() > height) {
|
||||
min = middle;
|
||||
} else {
|
||||
max = middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
setMinWidth(skip * 2 + max);
|
||||
}
|
||||
|
||||
const style::Menu &_st;
|
||||
const base::unique_qptr<Ui::FlatLabel> _text;
|
||||
const not_null<QAction*> _dummyAction;
|
||||
|
|
|
@ -1090,9 +1090,9 @@ msgServiceGiftBoxStickerSize: size(140px, 140px);
|
|||
|
||||
historyHasCustomEmoji: FlatLabel(defaultFlatLabel) {
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
font: font(12px);
|
||||
linkFont: font(12px underline);
|
||||
linkFontOver: font(12px underline);
|
||||
font: font(11px);
|
||||
linkFont: font(11px underline);
|
||||
linkFontOver: font(11px underline);
|
||||
}
|
||||
minWidth: 80px;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue