mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-10 01:44:01 +02:00
Added ability to swipe-to-back to dialogs widget.
This commit is contained in:
parent
d93d8ab1cc
commit
05cd9eebb8
2 changed files with 58 additions and 0 deletions
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_key.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "history/view/history_view_top_bar_widget.h"
|
||||
#include "history/view/history_view_contact_status.h"
|
||||
#include "history/view/history_view_requests_bar.h"
|
||||
|
@ -666,6 +667,7 @@ Widget::Widget(
|
|||
setupMoreChatsBar();
|
||||
setupDownloadBar();
|
||||
}
|
||||
setupSwipeBack();
|
||||
|
||||
if (session().settings().dialogsFiltersEnabled()
|
||||
&& (Core::App().settings().chatFiltersHorizontal()
|
||||
|
@ -674,6 +676,58 @@ Widget::Widget(
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::setupSwipeBack() {
|
||||
HistoryView::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
this,
|
||||
[]() -> std::pair<QColor, QColor> {
|
||||
return {
|
||||
st::historyForwardChooseBg->c,
|
||||
st::historyForwardChooseFg->c,
|
||||
};
|
||||
});
|
||||
}
|
||||
_swipeBackData.callback(data);
|
||||
return;
|
||||
} else {
|
||||
if (_swipeBackData.lifetime) {
|
||||
_swipeBackData = {};
|
||||
}
|
||||
}
|
||||
}, [=](int, Qt::LayoutDirection direction) {
|
||||
if ((direction != Qt::RightToLeft)
|
||||
|| _childListShown.current()
|
||||
|| (!controller()->isPrimary() && (_layout != Layout::Child))
|
||||
|| (!controller()->shownForum().current()
|
||||
&& !controller()->openedFolder().current())) {
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
}
|
||||
return HistoryView::SwipeHandlerFinishData{
|
||||
.callback = [=] {
|
||||
_swipeBackData = {};
|
||||
if (const auto forum = controller()->shownForum().current()) {
|
||||
const auto id = controller()->windowId();
|
||||
const auto initial = id.forum();
|
||||
if (!initial) {
|
||||
controller()->closeForum();
|
||||
} else if (initial != forum) {
|
||||
controller()->showForum(initial);
|
||||
}
|
||||
} else if (controller()->openedFolder().current()) {
|
||||
if (!controller()->windowId().folder()) {
|
||||
controller()->closeFolder();
|
||||
}
|
||||
}
|
||||
},
|
||||
.msgBareId = HistoryView::kMsgBareIdSwipeBack,
|
||||
};
|
||||
}, nullptr);
|
||||
|
||||
}
|
||||
|
||||
void Widget::chosenRow(const ChosenRow &row) {
|
||||
storiesToggleExplicitExpand(false);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "base/timer.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/userpic_view.h"
|
||||
|
@ -206,6 +207,7 @@ private:
|
|||
void setupDownloadBar();
|
||||
void setupShortcuts();
|
||||
void setupStories();
|
||||
void setupSwipeBack();
|
||||
void storiesExplicitCollapse();
|
||||
void collectStoriesUserpicsViews(Data::StorySourcesList list);
|
||||
void storiesToggleExplicitExpand(bool expand);
|
||||
|
@ -383,6 +385,8 @@ private:
|
|||
ChatSearchTab _searchQueryTab = {};
|
||||
ChatTypeFilter _searchQueryFilter = {};
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
|
||||
SearchProcessState _searchProcess;
|
||||
SearchProcessState _migratedProcess;
|
||||
SearchProcessState _postsProcess;
|
||||
|
|
Loading…
Add table
Reference in a new issue