mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to swipe-to-back to other sections.
This commit is contained in:
parent
13a93102a5
commit
d662a8f2b9
6 changed files with 93 additions and 0 deletions
|
@ -919,6 +919,8 @@ PRIVATE
|
||||||
history/history_unread_things.h
|
history/history_unread_things.h
|
||||||
history/history_view_highlight_manager.cpp
|
history/history_view_highlight_manager.cpp
|
||||||
history/history_view_highlight_manager.h
|
history/history_view_highlight_manager.h
|
||||||
|
history/history_view_swipe_back_session.cpp
|
||||||
|
history/history_view_swipe_back_session.h
|
||||||
history/history_widget.cpp
|
history/history_widget.cpp
|
||||||
history/history_widget.h
|
history/history_widget.h
|
||||||
info/bot/earn/info_bot_earn_list.cpp
|
info/bot/earn/info_bot_earn_list.cpp
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "history/history_view_swipe_back_session.h"
|
||||||
|
|
||||||
|
#include "history/history_view_swipe_data.h"
|
||||||
|
#include "history/history_view_swipe.h"
|
||||||
|
#include "history/view/history_view_list_widget.h"
|
||||||
|
#include "ui/chat/chat_style.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
|
||||||
|
void SetupSwipeBackSection(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<Ui::ScrollArea*> scroll,
|
||||||
|
not_null<HistoryView::ListWidget*> list) {
|
||||||
|
const auto swipeBackData
|
||||||
|
= list->lifetime().make_state<HistoryView::SwipeBackResult>();
|
||||||
|
HistoryView::SetupSwipeHandler(parent, scroll, [=](
|
||||||
|
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||||
|
if (data.translation > 0) {
|
||||||
|
if (!swipeBackData->callback) {
|
||||||
|
const auto color = [=]() -> std::pair<QColor, QColor> {
|
||||||
|
const auto c = list->delegate()->listPreparePaintContext({
|
||||||
|
.theme = list->delegate()->listChatTheme(),
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
c.st->msgServiceBg()->c,
|
||||||
|
c.st->msgServiceFg()->c,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
(*swipeBackData) = HistoryView::SetupSwipeBack(parent, color);
|
||||||
|
}
|
||||||
|
swipeBackData->callback(data);
|
||||||
|
return;
|
||||||
|
} else if (swipeBackData->lifetime) {
|
||||||
|
(*swipeBackData) = {};
|
||||||
|
}
|
||||||
|
}, [=](int, Qt::LayoutDirection direction) {
|
||||||
|
if (direction != Qt::RightToLeft) {
|
||||||
|
return HistoryView::SwipeHandlerFinishData();
|
||||||
|
}
|
||||||
|
return HistoryView::SwipeHandlerFinishData{
|
||||||
|
.callback = [=] { list->controller()->showBackFromStack(); },
|
||||||
|
.msgBareId = HistoryView::kMsgBareIdSwipeBack,
|
||||||
|
};
|
||||||
|
}, list->touchMaybeSelectingValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Window
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class WindowListDelegate;
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
class ListWidget;
|
||||||
|
} // namespace HistoryView
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class RpWidget;
|
||||||
|
class ScrollArea;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
|
||||||
|
class SectionWidget;
|
||||||
|
|
||||||
|
void SetupSwipeBackSection(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
not_null<Ui::ScrollArea*> scroll,
|
||||||
|
not_null<HistoryView::ListWidget*> list);
|
||||||
|
|
||||||
|
} // namespace Window
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
#include "history/history_view_swipe_back_session.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
|
@ -173,6 +174,7 @@ PinnedWidget::PinnedWidget(
|
||||||
|
|
||||||
setupClearButton();
|
setupClearButton();
|
||||||
setupTranslateBar();
|
setupTranslateBar();
|
||||||
|
Window::SetupSwipeBackSection(this, _scroll.get(), _inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
PinnedWidget::~PinnedWidget() = default;
|
PinnedWidget::~PinnedWidget() = default;
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_drag_area.h"
|
#include "history/history_drag_area.h"
|
||||||
#include "history/history_item_helpers.h" // GetErrorForSending.
|
#include "history/history_item_helpers.h" // GetErrorForSending.
|
||||||
|
#include "history/history_view_swipe_back_session.h"
|
||||||
#include "menu/menu_send.h" // SendMenu::Type.
|
#include "menu/menu_send.h" // SendMenu::Type.
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/tooltip.h"
|
#include "ui/widgets/tooltip.h"
|
||||||
|
@ -245,6 +246,7 @@ ScheduledWidget::ScheduledWidget(
|
||||||
_inner->setEmptyInfoWidget(std::move(emptyInfo));
|
_inner->setEmptyInfoWidget(std::move(emptyInfo));
|
||||||
}
|
}
|
||||||
setupComposeControls();
|
setupComposeControls();
|
||||||
|
Window::SetupSwipeBackSection(this, _scroll, _inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduledWidget::~ScheduledWidget() = default;
|
ScheduledWidget::~ScheduledWidget() = default;
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_list_widget.h"
|
#include "history/view/history_view_list_widget.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
#include "history/history_view_swipe_back_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -146,6 +147,7 @@ SublistWidget::SublistWidget(
|
||||||
|
|
||||||
setupShortcuts();
|
setupShortcuts();
|
||||||
setupTranslateBar();
|
setupTranslateBar();
|
||||||
|
Window::SetupSwipeBackSection(this, _scroll.get(), _inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
SublistWidget::~SublistWidget() = default;
|
SublistWidget::~SublistWidget() = default;
|
||||||
|
|
Loading…
Add table
Reference in a new issue