mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 07:23:02 +02:00
Fix spoilers in todo lists.
This commit is contained in:
parent
e1420ba26c
commit
7ccf26310d
2 changed files with 30 additions and 3 deletions
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
#include "history/view/history_view_message.h"
|
#include "history/view/history_view_message.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
|
#include "history/view/history_view_text_helper.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "ui/chat/message_bubble.h"
|
#include "ui/chat/message_bubble.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
@ -61,6 +62,7 @@ struct TodoList::Task {
|
||||||
Task();
|
Task();
|
||||||
|
|
||||||
void fillData(
|
void fillData(
|
||||||
|
not_null<Element*> view,
|
||||||
not_null<TodoListData*> todolist,
|
not_null<TodoListData*> todolist,
|
||||||
const TodoListItem &original,
|
const TodoListItem &original,
|
||||||
Ui::Text::MarkedContext context);
|
Ui::Text::MarkedContext context);
|
||||||
|
@ -83,6 +85,7 @@ TodoList::Task::Task()
|
||||||
}
|
}
|
||||||
|
|
||||||
void TodoList::Task::fillData(
|
void TodoList::Task::fillData(
|
||||||
|
not_null<Element*> view,
|
||||||
not_null<TodoListData*> todolist,
|
not_null<TodoListData*> todolist,
|
||||||
const TodoListItem &original,
|
const TodoListItem &original,
|
||||||
Ui::Text::MarkedContext context) {
|
Ui::Text::MarkedContext context) {
|
||||||
|
@ -97,6 +100,7 @@ void TodoList::Task::fillData(
|
||||||
original.text,
|
original.text,
|
||||||
Ui::WebpageTextTitleOptions(),
|
Ui::WebpageTextTitleOptions(),
|
||||||
context);
|
context);
|
||||||
|
InitElementTextPart(view, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TodoList::Task::setCompletedBy(PeerData *by) {
|
void TodoList::Task::setCompletedBy(PeerData *by) {
|
||||||
|
@ -269,6 +273,7 @@ void TodoList::updateTexts() {
|
||||||
.repaint = [=] { repaint(); },
|
.repaint = [=] { repaint(); },
|
||||||
.customEmojiLoopLimit = 2,
|
.customEmojiLoopLimit = 2,
|
||||||
}));
|
}));
|
||||||
|
InitElementTextPart(_parent, _title);
|
||||||
}
|
}
|
||||||
if (_flags != _todolist->flags() || _subtitle.isEmpty()) {
|
if (_flags != _todolist->flags() || _subtitle.isEmpty()) {
|
||||||
_flags = _todolist->flags();
|
_flags = _todolist->flags();
|
||||||
|
@ -298,7 +303,7 @@ void TodoList::updateTasks(bool skipAnimations) {
|
||||||
auto &&tasks = ranges::views::zip(_tasks, _todolist->items);
|
auto &&tasks = ranges::views::zip(_tasks, _todolist->items);
|
||||||
for (auto &&[task, original] : tasks) {
|
for (auto &&[task, original] : tasks) {
|
||||||
const auto wasDate = task.completionDate;
|
const auto wasDate = task.completionDate;
|
||||||
task.fillData(_todolist, original, context);
|
task.fillData(_parent, _todolist, original, context);
|
||||||
if (!skipAnimations && (!wasDate != !task.completionDate)) {
|
if (!skipAnimations && (!wasDate != !task.completionDate)) {
|
||||||
startToggleAnimation(task);
|
startToggleAnimation(task);
|
||||||
animated = true;
|
animated = true;
|
||||||
|
@ -315,7 +320,7 @@ void TodoList::updateTasks(bool skipAnimations) {
|
||||||
) | ranges::views::transform([&](const TodoListItem &item) {
|
) | ranges::views::transform([&](const TodoListItem &item) {
|
||||||
auto result = Task();
|
auto result = Task();
|
||||||
result.id = item.id;
|
result.id = item.id;
|
||||||
result.fillData(_todolist, item, context);
|
result.fillData(_parent, _todolist, item, context);
|
||||||
return result;
|
return result;
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
|
|
||||||
|
@ -431,7 +436,16 @@ void TodoList::draw(Painter &p, const PaintContext &context) const {
|
||||||
paintw -= padding.left() + padding.right();
|
paintw -= padding.left() + padding.right();
|
||||||
|
|
||||||
p.setPen(stm->historyTextFg);
|
p.setPen(stm->historyTextFg);
|
||||||
_title.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, context.selection);
|
_title.draw(p, {
|
||||||
|
.position = { padding.left(), tshift },
|
||||||
|
.availableWidth = paintw,
|
||||||
|
.palette = &stm->textPalette,
|
||||||
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
|
.now = context.now,
|
||||||
|
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
|
||||||
|
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
|
||||||
|
.selection = context.selection,
|
||||||
|
});
|
||||||
tshift += _title.countHeight(paintw) + st::historyPollSubtitleSkip;
|
tshift += _title.countHeight(paintw) + st::historyPollSubtitleSkip;
|
||||||
|
|
||||||
p.setPen(stm->msgDateFg);
|
p.setPen(stm->msgDateFg);
|
||||||
|
@ -788,6 +802,17 @@ bool TodoList::hasHeavyPart() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TodoList::hideSpoilers() {
|
||||||
|
if (_title.hasSpoilers()) {
|
||||||
|
_title.setSpoilerRevealed(false, anim::type::instant);
|
||||||
|
}
|
||||||
|
for (auto &task : _tasks) {
|
||||||
|
if (task.text.hasSpoilers()) {
|
||||||
|
task.text.setSpoilerRevealed(false, anim::type::instant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Media::TodoTaskInfo> TodoList::takeTasksInfo() {
|
std::vector<Media::TodoTaskInfo> TodoList::takeTasksInfo() {
|
||||||
if (_tasks.empty()) {
|
if (_tasks.empty()) {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -64,6 +64,8 @@ public:
|
||||||
void unloadHeavyPart() override;
|
void unloadHeavyPart() override;
|
||||||
bool hasHeavyPart() const override;
|
bool hasHeavyPart() const override;
|
||||||
|
|
||||||
|
void hideSpoilers() override;
|
||||||
|
|
||||||
std::vector<TodoTaskInfo> takeTasksInfo() override;
|
std::vector<TodoTaskInfo> takeTasksInfo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue