[Option][GUI] Adaptive chat bubbles
This commit is contained in:
parent
5ee990a124
commit
5baeb46436
18 changed files with 182 additions and 23 deletions
|
|
@ -46,8 +46,10 @@
|
|||
"ktg_settings_network": "Network",
|
||||
"ktg_settings_system": "System",
|
||||
"ktg_settings_other": "Other",
|
||||
"ktg_settings_adaptive_bubbles": "Adaptive bubbles",
|
||||
"ktg_settings_filters": "Folders",
|
||||
"ktg_settings_messages": "Messages",
|
||||
"ktg_settings_monospace_large_bubbles": "Expand bubbles with monospace",
|
||||
"ktg_settings_forward": "Forward",
|
||||
"ktg_in_app_update_disabled": "In-app updater is disabled.",
|
||||
"dummy_last_string": ""
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/history_inner_widget.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/crash_reports.h"
|
||||
#include "core/click_handler_types.h"
|
||||
|
|
@ -3641,7 +3642,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
|
||||
auto dateLeft = st::msgServiceMargin.left();
|
||||
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()));
|
||||
}
|
||||
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
|
||||
|
|
|
|||
|
|
@ -598,6 +598,36 @@ HistoryWidget::HistoryWidget(
|
|||
});
|
||||
}, 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().webPageUpdates(
|
||||
) | rpl::filter([=](not_null<WebPageData*> page) {
|
||||
return (_previewData == page.get());
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/history_view_element.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "api/api_chat_invite.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_message.h"
|
||||
|
|
@ -312,7 +313,7 @@ void UnreadBar::paint(
|
|||
p.setPen(st->historyUnreadBarFg());
|
||||
|
||||
int maxwidth = w;
|
||||
if (chatWide) {
|
||||
if (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
maxwidth = qMin(
|
||||
maxwidth,
|
||||
st::msgMaxWidth
|
||||
|
|
@ -589,6 +590,10 @@ int Element::infoWidth() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Element::plainMaxWidth() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Element::bottomInfoFirstLineWidth() const {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ public:
|
|||
[[nodiscard]] int skipBlockWidth() const;
|
||||
[[nodiscard]] int skipBlockHeight() const;
|
||||
[[nodiscard]] virtual int infoWidth() const;
|
||||
[[nodiscard]] virtual int plainMaxWidth() const;
|
||||
[[nodiscard]] virtual int bottomInfoFirstLineWidth() 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 "kotato/kotato_settings.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
|
|
@ -3431,7 +3432,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
|
||||
auto dateLeft = st::msgServiceMargin.left();
|
||||
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()));
|
||||
}
|
||||
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 "kotato/kotato_settings.h"
|
||||
#include "core/click_handler_types.h" // ClickHandlerContext
|
||||
#include "core/ui_integration.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
|
|
@ -3423,7 +3424,9 @@ QRect Message::countGeometry() const {
|
|||
// contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
|
||||
}
|
||||
accumulate_min(contentWidth, maxWidth());
|
||||
accumulate_min(contentWidth, _bubbleWidthLimit);
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(contentWidth, _bubbleWidthLimit);
|
||||
}
|
||||
if (mediaWidth < contentWidth) {
|
||||
const auto textualWidth = plainMaxWidth();
|
||||
if (mediaWidth < textualWidth
|
||||
|
|
@ -3433,7 +3436,11 @@ QRect Message::countGeometry() const {
|
|||
contentWidth = mediaWidth;
|
||||
}
|
||||
}
|
||||
if (contentWidth < availableWidth && !delegate()->elementIsChatWide()) {
|
||||
if (contentWidth < availableWidth
|
||||
&& (!delegate()->elementIsChatWide()
|
||||
|| (context() == Context::Replies
|
||||
&& item->isDiscussionPost()
|
||||
&& ::Kotato::JsonSettings::GetBool("adaptive_bubbles")))) {
|
||||
if (outbg) {
|
||||
contentLeft += availableWidth - contentWidth;
|
||||
} else if (centeredView) {
|
||||
|
|
@ -3525,8 +3532,12 @@ int Message::resizeContentGetHeight(int newWidth) {
|
|||
}
|
||||
}
|
||||
accumulate_min(contentWidth, maxWidth());
|
||||
_bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth());
|
||||
accumulate_min(contentWidth, _bubbleWidthLimit);
|
||||
_bubbleWidthLimit = (::Kotato::JsonSettings::GetBool("monospace_large_bubbles")
|
||||
? std::max(st::msgMaxWidth, monospaceMaxWidth())
|
||||
: st::msgMaxWidth);
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(contentWidth, _bubbleWidthLimit);
|
||||
}
|
||||
if (mediaDisplayed) {
|
||||
media->resizeGetHeight(contentWidth);
|
||||
if (media->width() < contentWidth) {
|
||||
|
|
@ -3559,7 +3570,7 @@ int Message::resizeContentGetHeight(int newWidth) {
|
|||
_reactions->resizeGetHeight(textWidth);
|
||||
}
|
||||
|
||||
if (contentWidth == maxWidth()) {
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles") && contentWidth == maxWidth()) {
|
||||
if (mediaDisplayed) {
|
||||
if (entry) {
|
||||
newHeight += entry->resizeGetHeight(contentWidth);
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ public:
|
|||
[[nodiscard]] bool toggleSelectionByHandlerClick(
|
||||
const ClickHandlerPtr &handler) const override;
|
||||
[[nodiscard]] int infoWidth() const override;
|
||||
[[nodiscard]] int plainMaxWidth() const override;
|
||||
[[nodiscard]] int bottomInfoFirstLineWidth() const override;
|
||||
[[nodiscard]] bool bottomInfoIsWide() const override;
|
||||
[[nodiscard]] bool isSignedAuthorElided() const override;
|
||||
|
|
@ -276,7 +277,7 @@ private:
|
|||
void ensureRightAction() const;
|
||||
void refreshTopicButton();
|
||||
void refreshInfoSkipBlock();
|
||||
[[nodiscard]] int plainMaxWidth() const;
|
||||
//[[nodiscard]] int plainMaxWidth() const;
|
||||
[[nodiscard]] int monospaceMaxWidth() const;
|
||||
|
||||
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 "kotato/kotato_settings.h"
|
||||
#include "history/view/media/history_view_media.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/history.h"
|
||||
|
|
@ -154,7 +155,7 @@ void PaintPreparedDate(
|
|||
int w,
|
||||
bool chatWide) {
|
||||
int left = st::msgServiceMargin.left();
|
||||
const auto maxwidth = chatWide
|
||||
const auto maxwidth = (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles"))
|
||||
? std::min(w, WideChatWidth())
|
||||
: w;
|
||||
w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
|
||||
|
|
@ -413,7 +414,7 @@ QRect Service::innerGeometry() const {
|
|||
|
||||
QRect Service::countGeometry() const {
|
||||
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()));
|
||||
}
|
||||
return result.marginsRemoved(st::msgServiceMargin);
|
||||
|
|
@ -435,7 +436,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
|
|||
+ st::msgServiceMargin.bottom();
|
||||
} else if (!text().isEmpty()) {
|
||||
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());
|
||||
}
|
||||
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 "kotato/kotato_settings.h"
|
||||
#include "base/random.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/localstorage.h"
|
||||
|
|
@ -384,7 +385,11 @@ QSize Document::countOptimalSize() {
|
|||
|
||||
if (auto named = Get<HistoryDocumentNamed>()) {
|
||||
accumulate_max(maxWidth, tleft + named->namew + tright);
|
||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (voice && voice->transcribe) {
|
||||
maxWidth += st::historyTranscribeSkip
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_gif.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_transcribes.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
|
@ -150,13 +151,19 @@ QSize Gif::sizeForAspectRatio() 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()
|
||||
? st::maxMediaSize
|
||||
: _data->isVideoMessage()
|
||||
? st::maxVideoMessageSize
|
||||
: st::maxGifSize;
|
||||
const auto maxSizeWithCaption = std::max(captionWithPaddings, maxSize);
|
||||
const auto size = style::ConvertScale(videoSize());
|
||||
accumulate_min(inOutWidthMax, maxSize);
|
||||
accumulate_min(inOutWidthMax, maxSizeWithCaption);
|
||||
return DownscaledSize(size, { inOutWidthMax, maxSize });
|
||||
}
|
||||
|
||||
|
|
@ -193,6 +200,11 @@ QSize Gif::countOptimalSize() {
|
|||
}
|
||||
if (_parent->hasBubble()) {
|
||||
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()
|
||||
+ _caption.maxWidth()
|
||||
+ st::msgPadding.right());
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_location.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item.h"
|
||||
|
|
@ -92,9 +93,15 @@ QSize Location::countOptimalSize() {
|
|||
|
||||
if (_parent->hasBubble()) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (!_title.isEmpty() || !_description.isEmpty()) {
|
||||
|
|
@ -119,8 +126,10 @@ QSize Location::countCurrentSize(int newWidth) {
|
|||
auto newHeight = th;
|
||||
if (tw > newWidth) {
|
||||
newHeight = (newWidth * newHeight / tw);
|
||||
} else {
|
||||
} else if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
newWidth = tw;
|
||||
} else {
|
||||
newHeight = (newWidth * newHeight / tw);
|
||||
}
|
||||
auto minWidth = std::clamp(
|
||||
_parent->minWidthForMedia(),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_media_grouped.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history.h"
|
||||
|
|
@ -127,10 +128,18 @@ QSize GroupedMedia::countOptimalSize() {
|
|||
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)
|
||||
? Ui::LayoutMediaGroup(
|
||||
sizes,
|
||||
st::historyGroupWidthMax,
|
||||
groupMaxWidth,
|
||||
st::historyGroupWidthMin,
|
||||
st::historyGroupSkip)
|
||||
: LayoutPlaylist(sizes);
|
||||
|
|
@ -146,6 +155,9 @@ QSize GroupedMedia::countOptimalSize() {
|
|||
}
|
||||
|
||||
if (!_caption.isEmpty()) {
|
||||
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
maxWidth = qMax(maxWidth, captionWithPaddings);
|
||||
}
|
||||
auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
|
||||
minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
|
||||
if (isBubbleBottom()) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_photo.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history.h"
|
||||
|
|
@ -175,15 +176,20 @@ QSize Photo::countOptimalSize() {
|
|||
? st::historyPhotoBubbleMinWidth
|
||||
: st::minPhotoSize),
|
||||
st::maxMediaSize);
|
||||
const auto maxActualWidth = qMax(scaled.width(), minWidth);
|
||||
auto maxActualWidth = qMax(scaled.width(), minWidth);
|
||||
auto maxWidth = qMax(maxActualWidth, scaled.height());
|
||||
auto minHeight = qMax(scaled.height(), st::minPhotoSize);
|
||||
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,
|
||||
(st::msgPadding.left()
|
||||
+ _caption.maxWidth()
|
||||
+ st::msgPadding.right()));
|
||||
captionWithPaddings);
|
||||
minHeight = adjustHeightForLessCrop(
|
||||
dimensions,
|
||||
{ maxWidth, minHeight });
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/media/history_view_web_page.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
|
@ -317,6 +318,10 @@ QSize WebPage::countOptimalSize() {
|
|||
_durationWidth = st::msgDateFont->width(_duration);
|
||||
}
|
||||
maxWidth += st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
|
||||
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||
accumulate_max(maxWidth, _parent->plainMaxWidth());
|
||||
}
|
||||
auto padding = inBubblePadding();
|
||||
minHeight += padding.top() + padding.bottom();
|
||||
|
||||
|
|
@ -331,6 +336,10 @@ QSize WebPage::countCurrentSize(int newWidth) {
|
|||
return { newWidth, minHeight() };
|
||||
}
|
||||
|
||||
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && !asArticle()) {
|
||||
accumulate_min(newWidth, maxWidth());
|
||||
}
|
||||
|
||||
auto innerWidth = newWidth - st::msgPadding.left() - st::webPageLeft - st::msgPadding.right();
|
||||
auto newHeight = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -253,12 +253,19 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
|||
{ "sticker_scale_both", {
|
||||
.type = SettingType::BoolSetting,
|
||||
.defaultValue = true, }},
|
||||
{ "adaptive_bubbles", {
|
||||
.type = SettingType::BoolSetting,
|
||||
.defaultValue = false, }},
|
||||
{ "monospace_large_bubbles", {
|
||||
.type = SettingType::BoolSetting,
|
||||
.defaultValue = false, }},
|
||||
};
|
||||
|
||||
using OldOptionKey = QString;
|
||||
using NewOptionKey = QString;
|
||||
|
||||
const std::map<OldOptionKey, NewOptionKey, std::greater<OldOptionKey>> ReplacedOptionsMap {
|
||||
{ "adaptive_baloons", "adaptive_bubbles" },
|
||||
};
|
||||
|
||||
QString DefaultFilePath() {
|
||||
|
|
|
|||
|
|
@ -134,6 +134,45 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
|
|||
AddDividerText(container, rktr("ktg_settings_sticker_scale_both_about"));
|
||||
AddSkip(container);
|
||||
|
||||
auto adaptiveBubblesButton = AddButton(
|
||||
container,
|
||||
rktr("ktg_settings_adaptive_bubbles"),
|
||||
st::settingsButtonNoIcon
|
||||
);
|
||||
|
||||
auto monospaceLargeBubblesButton = container->add(
|
||||
object_ptr<Ui::SlideWrap<Button>>(
|
||||
container,
|
||||
CreateButton(
|
||||
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);
|
||||
|
||||
AddSkip(container);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "window/themes/window_theme_preview.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "platform/platform_window_title.h"
|
||||
#include "ui/text/text_options.h"
|
||||
|
|
@ -266,7 +267,9 @@ void Generator::addAudioBubble(QVector<int> waveform, int waveactive, QString wa
|
|||
const auto &st = st::msgFileLayout;
|
||||
auto tleft = st.padding.left() + st.thumbSize + st.thumbSkip;
|
||||
accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto height = st.padding.top() + st.thumbSize + st.padding.bottom();
|
||||
addBubble(std::move(bubble), width, height, date, status);
|
||||
|
|
@ -299,7 +302,9 @@ 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());
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
|
||||
auto textHeight = bubble.text.countHeight(textWidth);
|
||||
|
|
@ -328,7 +333,9 @@ 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);
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
|
||||
auto textHeight = bubble.text.countHeight(textWidth);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue