[Option][GUI] Adaptive chat bubbles
This commit is contained in:
		
							parent
							
								
									01623cfa75
								
							
						
					
					
						commit
						2cfaa5af2a
					
				
					 18 changed files with 182 additions and 23 deletions
				
			
		| 
						 | 
					@ -42,8 +42,10 @@
 | 
				
			||||||
	"ktg_settings_network": "Network",
 | 
						"ktg_settings_network": "Network",
 | 
				
			||||||
	"ktg_settings_system": "System",
 | 
						"ktg_settings_system": "System",
 | 
				
			||||||
	"ktg_settings_other": "Other",
 | 
						"ktg_settings_other": "Other",
 | 
				
			||||||
 | 
						"ktg_settings_adaptive_bubbles": "Adaptive bubbles",
 | 
				
			||||||
	"ktg_settings_filters": "Folders",
 | 
						"ktg_settings_filters": "Folders",
 | 
				
			||||||
	"ktg_settings_messages": "Messages",
 | 
						"ktg_settings_messages": "Messages",
 | 
				
			||||||
 | 
						"ktg_settings_monospace_large_bubbles": "Expand bubbles with monospace",
 | 
				
			||||||
	"ktg_settings_forward": "Forward",
 | 
						"ktg_settings_forward": "Forward",
 | 
				
			||||||
	"ktg_in_app_update_disabled": "In-app updater is disabled.",
 | 
						"ktg_in_app_update_disabled": "In-app updater is disabled.",
 | 
				
			||||||
	"dummy_last_string": ""
 | 
						"dummy_last_string": ""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/history_inner_widget.h"
 | 
					#include "history/history_inner_widget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "chat_helpers/stickers_emoji_pack.h"
 | 
					#include "chat_helpers/stickers_emoji_pack.h"
 | 
				
			||||||
#include "core/file_utilities.h"
 | 
					#include "core/file_utilities.h"
 | 
				
			||||||
#include "core/click_handler_types.h"
 | 
					#include "core/click_handler_types.h"
 | 
				
			||||||
