diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index a7ea96d4c0..61a599cac4 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1039,6 +1039,16 @@ void InnerWidget::restoreScrollPosition() { _scrollToSignal.fire_copy(newVisibleTop); } +Ui::ChatPaintContext InnerWidget::preparePaintContext(QRect clip) const { + return _controller->preparePaintContext({ + .theme = _theme.get(), + .clip = clip, + .visibleAreaPositionGlobal = mapToGlobal(QPoint(0, _visibleTop)), + .visibleAreaTop = _visibleTop, + .visibleAreaWidth = width(), + }); +} + void InnerWidget::paintEvent(QPaintEvent *e) { if (_controller->contentOverlapped(this, e)) { return; @@ -1051,13 +1061,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) { Painter p(this); auto clip = e->rect(); - auto context = _controller->preparePaintContext({ - .theme = _theme.get(), - .clip = clip, - .visibleAreaPositionGlobal = mapToGlobal(QPoint(0, _visibleTop)), - .visibleAreaTop = _visibleTop, - .visibleAreaWidth = width(), - }); + auto context = preparePaintContext(clip); if (_items.empty() && _upLoaded && _downLoaded) { paintEmpty(p, context.st); } else { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h index 209cc0384e..ed23bdad44 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h @@ -36,6 +36,7 @@ class PopupMenu; class ChatStyle; class ChatTheme; struct PeerUserpicView; +struct ChatPaintContext; } // namespace Ui namespace Window { @@ -69,6 +70,8 @@ public: return _channel; } + Ui::ChatPaintContext preparePaintContext(QRect clip) const; + // Set the correct scroll position after being resized. void restoreScrollPosition(); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index 417223ae30..4047c533bd 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -9,8 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/admin_log/history_admin_log_inner.h" #include "history/admin_log/history_admin_log_filter.h" +#include "history/history_view_swipe.h" #include "profile/profile_back_button.h" #include "core/shortcuts.h" +#include "ui/chat/chat_style.h" #include "ui/effects/animations.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/shadow.h" @@ -341,6 +343,7 @@ Widget::Widget( }); setupShortcuts(); + setupSwipeReply(); } void Widget::showFilter() { @@ -416,6 +419,37 @@ void Widget::setupShortcuts() { }, lifetime()); } +void Widget::setupSwipeReply() { + HistoryView::SetupSwipeHandler(this, _scroll.data(), [=]( + HistoryView::ChatPaintGestureHorizontalData data) { + if (data.translation > 0) { + if (!_swipeBackData.callback) { + _swipeBackData = HistoryView::SetupSwipeBack( + this, + [=]() -> std::pair { + auto context = _inner->preparePaintContext({}); + return { + context.st->msgServiceBg()->c, + context.st->msgServiceFg()->c, + }; + }); + } + _swipeBackData.callback(data); + return; + } else if (_swipeBackData.lifetime) { + _swipeBackData = {}; + } + }, [=](int, Qt::LayoutDirection direction) { + if (direction == Qt::RightToLeft) { + return HistoryView::SwipeHandlerFinishData{ + .callback = [=] { controller()->showBackFromStack(); }, + .msgBareId = HistoryView::kMsgBareIdSwipeBack, + }; + } + return HistoryView::SwipeHandlerFinishData(); + }, nullptr); +} + std::shared_ptr Widget::createMemento() { auto result = std::make_shared(channel()); saveState(result.get()); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.h index 8a547ee817..7521b8f258 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.h @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/section_memento.h" #include "history/admin_log/history_admin_log_item.h" #include "history/admin_log/history_admin_log_filter_value.h" +#include "history/history_view_swipe_data.h" #include "mtproto/sender.h" namespace Ui { @@ -74,6 +75,7 @@ private: void saveState(not_null memento); void restoreState(not_null memento); void setupShortcuts(); + void setupSwipeReply(); object_ptr _scroll; QPointer _inner; @@ -81,6 +83,8 @@ private: object_ptr _fixedBarShadow; object_ptr _whatIsThis; + HistoryView::SwipeBackResult _swipeBackData; + }; class SectionMemento : public Window::SectionMemento {