mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added ability to swipe-to-back to admin log section.
This commit is contained in:
parent
0d6a1e6610
commit
13a93102a5
4 changed files with 52 additions and 7 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<QColor, QColor> {
|
||||
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<Window::SectionMemento> Widget::createMemento() {
|
||||
auto result = std::make_shared<SectionMemento>(channel());
|
||||
saveState(result.get());
|
||||
|
|
|
@ -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<SectionMemento*> memento);
|
||||
void restoreState(not_null<SectionMemento*> memento);
|
||||
void setupShortcuts();
|
||||
void setupSwipeReply();
|
||||
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
QPointer<InnerWidget> _inner;
|
||||
|
@ -81,6 +83,8 @@ private:
|
|||
object_ptr<Ui::PlainShadow> _fixedBarShadow;
|
||||
object_ptr<Ui::FlatButton> _whatIsThis;
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
|
||||
};
|
||||
|
||||
class SectionMemento : public Window::SectionMemento {
|
||||
|
|
Loading…
Add table
Reference in a new issue