diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index 9187b0251d..2ae0883469 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/media/info_media_widget.h" #include "info/common_groups/info_common_groups_widget.h" #include "info/info_layer_widget.h" +#include "history/history_view_swipe.h" #include "info/info_section_widget.h" #include "info/info_controller.h" #include "lang/lang_keys.h" @@ -76,6 +77,8 @@ ContentWidget::ContentWidget( ) | rpl::start_with_next([this] { updateControlsGeometry(); }, lifetime()); + + setupSwipeReply(); } void ContentWidget::resizeEvent(QResizeEvent *e) { @@ -381,6 +384,37 @@ not_null ContentWidget::scroll() const { return _scroll.data(); } +void ContentWidget::setupSwipeReply() { + HistoryView::SetupSwipeHandler(this, _scroll.data(), [=]( + HistoryView::ChatPaintGestureHorizontalData data) { + if (data.translation > 0) { + if (!_swipeBackData.callback) { + _swipeBackData = HistoryView::SetupSwipeBack( + this, + []() -> std::pair { + return { + st::historyForwardChooseBg->c, + st::historyForwardChooseFg->c, + }; + }); + } + _swipeBackData.callback(data); + return; + } else if (_swipeBackData.lifetime) { + _swipeBackData = {}; + } + }, [=](int, Qt::LayoutDirection direction) { + if (_controller->wrap() != Wrap::Narrow + || direction != Qt::RightToLeft) { + return HistoryView::SwipeHandlerFinishData(); + } + return HistoryView::SwipeHandlerFinishData{ + .callback = [=] { _controller->showBackFromStack(); }, + .msgBareId = HistoryView::kMsgBareIdSwipeBack, + }; + }, nullptr); +} + Key ContentMemento::key() const { if (const auto topic = this->topic()) { return Key(topic); diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index 0fafdfe01c..c53ffadf44 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_wrap_widget.h" #include "info/statistics/info_statistics_tag.h" +#include "history/history_view_swipe_data.h" namespace Api { struct WhoReadList; @@ -167,6 +168,7 @@ private: RpWidget *doSetInnerWidget(object_ptr inner); void updateControlsGeometry(); void refreshSearchField(bool shown); + void setupSwipeReply(); virtual std::shared_ptr doCreateMemento() = 0; @@ -190,6 +192,8 @@ private: // To paint round edges from content. style::margins _paintPadding; + HistoryView::SwipeBackResult _swipeBackData; + }; class ContentMemento {