Implement some power saving options.

This commit is contained in:
John Preston
2023-02-21 16:31:55 +04:00
parent 02bc950b57
commit 2a4c39b9d7
53 changed files with 446 additions and 108 deletions
@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/unread_badge.h"
#include "ui/unread_badge_paint.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h"
#include "support/support_helper.h"
@@ -262,7 +263,8 @@ void PaintFolderEntryText(
: st::dialogsTextPaletteArchive),
.spoiler = Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = rect.height() / st::dialogsTextFont->height,
});
}
@@ -420,7 +422,8 @@ void PaintRow(
.availableWidth = availableWidth,
.spoiler = Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1,
});
} else if (draft
@@ -514,7 +517,8 @@ void PaintRow(
: st::dialogsTextPaletteDraft)),
.spoiler = Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1,
});
}
@@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/image/image.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h"
#include "lang/lang_text_entity.h"
@@ -296,6 +297,8 @@ void MessageView::paint(
finalRight -= st::forumDialogJumpArrowSkip;
}
const auto lines = rect.height() / st::dialogsTextFont->height;
const auto pausedSpoiler = context.paused
|| On(PowerSaving::kChatSpoiler);
if (!_senderCache.isEmpty()) {
_senderCache.draw(p, {
.position = rect.topLeft(),
@@ -323,7 +326,7 @@ void MessageView::paint(
p.drawImage(mini, image.data);
if (image.hasSpoiler()) {
const auto frame = DefaultImageSpoiler().frame(
_spoiler->index(context.now, context.paused));
_spoiler->index(context.now, pausedSpoiler));
FillSpoilerRect(p, mini, frame);
}
}
@@ -341,7 +344,8 @@ void MessageView::paint(
.palette = palette,
.spoiler = Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = pausedSpoiler,
.elisionLines = lines,
});
rect.setLeft(rect.x() + _textCache.maxWidth());
@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/ui_integration.h"
#include "lang/lang_keys.h"
#include "ui/painter.h"
#include "ui/power_saving.h"
#include "ui/text/text_options.h"
#include "ui/text/text_utilities.h"
#include "ui/effects/ripple_animation.h"
@@ -138,7 +139,8 @@ void TopicsView::paint(
.palette = palette,
.spoiler = Text::DefaultSpoilerCache(),
.now = context.now,
.paused = context.paused,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1,
});
const auto skip = skipBig