Make adaptive bubbles work without restart
This commit is contained in:
		
							parent
							
								
									2080b0ca26
								
							
						
					
					
						commit
						1f0573f36e
					
				
					 17 changed files with 67 additions and 60 deletions
				
			
		|  | @ -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()); | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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<HistoryItem*> item) { | ||||
| 		if (const auto view = item->mainView()) { | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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<HistoryService*> 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
 | ||||
|  |  | |||
|  | @ -181,7 +181,7 @@ QSize Document::countOptimalSize() { | |||
| 
 | ||||
| 	if (auto named = Get<HistoryDocumentNamed>()) { | ||||
| 		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); | ||||
|  |  | |||
|  | @ -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); | ||||
| 			} | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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); | ||||
| 		} | ||||
|  |  | |||
|  | @ -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()); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -232,7 +232,17 @@ rpl::producer<bool> BigEmojiOutlineChanges() { | |||
| 	return gBigEmojiOutline.changes(); | ||||
| } | ||||
| 
 | ||||
| bool gAdaptiveBubbles = false; | ||||
| rpl::variable<bool> gAdaptiveBubbles = false; | ||||
| void SetAdaptiveBubbles(bool enabled) { | ||||
| 	gAdaptiveBubbles = enabled; | ||||
| } | ||||
| bool AdaptiveBubbles() { | ||||
| 	return gAdaptiveBubbles.current(); | ||||
| } | ||||
| rpl::producer<bool> AdaptiveBubblesChanges() { | ||||
| 	return gAdaptiveBubbles.changes(); | ||||
| } | ||||
| 
 | ||||
| bool gAlwaysShowScheduled = true; | ||||
| bool gShowChatId = true; | ||||
| 
 | ||||
|  |  | |||
|  | @ -192,7 +192,10 @@ void SetStickerHeight(int height); | |||
| [[nodiscard]] int StickerHeight(); | ||||
| [[nodiscard]] rpl::producer<int> StickerHeightChanges(); | ||||
| 
 | ||||
| DeclareSetting(bool, AdaptiveBubbles); | ||||
| void SetAdaptiveBubbles(bool enabled); | ||||
| [[nodiscard]] bool AdaptiveBubbles(); | ||||
| [[nodiscard]] rpl::producer<bool> AdaptiveBubblesChanges(); | ||||
| 
 | ||||
| DeclareSetting(bool, AlwaysShowScheduled); | ||||
| DeclareSetting(bool, ShowChatId); | ||||
| 
 | ||||
|  |  | |||
|  | @ -69,31 +69,18 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) { | |||
| 		updateStickerHeight); | ||||
| 	updateStickerHeightLabel(StickerHeight()); | ||||
| 
 | ||||
| 	const auto adaptiveBubblesToggled = Ui::CreateChild<rpl::event_stream<bool>>( | ||||
| 		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); | ||||
| 		return (enabled != AdaptiveBubbles()); | ||||
| 	}) | rpl::start_with_next([](bool enabled) { | ||||
| 		SetAdaptiveBubbles(enabled); | ||||
| 		KotatoSettings::Write(); | ||||
| 			App::restart(); | ||||
| 		}; | ||||
| 		const auto cancelled = [=] { | ||||
| 			adaptiveBubblesToggled->fire(cAdaptiveBubbles() == true); | ||||
| 		}; | ||||
| 		Ui::show(Box<ConfirmBox>( | ||||
| 			tr::lng_settings_need_restart(tr::now), | ||||
| 			tr::lng_settings_restart_now(tr::now), | ||||
| 			confirmed, | ||||
| 			cancelled)); | ||||
| 	}, container->lifetime()); | ||||
| 
 | ||||
| 	AddButton( | ||||
|  |  | |||
|  | @ -251,7 +251,7 @@ void Generator::addAudioBubble(QVector<int> 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); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue