diff --git a/Telegram/SourceFiles/core/kotato_settings.cpp b/Telegram/SourceFiles/core/kotato_settings.cpp index 74d0b348c..fe0f9ef13 100644 --- a/Telegram/SourceFiles/core/kotato_settings.cpp +++ b/Telegram/SourceFiles/core/kotato_settings.cpp @@ -154,11 +154,11 @@ bool Manager::readCustomFile() { const auto settingsAdaptiveBubblesIt = settings.constFind(qsl("adaptive_bubbles")); if (settingsAdaptiveBubblesIt != settings.constEnd() && (*settingsAdaptiveBubblesIt).isBool()) { - cSetAdaptiveBubbles((*settingsAdaptiveBubblesIt).toBool()); + SetAdaptiveBubbles((*settingsAdaptiveBubblesIt).toBool()); } else { const auto settingsAdaptiveBaloonsIt = settings.constFind(qsl("adaptive_baloons")); if (settingsAdaptiveBaloonsIt != settings.constEnd() && (*settingsAdaptiveBaloonsIt).isBool()) { - cSetAdaptiveBubbles((*settingsAdaptiveBaloonsIt).toBool()); + SetAdaptiveBubbles((*settingsAdaptiveBaloonsIt).toBool()); } } @@ -258,7 +258,7 @@ void Manager::writeDefaultFile() { settings.insert(qsl("fonts"), settingsFonts); settings.insert(qsl("sticker_height"), StickerHeight()); - settings.insert(qsl("adaptive_bubbles"), cAdaptiveBubbles()); + settings.insert(qsl("adaptive_bubbles"), AdaptiveBubbles()); settings.insert(qsl("big_emoji_outline"), BigEmojiOutline()); settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled()); settings.insert(qsl("show_chat_id"), cShowChatId()); @@ -312,7 +312,7 @@ void Manager::writeCurrentSettings() { settings.insert(qsl("fonts"), settingsFonts); settings.insert(qsl("sticker_height"), StickerHeight()); - settings.insert(qsl("adaptive_bubbles"), cAdaptiveBubbles()); + settings.insert(qsl("adaptive_bubbles"), AdaptiveBubbles()); settings.insert(qsl("big_emoji_outline"), BigEmojiOutline()); settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled()); settings.insert(qsl("show_chat_id"), cShowChatId()); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 1a012f462..5f2e8c104 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2048,7 +2048,7 @@ void HistoryInner::recountHistoryGeometry() { updateBotInfo(false); if (_botAbout && !_botAbout->info->text.isEmpty()) { int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); - if (!cAdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth; + if (!AdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth; tw -= st::msgPadding.left() + st::msgPadding.right(); int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now))); if (tw > mw) tw = mw; @@ -2058,7 +2058,7 @@ void HistoryInner::recountHistoryGeometry() { int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); int32 descMaxWidth = _scroll->width(); - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); } int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); @@ -2095,7 +2095,7 @@ void HistoryInner::updateBotInfo(bool recount) { Ui::ItemTextBotNoMonoOptions()); if (recount) { int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right(); - if (!cAdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth; + if (!AdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth; tw -= st::msgPadding.left() + st::msgPadding.right(); int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now))); if (tw > mw) tw = mw; @@ -2250,7 +2250,7 @@ void HistoryInner::updateSize() { if (_botAbout && _botAbout->height > 0) { int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom(); int32 descMaxWidth = _scroll->width(); - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); } int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left(); @@ -2582,7 +2582,7 @@ void HistoryInner::mouseActionUpdate() { dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right(); auto dateLeft = st::msgServiceMargin.left(); auto maxwidth = _contentWidth; - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); } auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index cffe054cc..71a6e5234 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -526,6 +526,13 @@ HistoryWidget::HistoryWidget( }); }, lifetime()); + AdaptiveBubblesChanges( + ) | rpl::start_with_next([=] { + crl::on_main(this, [=] { + updateHistoryGeometry(); + }); + }, lifetime()); + session().data().animationPlayInlineRequest( ) | rpl::start_with_next([=](not_null item) { if (const auto view = item->mainView()) { diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index d734092fe..fe005b2a9 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -166,7 +166,7 @@ void UnreadBar::paint(Painter &p, int y, int w) const { int left = st::msgServiceMargin.left(); int maxwidth = w; - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { maxwidth = qMin( maxwidth, st::msgMaxWidth diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index db814c798..1c744c480 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2156,7 +2156,7 @@ void ListWidget::mouseActionUpdate() { dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right(); auto dateLeft = st::msgServiceMargin.left(); auto maxwidth = view->width(); - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); } auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 2bf12003f..65f46b1ce 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1647,7 +1647,7 @@ QRect Message::countGeometry() const { // contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth); } accumulate_min(contentWidth, maxWidth()); - if (!cAdaptiveBubbles()) { + if (!AdaptiveBubbles()) { accumulate_min(contentWidth, st::msgMaxWidth); } if (mediaWidth < contentWidth) { @@ -1691,7 +1691,7 @@ int Message::resizeContentGetHeight(int newWidth) { contentWidth -= st::msgPhotoSkip; } accumulate_min(contentWidth, maxWidth()); - if (!cAdaptiveBubbles()) { + if (!AdaptiveBubbles()) { accumulate_min(contentWidth, st::msgMaxWidth); } if (mediaDisplayed) { @@ -1716,7 +1716,7 @@ int Message::resizeContentGetHeight(int newWidth) { auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/); auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop()); - if (!cAdaptiveBubbles() && contentWidth == maxWidth()) { + if (!AdaptiveBubbles() && contentWidth == maxWidth()) { if (mediaDisplayed) { if (entry) { newHeight += entry->resizeGetHeight(contentWidth); diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index 747610704..1d7f8e6d8 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -164,7 +164,7 @@ void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, int y, int w) { int left = st::msgServiceMargin.left(); int maxwidth = w; - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { maxwidth = qMin(maxwidth, WideChatWidth()); } w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left(); @@ -319,7 +319,7 @@ not_null Service::message() const { QRect Service::countGeometry() const { auto result = QRect(0, 0, width(), height()); - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left())); } return result.marginsRemoved(st::msgServiceMargin); @@ -342,7 +342,7 @@ QSize Service::performCountCurrentSize(int newWidth) { item->_textHeight = 0; } else { auto contentWidth = newWidth; - if (Adaptive::ChatWide() && !cAdaptiveBubbles()) { + if (Adaptive::ChatWide() && !AdaptiveBubbles()) { accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()); } contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index f1faf6b64..6bc12c46a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -181,7 +181,7 @@ QSize Document::countOptimalSize() { if (auto named = Get()) { accumulate_max(maxWidth, tleft + named->_namew + tright); - if (cAdaptiveBubbles() && captioned) { + if (AdaptiveBubbles() && captioned) { accumulate_max(maxWidth, captioned->_caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right()); } else { accumulate_min(maxWidth, st::msgMaxWidth); diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index c7d2e1576..66295c676 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -123,10 +123,10 @@ QSize Gif::countOptimalSize() { const auto size = style::ConvertScale(videoSize()); auto tw = size.width(); auto th = size.height(); - if ((!cAdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) { + if ((!AdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) { th = (maxSize * th) / tw; tw = maxSize; - } else if (cAdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) { + } else if (AdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) { th = (captionWithPaddings * th) / tw; tw = captionWithPaddings; } @@ -147,7 +147,7 @@ QSize Gif::countOptimalSize() { } if (_parent->hasBubble()) { if (!_caption.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { accumulate_max(maxWidth, captionWithPaddings); } auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right(); @@ -183,10 +183,10 @@ QSize Gif::countCurrentSize(int newWidth) { const auto size = style::ConvertScale(videoSize()); auto tw = size.width(); auto th = size.height(); - if ((!cAdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) { + if ((!AdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) { th = (maxSize * th) / tw; tw = maxSize; - } else if (cAdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) { + } else if (AdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) { th = (captionWithPaddings * th) / tw; tw = captionWithPaddings; } @@ -213,7 +213,7 @@ QSize Gif::countCurrentSize(int newWidth) { } if (_parent->hasBubble()) { if (!_caption.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { accumulate_max(newWidth, captionWithPaddings); accumulate_min(newWidth, availableWidth); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp index 8745b5b2d..d96754e8c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -61,13 +61,13 @@ QSize Location::countOptimalSize() { if (_parent->hasBubble()) { if (!_title.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { maxWidth = qMax(maxWidth, _title.maxWidth() + st::msgPadding.left() + st::msgPadding.right()); } minHeight += qMin(_title.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height); } if (!_description.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { maxWidth = qMax(maxWidth, _description.maxWidth() + st::msgPadding.left() + st::msgPadding.right()); } minHeight += qMin(_description.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height); @@ -94,7 +94,7 @@ QSize Location::countCurrentSize(int newWidth) { auto newHeight = th; if (tw > newWidth) { newHeight = (newWidth * newHeight / tw); - } else if (!cAdaptiveBubbles()) { + } else if (!AdaptiveBubbles()) { newWidth = tw; } else { newHeight = (newWidth * newHeight / tw); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index 85f10330a..166ab327e 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -80,7 +80,7 @@ QSize GroupedMedia::countOptimalSize() { + st::msgPadding.left() + st::msgPadding.right(); auto groupMaxWidth = st::historyGroupWidthMax; - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { accumulate_max(groupMaxWidth, captionWithPaddings); } @@ -102,7 +102,7 @@ QSize GroupedMedia::countOptimalSize() { } if (!_caption.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { maxWidth = qMax(maxWidth, captionWithPaddings); } auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 91228609a..6ff29e3ab 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -80,10 +80,10 @@ QSize Photo::countOptimalSize() { if (!tw || !th) { tw = th = 1; } - if ((!cAdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) { + if ((!AdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) { th = (st::maxMediaSize * th) / tw; tw = st::maxMediaSize; - } else if (cAdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) { + } else if (AdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) { th = (captionWithPaddings * th) / tw; tw = captionWithPaddings; } @@ -100,7 +100,7 @@ QSize Photo::countOptimalSize() { maxWidth = qMax(maxActualWidth, th); minHeight = qMax(th, st::minPhotoSize); if (_parent->hasBubble() && !_caption.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { maxActualWidth = qMax(maxActualWidth, captionWithPaddings); maxWidth = qMax(maxWidth, captionWithPaddings); } @@ -122,10 +122,10 @@ QSize Photo::countCurrentSize(int newWidth) { auto inWebPage = (_parent->media() != this); auto tw = style::ConvertScale(_data->width()); auto th = style::ConvertScale(_data->height()); - if ((!cAdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) { + if ((!AdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) { th = (st::maxMediaSize * th) / tw; tw = st::maxMediaSize; - } else if (cAdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) { + } else if (AdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) { th = (captionWithPaddings * th) / tw; tw = captionWithPaddings; } @@ -152,7 +152,7 @@ QSize Photo::countCurrentSize(int newWidth) { newWidth = qMax(_pixw, minWidth); auto newHeight = qMax(_pixh, st::minPhotoSize); if (_parent->hasBubble() && !_caption.isEmpty()) { - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { newWidth = qMax(newWidth, captionWithPaddings); newWidth = qMin(newWidth, availableWidth); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 2d6df09fe..84c744b71 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -278,7 +278,7 @@ QSize WebPage::countOptimalSize() { _durationWidth = st::msgDateFont->width(_duration); } maxWidth += st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); - if (cAdaptiveBubbles()) { + if (AdaptiveBubbles()) { accumulate_min(maxWidth, st::msgMaxWidth); accumulate_max(maxWidth, _parent->plainMaxWidth()); } @@ -296,7 +296,7 @@ QSize WebPage::countCurrentSize(int newWidth) { return { newWidth, minHeight() }; } - if (cAdaptiveBubbles() && !asArticle()) { + if (AdaptiveBubbles() && !asArticle()) { accumulate_min(newWidth, maxWidth()); } diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 9a59a4ce0..de2c629d2 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -232,7 +232,17 @@ rpl::producer BigEmojiOutlineChanges() { return gBigEmojiOutline.changes(); } -bool gAdaptiveBubbles = false; +rpl::variable gAdaptiveBubbles = false; +void SetAdaptiveBubbles(bool enabled) { + gAdaptiveBubbles = enabled; +} +bool AdaptiveBubbles() { + return gAdaptiveBubbles.current(); +} +rpl::producer AdaptiveBubblesChanges() { + return gAdaptiveBubbles.changes(); +} + bool gAlwaysShowScheduled = true; bool gShowChatId = true; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index fd6fa8f2f..71d4f7f13 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -192,7 +192,10 @@ void SetStickerHeight(int height); [[nodiscard]] int StickerHeight(); [[nodiscard]] rpl::producer StickerHeightChanges(); -DeclareSetting(bool, AdaptiveBubbles); +void SetAdaptiveBubbles(bool enabled); +[[nodiscard]] bool AdaptiveBubbles(); +[[nodiscard]] rpl::producer AdaptiveBubblesChanges(); + DeclareSetting(bool, AlwaysShowScheduled); DeclareSetting(bool, ShowChatId); diff --git a/Telegram/SourceFiles/settings/settings_kotato.cpp b/Telegram/SourceFiles/settings/settings_kotato.cpp index e92d1dc51..3e3908e82 100644 --- a/Telegram/SourceFiles/settings/settings_kotato.cpp +++ b/Telegram/SourceFiles/settings/settings_kotato.cpp @@ -69,31 +69,18 @@ void SetupKotatoChats(not_null container) { updateStickerHeight); updateStickerHeightLabel(StickerHeight()); - const auto adaptiveBubblesToggled = Ui::CreateChild>( - container.get()); AddButton( container, tr::ktg_settings_adaptive_bubbles(), st::settingsButton )->toggleOn( - adaptiveBubblesToggled->events_starting_with_copy(cAdaptiveBubbles()) + rpl::single(AdaptiveBubbles()) )->toggledValue( ) | rpl::filter([](bool enabled) { - return (enabled != cAdaptiveBubbles()); - }) | rpl::start_with_next([=](bool enabled) { - const auto confirmed = [=] { - cSetAdaptiveBubbles(enabled); - KotatoSettings::Write(); - App::restart(); - }; - const auto cancelled = [=] { - adaptiveBubblesToggled->fire(cAdaptiveBubbles() == true); - }; - Ui::show(Box( - tr::lng_settings_need_restart(tr::now), - tr::lng_settings_restart_now(tr::now), - confirmed, - cancelled)); + return (enabled != AdaptiveBubbles()); + }) | rpl::start_with_next([](bool enabled) { + SetAdaptiveBubbles(enabled); + KotatoSettings::Write(); }, container->lifetime()); AddButton( diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index 7520e2b6d..8fe35b26e 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -251,7 +251,7 @@ void Generator::addAudioBubble(QVector waveform, int waveactive, QString wa tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); tright = st::msgFileThumbPadding.left(); accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right()); - if (!cAdaptiveBubbles()) { + if (!AdaptiveBubbles()) { accumulate_min(width, st::msgMaxWidth); } @@ -281,7 +281,7 @@ void Generator::addTextBubble(QString text, QString date, Status status) { auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right(); accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right()); - if (!cAdaptiveBubbles()) { + if (!AdaptiveBubbles()) { accumulate_min(width, st::msgMaxWidth); } @@ -307,7 +307,7 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right(); accumulate_min(width, bubble.photoWidth); - if (!cAdaptiveBubbles()) { + if (!AdaptiveBubbles()) { accumulate_min(width, st::msgMaxWidth); }