| 
						 | 
					@ -3765,7 +3766,7 @@ void HistoryInner::mouseActionUpdate() {
 | 
				
			||||||
					dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
 | 
										dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
 | 
				
			||||||
					auto dateLeft = st::msgServiceMargin.left();
 | 
										auto dateLeft = st::msgServiceMargin.left();
 | 
				
			||||||
					auto maxwidth = _contentWidth;
 | 
										auto maxwidth = _contentWidth;
 | 
				
			||||||
					if (_isChatWide) {
 | 
										if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
						maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
											maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
										auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -659,6 +659,36 @@ HistoryWidget::HistoryWidget(
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}, lifetime());
 | 
						}, lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						::Kotato::JsonSettings::Events(
 | 
				
			||||||
 | 
							"adaptive_bubbles"
 | 
				
			||||||
 | 
						) | rpl::start_with_next([=] {
 | 
				
			||||||
 | 
							crl::on_main(this, [=] {
 | 
				
			||||||
 | 
								if (_history) {
 | 
				
			||||||
 | 
									_history->forceFullResize();
 | 
				
			||||||
 | 
									if (_migrated) {
 | 
				
			||||||
 | 
										_migrated->forceFullResize();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									updateHistoryGeometry();
 | 
				
			||||||
 | 
									update();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}, lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						::Kotato::JsonSettings::Events(
 | 
				
			||||||
 | 
							"monospace_large_bubbles"
 | 
				
			||||||
 | 
						) | rpl::start_with_next([=] {
 | 
				
			||||||
 | 
							crl::on_main(this, [=] {
 | 
				
			||||||
 | 
								if (_history) {
 | 
				
			||||||
 | 
									_history->forceFullResize();
 | 
				
			||||||
 | 
									if (_migrated) {
 | 
				
			||||||
 | 
										_migrated->forceFullResize();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									updateHistoryGeometry();
 | 
				
			||||||
 | 
									update();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}, lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	session().data().channelDifferenceTooLong(
 | 
						session().data().channelDifferenceTooLong(
 | 
				
			||||||
	) | rpl::filter([=](not_null<ChannelData*> channel) {
 | 
						) | rpl::filter([=](not_null<ChannelData*> channel) {
 | 
				
			||||||
		return _peer == channel.get();
 | 
							return _peer == channel.get();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/history_view_element.h"
 | 
					#include "history/view/history_view_element.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "history/view/history_view_service_message.h"
 | 
					#include "history/view/history_view_service_message.h"
 | 
				
			||||||
#include "history/view/history_view_message.h"
 | 
					#include "history/view/history_view_message.h"
 | 
				
			||||||
#include "history/view/media/history_view_media_grouped.h"
 | 
					#include "history/view/media/history_view_media_grouped.h"
 | 
				
			||||||
| 
						 | 
					@ -323,7 +324,7 @@ void UnreadBar::paint(
 | 
				
			||||||
	p.setPen(st->historyUnreadBarFg());
 | 
						p.setPen(st->historyUnreadBarFg());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int maxwidth = w;
 | 
						int maxwidth = w;
 | 
				
			||||||
	if (chatWide) {
 | 
						if (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		maxwidth = qMin(
 | 
							maxwidth = qMin(
 | 
				
			||||||
			maxwidth,
 | 
								maxwidth,
 | 
				
			||||||
			st::msgMaxWidth
 | 
								st::msgMaxWidth
 | 
				
			||||||
| 
						 | 
					@ -680,6 +681,10 @@ int Element::infoWidth() const {
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int Element::plainMaxWidth() const {
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int Element::bottomInfoFirstLineWidth() const {
 | 
					int Element::bottomInfoFirstLineWidth() const {
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -352,6 +352,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] int skipBlockWidth() const;
 | 
						[[nodiscard]] int skipBlockWidth() const;
 | 
				
			||||||
	[[nodiscard]] int skipBlockHeight() const;
 | 
						[[nodiscard]] int skipBlockHeight() const;
 | 
				
			||||||
	[[nodiscard]] virtual int infoWidth() const;
 | 
						[[nodiscard]] virtual int infoWidth() const;
 | 
				
			||||||
 | 
						[[nodiscard]] virtual int plainMaxWidth() const;
 | 
				
			||||||
	[[nodiscard]] virtual int bottomInfoFirstLineWidth() const;
 | 
						[[nodiscard]] virtual int bottomInfoFirstLineWidth() const;
 | 
				
			||||||
	[[nodiscard]] virtual bool bottomInfoIsWide() const;
 | 
						[[nodiscard]] virtual bool bottomInfoIsWide() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/history_view_list_widget.h"
 | 
					#include "history/view/history_view_list_widget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "base/unixtime.h"
 | 
					#include "base/unixtime.h"
 | 
				
			||||||
#include "base/qt/qt_key_modifiers.h"
 | 
					#include "base/qt/qt_key_modifiers.h"
 | 
				
			||||||
#include "base/qt/qt_common_adapters.h"
 | 
					#include "base/qt/qt_common_adapters.h"
 | 
				
			||||||
| 
						 | 
					@ -3575,7 +3576,7 @@ void ListWidget::mouseActionUpdate() {
 | 
				
			||||||
					dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
 | 
										dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
 | 
				
			||||||
					auto dateLeft = st::msgServiceMargin.left();
 | 
										auto dateLeft = st::msgServiceMargin.left();
 | 
				
			||||||
					auto maxwidth = view->width();
 | 
										auto maxwidth = view->width();
 | 
				
			||||||
					if (_isChatWide) {
 | 
										if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
						maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
											maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
										auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/history_view_message.h"
 | 
					#include "history/view/history_view_message.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "core/click_handler_types.h" // ClickHandlerContext
 | 
					#include "core/click_handler_types.h" // ClickHandlerContext
 | 
				
			||||||
#include "core/ui_integration.h"
 | 
					#include "core/ui_integration.h"
 | 
				
			||||||
#include "history/view/history_view_cursor_state.h"
 | 
					#include "history/view/history_view_cursor_state.h"
 | 
				
			||||||
| 
						 | 
					@ -3925,7 +3926,9 @@ QRect Message::countGeometry() const {
 | 
				
			||||||
	//	contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
 | 
						//	contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	accumulate_min(contentWidth, maxWidth());
 | 
						accumulate_min(contentWidth, maxWidth());
 | 
				
			||||||
 | 
						if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		accumulate_min(contentWidth, int(_bubbleWidthLimit));
 | 
							accumulate_min(contentWidth, int(_bubbleWidthLimit));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (mediaWidth < contentWidth) {
 | 
						if (mediaWidth < contentWidth) {
 | 
				
			||||||
		const auto textualWidth = plainMaxWidth();
 | 
							const auto textualWidth = plainMaxWidth();
 | 
				
			||||||
		if (mediaWidth < textualWidth
 | 
							if (mediaWidth < textualWidth
 | 
				
			||||||
| 
						 | 
					@ -3935,7 +3938,11 @@ QRect Message::countGeometry() const {
 | 
				
			||||||
			contentWidth = mediaWidth;
 | 
								contentWidth = mediaWidth;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (contentWidth < availableWidth && !delegate()->elementIsChatWide()) {
 | 
						if (contentWidth < availableWidth
 | 
				
			||||||
 | 
							&& (!delegate()->elementIsChatWide()
 | 
				
			||||||
 | 
								|| (context() == Context::Replies
 | 
				
			||||||
 | 
									&& item->isDiscussionPost()
 | 
				
			||||||
 | 
									&& ::Kotato::JsonSettings::GetBool("adaptive_bubbles")))) {
 | 
				
			||||||
		if (outbg) {
 | 
							if (outbg) {
 | 
				
			||||||
			contentLeft += availableWidth - contentWidth;
 | 
								contentLeft += availableWidth - contentWidth;
 | 
				
			||||||
		} else if (centeredView) {
 | 
							} else if (centeredView) {
 | 
				
			||||||
| 
						 | 
					@ -4033,8 +4040,12 @@ int Message::resizeContentGetHeight(int newWidth) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	accumulate_min(contentWidth, maxWidth());
 | 
						accumulate_min(contentWidth, maxWidth());
 | 
				
			||||||
	_bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth());
 | 
						_bubbleWidthLimit = (::Kotato::JsonSettings::GetBool("monospace_large_bubbles")
 | 
				
			||||||
 | 
							? std::max(st::msgMaxWidth, monospaceMaxWidth())
 | 
				
			||||||
 | 
							: st::msgMaxWidth);
 | 
				
			||||||
 | 
						if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		accumulate_min(contentWidth, int(_bubbleWidthLimit));
 | 
							accumulate_min(contentWidth, int(_bubbleWidthLimit));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (mediaDisplayed) {
 | 
						if (mediaDisplayed) {
 | 
				
			||||||
		media->resizeGetHeight(contentWidth);
 | 
							media->resizeGetHeight(contentWidth);
 | 
				
			||||||
		if (media->width() < contentWidth) {
 | 
							if (media->width() < contentWidth) {
 | 
				
			||||||
| 
						 | 
					@ -4067,7 +4078,7 @@ int Message::resizeContentGetHeight(int newWidth) {
 | 
				
			||||||
			_reactions->resizeGetHeight(textWidth);
 | 
								_reactions->resizeGetHeight(textWidth);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (contentWidth == maxWidth()) {
 | 
							if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles") && contentWidth == maxWidth()) {
 | 
				
			||||||
			if (mediaDisplayed) {
 | 
								if (mediaDisplayed) {
 | 
				
			||||||
				if (entry) {
 | 
									if (entry) {
 | 
				
			||||||
					newHeight += entry->resizeGetHeight(contentWidth);
 | 
										newHeight += entry->resizeGetHeight(contentWidth);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -141,6 +141,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] bool allowTextSelectionByHandler(
 | 
						[[nodiscard]] bool allowTextSelectionByHandler(
 | 
				
			||||||
		const ClickHandlerPtr &handler) const override;
 | 
							const ClickHandlerPtr &handler) const override;
 | 
				
			||||||
	[[nodiscard]] int infoWidth() const override;
 | 
						[[nodiscard]] int infoWidth() const override;
 | 
				
			||||||
 | 
						[[nodiscard]] int plainMaxWidth() const override;
 | 
				
			||||||
	[[nodiscard]] int bottomInfoFirstLineWidth() const override;
 | 
						[[nodiscard]] int bottomInfoFirstLineWidth() const override;
 | 
				
			||||||
	[[nodiscard]] bool bottomInfoIsWide() const override;
 | 
						[[nodiscard]] bool bottomInfoIsWide() const override;
 | 
				
			||||||
	[[nodiscard]] bool isSignedAuthorElided() const override;
 | 
						[[nodiscard]] bool isSignedAuthorElided() const override;
 | 
				
			||||||
| 
						 | 
					@ -276,7 +277,7 @@ private:
 | 
				
			||||||
	void ensureRightAction() const;
 | 
						void ensureRightAction() const;
 | 
				
			||||||
	void refreshTopicButton();
 | 
						void refreshTopicButton();
 | 
				
			||||||
	void refreshInfoSkipBlock();
 | 
						void refreshInfoSkipBlock();
 | 
				
			||||||
	[[nodiscard]] int plainMaxWidth() const;
 | 
						//[[nodiscard]] int plainMaxWidth() const;
 | 
				
			||||||
	[[nodiscard]] int monospaceMaxWidth() const;
 | 
						[[nodiscard]] int monospaceMaxWidth() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
 | 
						void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/history_view_service_message.h"
 | 
					#include "history/view/history_view_service_message.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "history/view/media/history_view_media.h"
 | 
					#include "history/view/media/history_view_media.h"
 | 
				
			||||||
#include "history/view/history_view_cursor_state.h"
 | 
					#include "history/view/history_view_cursor_state.h"
 | 
				
			||||||
#include "history/history.h"
 | 
					#include "history/history.h"
 | 
				
			||||||
| 
						 | 
					@ -154,7 +155,7 @@ void PaintPreparedDate(
 | 
				
			||||||
		int w,
 | 
							int w,
 | 
				
			||||||
		bool chatWide) {
 | 
							bool chatWide) {
 | 
				
			||||||
	int left = st::msgServiceMargin.left();
 | 
						int left = st::msgServiceMargin.left();
 | 
				
			||||||
	const auto maxwidth = chatWide
 | 
						const auto maxwidth = (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles"))
 | 
				
			||||||
		? std::min(w, WideChatWidth())
 | 
							? std::min(w, WideChatWidth())
 | 
				
			||||||
		: w;
 | 
							: w;
 | 
				
			||||||
	w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
						w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
 | 
				
			||||||
| 
						 | 
					@ -420,7 +421,7 @@ bool Service::consumeHorizontalScroll(QPoint position, int delta) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QRect Service::countGeometry() const {
 | 
					QRect Service::countGeometry() const {
 | 
				
			||||||
	auto result = QRect(0, 0, width(), height());
 | 
						auto result = QRect(0, 0, width(), height());
 | 
				
			||||||
	if (delegate()->elementIsChatWide()) {
 | 
						if (delegate()->elementIsChatWide() && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
							result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return result.marginsRemoved(st::msgServiceMargin);
 | 
						return result.marginsRemoved(st::msgServiceMargin);
 | 
				
			||||||
| 
						 | 
					@ -445,7 +446,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
 | 
				
			||||||
			+ st::msgServiceMargin.bottom();
 | 
								+ st::msgServiceMargin.bottom();
 | 
				
			||||||
	} else if (!text().isEmpty()) {
 | 
						} else if (!text().isEmpty()) {
 | 
				
			||||||
		auto contentWidth = newWidth;
 | 
							auto contentWidth = newWidth;
 | 
				
			||||||
		if (delegate()->elementIsChatWide()) {
 | 
							if (delegate()->elementIsChatWide() && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
			accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left());
 | 
								accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins
 | 
							contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_document.h"
 | 
					#include "history/view/media/history_view_document.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "base/random.h"
 | 
					#include "base/random.h"
 | 
				
			||||||
#include "lang/lang_keys.h"
 | 
					#include "lang/lang_keys.h"
 | 
				
			||||||
#include "lottie/lottie_icon.h"
 | 
					#include "lottie/lottie_icon.h"
 | 
				
			||||||
| 
						 | 
					@ -520,8 +521,12 @@ QSize Document::countOptimalSize() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (auto named = Get<HistoryDocumentNamed>()) {
 | 
						if (auto named = Get<HistoryDocumentNamed>()) {
 | 
				
			||||||
		accumulate_max(maxWidth, tleft + named->namew + tright);
 | 
							accumulate_max(maxWidth, tleft + named->namew + tright);
 | 
				
			||||||
 | 
							if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captioned) {
 | 
				
			||||||
 | 
								accumulate_max(maxWidth, captioned->caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			accumulate_min(maxWidth, st::msgMaxWidth);
 | 
								accumulate_min(maxWidth, st::msgMaxWidth);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (voice && voice->transcribe) {
 | 
						if (voice && voice->transcribe) {
 | 
				
			||||||
		maxWidth += st::historyTranscribeSkip
 | 
							maxWidth += st::historyTranscribeSkip
 | 
				
			||||||
			+ voice->transcribe->size().width();
 | 
								+ voice->transcribe->size().width();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_gif.h"
 | 
					#include "history/view/media/history_view_gif.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "apiwrap.h"
 | 
					#include "apiwrap.h"
 | 
				
			||||||
#include "api/api_transcribes.h"
 | 
					#include "api/api_transcribes.h"
 | 
				
			||||||
#include "lang/lang_keys.h"
 | 
					#include "lang/lang_keys.h"
 | 
				
			||||||
| 
						 | 
					@ -229,13 +230,19 @@ QSize Gif::sizeForAspectRatio() const {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSize Gif::countThumbSize(int &inOutWidthMax) const {
 | 
					QSize Gif::countThumbSize(int &inOutWidthMax) const {
 | 
				
			||||||
 | 
						const auto captionWithPaddings = ::Kotato::JsonSettings::GetBool("adaptive_bubbles")
 | 
				
			||||||
 | 
							? _caption.maxWidth()
 | 
				
			||||||
 | 
								+ st::msgPadding.left()
 | 
				
			||||||
 | 
								+ st::msgPadding.right()
 | 
				
			||||||
 | 
							: 0;
 | 
				
			||||||
	const auto maxSize = _data->isVideoFile()
 | 
						const auto maxSize = _data->isVideoFile()
 | 
				
			||||||
		? st::maxMediaSize
 | 
							? st::maxMediaSize
 | 
				
			||||||
		: _data->isVideoMessage()
 | 
							: _data->isVideoMessage()
 | 
				
			||||||
		? st::maxVideoMessageSize
 | 
							? st::maxVideoMessageSize
 | 
				
			||||||
		: st::maxGifSize;
 | 
							: st::maxGifSize;
 | 
				
			||||||
 | 
						const auto maxSizeWithCaption = std::max(captionWithPaddings, maxSize);
 | 
				
			||||||
	const auto size = style::ConvertScale(videoSize());
 | 
						const auto size = style::ConvertScale(videoSize());
 | 
				
			||||||
	accumulate_min(inOutWidthMax, maxSize);
 | 
						accumulate_min(inOutWidthMax, maxSizeWithCaption);
 | 
				
			||||||
	return DownscaledSize(size, { inOutWidthMax, maxSize });
 | 
						return DownscaledSize(size, { inOutWidthMax, maxSize });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,6 +279,11 @@ QSize Gif::countOptimalSize() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (_parent->hasBubble()) {
 | 
						if (_parent->hasBubble()) {
 | 
				
			||||||
		if (!_caption.isEmpty()) {
 | 
							if (!_caption.isEmpty()) {
 | 
				
			||||||
 | 
								if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
									accumulate_max(maxWidth, _caption.maxWidth()
 | 
				
			||||||
 | 
											+ st::msgPadding.left()
 | 
				
			||||||
 | 
											+ st::msgPadding.right());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			maxWidth = qMax(maxWidth, st::msgPadding.left()
 | 
								maxWidth = qMax(maxWidth, st::msgPadding.left()
 | 
				
			||||||
				+ _caption.maxWidth()
 | 
									+ _caption.maxWidth()
 | 
				
			||||||
				+ st::msgPadding.right());
 | 
									+ st::msgPadding.right());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_location.h"
 | 
					#include "history/view/media/history_view_location.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "base/unixtime.h"
 | 
					#include "base/unixtime.h"
 | 
				
			||||||
#include "history/history.h"
 | 
					#include "history/history.h"
 | 
				
			||||||
#include "history/history_item_components.h"
 | 
					#include "history/history_item_components.h"
 | 
				
			||||||
| 
						 | 
					@ -274,9 +275,15 @@ QSize Location::countOptimalSize() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_parent->hasBubble()) {
 | 
						if (_parent->hasBubble()) {
 | 
				
			||||||
		if (!_title.isEmpty()) {
 | 
							if (!_title.isEmpty()) {
 | 
				
			||||||
 | 
								if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
									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);
 | 
								minHeight += qMin(_title.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!_description.isEmpty()) {
 | 
							if (!_description.isEmpty()) {
 | 
				
			||||||
 | 
								if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
									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);
 | 
								minHeight += qMin(_description.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!_title.isEmpty() || !_description.isEmpty()) {
 | 
							if (!_title.isEmpty() || !_description.isEmpty()) {
 | 
				
			||||||
| 
						 | 
					@ -307,8 +314,10 @@ QSize Location::countCurrentSize(int newWidth) {
 | 
				
			||||||
	auto newHeight = th;
 | 
						auto newHeight = th;
 | 
				
			||||||
	if (tw > newWidth) {
 | 
						if (tw > newWidth) {
 | 
				
			||||||
		newHeight = (newWidth * newHeight / tw);
 | 
							newHeight = (newWidth * newHeight / tw);
 | 
				
			||||||
	} else {
 | 
						} else if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		newWidth = tw;
 | 
							newWidth = tw;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							newHeight = (newWidth * newHeight / tw);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	auto minWidth = std::clamp(
 | 
						auto minWidth = std::clamp(
 | 
				
			||||||
		_parent->minWidthForMedia(),
 | 
							_parent->minWidthForMedia(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_media_grouped.h"
 | 
					#include "history/view/media/history_view_media_grouped.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "history/history_item_components.h"
 | 
					#include "history/history_item_components.h"
 | 
				
			||||||
#include "history/history_item.h"
 | 
					#include "history/history_item.h"
 | 
				
			||||||
#include "history/history.h"
 | 
					#include "history/history.h"
 | 
				
			||||||
| 
						 | 
					@ -127,10 +128,18 @@ QSize GroupedMedia::countOptimalSize() {
 | 
				
			||||||
		sizes.push_back(part.content->sizeForGroupingOptimal(maxWidth));
 | 
							sizes.push_back(part.content->sizeForGroupingOptimal(maxWidth));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const auto captionWithPaddings = _caption.maxWidth()
 | 
				
			||||||
 | 
							+ st::msgPadding.left()
 | 
				
			||||||
 | 
							+ st::msgPadding.right();
 | 
				
			||||||
 | 
						auto groupMaxWidth = st::historyGroupWidthMax;
 | 
				
			||||||
 | 
						if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
							accumulate_max(groupMaxWidth, captionWithPaddings);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto layout = (_mode == Mode::Grid)
 | 
						const auto layout = (_mode == Mode::Grid)
 | 
				
			||||||
		? Ui::LayoutMediaGroup(
 | 
							? Ui::LayoutMediaGroup(
 | 
				
			||||||
			sizes,
 | 
								sizes,
 | 
				
			||||||
			st::historyGroupWidthMax,
 | 
								groupMaxWidth,
 | 
				
			||||||
			st::historyGroupWidthMin,
 | 
								st::historyGroupWidthMin,
 | 
				
			||||||
			st::historyGroupSkip)
 | 
								st::historyGroupSkip)
 | 
				
			||||||
		: LayoutPlaylist(sizes);
 | 
							: LayoutPlaylist(sizes);
 | 
				
			||||||
| 
						 | 
					@ -146,6 +155,9 @@ QSize GroupedMedia::countOptimalSize() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!_caption.isEmpty()) {
 | 
						if (!_caption.isEmpty()) {
 | 
				
			||||||
 | 
							if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
								maxWidth = qMax(maxWidth, captionWithPaddings);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
 | 
							auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
 | 
				
			||||||
		minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
 | 
							minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
 | 
				
			||||||
		if (isBubbleBottom()) {
 | 
							if (isBubbleBottom()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_photo.h"
 | 
					#include "history/view/media/history_view_photo.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "history/history_item_components.h"
 | 
					#include "history/history_item_components.h"
 | 
				
			||||||
#include "history/history_item.h"
 | 
					#include "history/history_item.h"
 | 
				
			||||||
#include "history/history.h"
 | 
					#include "history/history.h"
 | 
				
			||||||
| 
						 | 
					@ -201,15 +202,20 @@ QSize Photo::countOptimalSize() {
 | 
				
			||||||
			? st::historyPhotoBubbleMinWidth
 | 
								? st::historyPhotoBubbleMinWidth
 | 
				
			||||||
			: st::minPhotoSize),
 | 
								: st::minPhotoSize),
 | 
				
			||||||
		st::maxMediaSize);
 | 
							st::maxMediaSize);
 | 
				
			||||||
	const auto maxActualWidth = qMax(scaled.width(), minWidth);
 | 
						auto maxActualWidth = qMax(scaled.width(), minWidth);
 | 
				
			||||||
	auto maxWidth = qMax(maxActualWidth, scaled.height());
 | 
						auto maxWidth = qMax(maxActualWidth, scaled.height());
 | 
				
			||||||
	auto minHeight = qMax(scaled.height(), st::minPhotoSize);
 | 
						auto minHeight = qMax(scaled.height(), st::minPhotoSize);
 | 
				
			||||||
	if (_parent->hasBubble() && !_caption.isEmpty()) {
 | 
						if (_parent->hasBubble() && !_caption.isEmpty()) {
 | 
				
			||||||
 | 
							const auto captionWithPaddings = (st::msgPadding.left()
 | 
				
			||||||
 | 
																+ _caption.maxWidth()
 | 
				
			||||||
 | 
																+ st::msgPadding.right());
 | 
				
			||||||
 | 
							if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
								maxActualWidth = qMax(maxActualWidth, captionWithPaddings);
 | 
				
			||||||
 | 
								maxWidth = qMax(maxWidth, captionWithPaddings);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		maxWidth = qMax(
 | 
							maxWidth = qMax(
 | 
				
			||||||
			maxWidth,
 | 
								maxWidth,
 | 
				
			||||||
			(st::msgPadding.left()
 | 
								captionWithPaddings);
 | 
				
			||||||
				+ _caption.maxWidth()
 | 
					 | 
				
			||||||
				+ st::msgPadding.right()));
 | 
					 | 
				
			||||||
		minHeight = adjustHeightForLessCrop(
 | 
							minHeight = adjustHeightForLessCrop(
 | 
				
			||||||
			dimensions,
 | 
								dimensions,
 | 
				
			||||||
			{ maxWidth, minHeight });
 | 
								{ maxWidth, minHeight });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "history/view/media/history_view_web_page.h"
 | 
					#include "history/view/media/history_view_web_page.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "core/application.h"
 | 
					#include "core/application.h"
 | 
				
			||||||
#include "base/qt/qt_key_modifiers.h"
 | 
					#include "base/qt/qt_key_modifiers.h"
 | 
				
			||||||
#include "window/window_session_controller.h"
 | 
					#include "window/window_session_controller.h"
 | 
				
			||||||
| 
						 | 
					@ -511,6 +512,10 @@ QSize WebPage::countOptimalSize() {
 | 
				
			||||||
		maxWidth += rect::m::sum::h(st::historyPageButtonPadding)
 | 
							maxWidth += rect::m::sum::h(st::historyPageButtonPadding)
 | 
				
			||||||
			+ _openButton.maxWidth();
 | 
								+ _openButton.maxWidth();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
 | 
							accumulate_min(maxWidth, st::msgMaxWidth);
 | 
				
			||||||
 | 
							accumulate_max(maxWidth, _parent->plainMaxWidth());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	maxWidth += rect::m::sum::h(padding);
 | 
						maxWidth += rect::m::sum::h(padding);
 | 
				
			||||||
	minHeight += rect::m::sum::v(padding);
 | 
						minHeight += rect::m::sum::v(padding);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -535,6 +540,10 @@ QSize WebPage::countCurrentSize(int newWidth) {
 | 
				
			||||||
		return { newWidth, minHeight() };
 | 
							return { newWidth, minHeight() };
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && !asArticle()) {
 | 
				
			||||||
 | 
							accumulate_min(newWidth, maxWidth());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto padding = inBubblePadding() + innerMargin();
 | 
						const auto padding = inBubblePadding() + innerMargin();
 | 
				
			||||||
	const auto innerWidth = newWidth - rect::m::sum::h(padding);
 | 
						const auto innerWidth = newWidth - rect::m::sum::h(padding);
 | 
				
			||||||
	auto newHeight = 0;
 | 
						auto newHeight = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -236,12 +236,19 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
 | 
				
			||||||
	{ "sticker_scale_both", {
 | 
						{ "sticker_scale_both", {
 | 
				
			||||||
		.type = SettingType::BoolSetting,
 | 
							.type = SettingType::BoolSetting,
 | 
				
			||||||
		.defaultValue = true, }},
 | 
							.defaultValue = true, }},
 | 
				
			||||||
 | 
						{ "adaptive_bubbles", {
 | 
				
			||||||
 | 
							.type = SettingType::BoolSetting,
 | 
				
			||||||
 | 
							.defaultValue = false, }},
 | 
				
			||||||
 | 
						{ "monospace_large_bubbles", {
 | 
				
			||||||
 | 
							.type = SettingType::BoolSetting,
 | 
				
			||||||
 | 
							.defaultValue = false, }},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using OldOptionKey = QString;
 | 
					using OldOptionKey = QString;
 | 
				
			||||||
using NewOptionKey = QString;
 | 
					using NewOptionKey = QString;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const std::map<OldOptionKey, NewOptionKey, std::greater<OldOptionKey>> ReplacedOptionsMap {
 | 
					const std::map<OldOptionKey, NewOptionKey, std::greater<OldOptionKey>> ReplacedOptionsMap {
 | 
				
			||||||
 | 
						{ "adaptive_baloons", "adaptive_bubbles" },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString DefaultFilePath() {
 | 
					QString DefaultFilePath() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,6 +135,45 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
 | 
				
			||||||
	Ui::AddDividerText(container, rktr("ktg_settings_sticker_scale_both_about"));
 | 
						Ui::AddDividerText(container, rktr("ktg_settings_sticker_scale_both_about"));
 | 
				
			||||||
	Ui::AddSkip(container);
 | 
						Ui::AddSkip(container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						auto adaptiveBubblesButton = container->add(object_ptr<Button>(
 | 
				
			||||||
 | 
							container,
 | 
				
			||||||
 | 
							rktr("ktg_settings_adaptive_bubbles"),
 | 
				
			||||||
 | 
							st::settingsButtonNoIcon
 | 
				
			||||||
 | 
						));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						auto monospaceLargeBubblesButton = container->add(
 | 
				
			||||||
 | 
							object_ptr<Ui::SlideWrap<Button>>(
 | 
				
			||||||
 | 
								container,
 | 
				
			||||||
 | 
								object_ptr<Ui::SettingsButton>(
 | 
				
			||||||
 | 
									container,
 | 
				
			||||||
 | 
									rktr("ktg_settings_monospace_large_bubbles"),
 | 
				
			||||||
 | 
									st::settingsButtonNoIcon)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						adaptiveBubblesButton->toggleOn(
 | 
				
			||||||
 | 
							rpl::single(::Kotato::JsonSettings::GetBool("adaptive_bubbles"))
 | 
				
			||||||
 | 
						)->toggledValue(
 | 
				
			||||||
 | 
						) | rpl::filter([](bool enabled) {
 | 
				
			||||||
 | 
							return (enabled != ::Kotato::JsonSettings::GetBool("adaptive_bubbles"));
 | 
				
			||||||
 | 
						}) | rpl::start_with_next([monospaceLargeBubblesButton](bool enabled) {
 | 
				
			||||||
 | 
							monospaceLargeBubblesButton->toggle(!enabled, anim::type::normal);
 | 
				
			||||||
 | 
							::Kotato::JsonSettings::Set("adaptive_bubbles", enabled);
 | 
				
			||||||
 | 
							::Kotato::JsonSettings::Write();
 | 
				
			||||||
 | 
						}, container->lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						monospaceLargeBubblesButton->entity()->toggleOn(
 | 
				
			||||||
 | 
							rpl::single(::Kotato::JsonSettings::GetBool("monospace_large_bubbles"))
 | 
				
			||||||
 | 
						)->toggledValue(
 | 
				
			||||||
 | 
						) | rpl::filter([](bool enabled) {
 | 
				
			||||||
 | 
							return (enabled != ::Kotato::JsonSettings::GetBool("monospace_large_bubbles"));
 | 
				
			||||||
 | 
						}) | rpl::start_with_next([](bool enabled) {
 | 
				
			||||||
 | 
							::Kotato::JsonSettings::Set("monospace_large_bubbles", enabled);
 | 
				
			||||||
 | 
							::Kotato::JsonSettings::Write();
 | 
				
			||||||
 | 
						}, container->lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (adaptiveBubblesButton->toggled()) {
 | 
				
			||||||
 | 
							monospaceLargeBubblesButton->hide(anim::type::instant);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SettingsMenuJsonSwitch(ktg_settings_emoji_outline, big_emoji_outline);
 | 
						SettingsMenuJsonSwitch(ktg_settings_emoji_outline, big_emoji_outline);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Ui::AddSkip(container);
 | 
						Ui::AddSkip(container);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "window/themes/window_theme_preview.h"
 | 
					#include "window/themes/window_theme_preview.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "kotato/kotato_settings.h"
 | 
				
			||||||
#include "dialogs/dialogs_three_state_icon.h"
 | 
					#include "dialogs/dialogs_three_state_icon.h"
 | 
				
			||||||
#include "lang/lang_keys.h"
 | 
					#include "lang/lang_keys.h"
 | 
				
			||||||
#include "platform/platform_window_title.h"
 | 
					#include "platform/platform_window_title.h"
 | 
				
			||||||
| 
						 | 
					@ -267,7 +268,9 @@ void Generator::addAudioBubble(QVector<int> waveform, int waveactive, QString wa
 | 
				
			||||||
	const auto &st = st::msgFileLayout;
 | 
						const auto &st = st::msgFileLayout;
 | 
				
			||||||
	auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
 | 
						auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
 | 
				
			||||||
	accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
 | 
						accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
 | 
				
			||||||
 | 
						if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		accumulate_min(width, st::msgMaxWidth);
 | 
							accumulate_min(width, st::msgMaxWidth);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto height = st.padding.top() + st.thumbSize + st.padding.bottom();
 | 
						auto height = st.padding.top() + st.thumbSize + st.padding.bottom();
 | 
				
			||||||
	addBubble(std::move(bubble), width, height, date, status);
 | 
						addBubble(std::move(bubble), width, height, date, status);
 | 
				
			||||||
| 
						 | 
					@ -300,7 +303,9 @@ void Generator::addTextBubble(QString text, QString date, Status status) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
 | 
						auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
 | 
				
			||||||
	accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right());
 | 
						accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right());
 | 
				
			||||||
 | 
						if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		accumulate_min(width, st::msgMaxWidth);
 | 
							accumulate_min(width, st::msgMaxWidth);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
 | 
						auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
 | 
				
			||||||
	auto textHeight = bubble.text.countHeight(textWidth);
 | 
						auto textHeight = bubble.text.countHeight(textWidth);
 | 
				
			||||||
| 
						 | 
					@ -329,7 +334,9 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
 | 
						auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
 | 
				
			||||||
	accumulate_min(width, bubble.photoWidth);
 | 
						accumulate_min(width, bubble.photoWidth);
 | 
				
			||||||
 | 
						if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
 | 
				
			||||||
		accumulate_min(width, st::msgMaxWidth);
 | 
							accumulate_min(width, st::msgMaxWidth);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
 | 
						auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
 | 
				
			||||||
	auto textHeight = bubble.text.countHeight(textWidth);
 | 
						auto textHeight = bubble.text.countHeight(textWidth);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue