/* 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 #include "window/section_widget.h" #include "window/section_memento.h" #include "history/admin_log/history_admin_log_item.h" #include "mtproto/sender.h" namespace Ui { class ScrollArea; class PlainShadow; class FlatButton; } // namespace Ui namespace Profile { class BackButton; } // namespace Profile namespace AdminLog { class FixedBar; class InnerWidget; class SectionMemento; struct FilterValue { enum class Flag : uint32 { Join = (1U << 0), Leave = (1U << 1), Invite = (1U << 2), Ban = (1U << 3), Unban = (1U << 4), Kick = (1U << 5), Unkick = (1U << 6), Promote = (1U << 7), Demote = (1U << 8), Info = (1U << 9), Settings = (1U << 10), Pinned = (1U << 11), Edit = (1U << 12), Delete = (1U << 13), GroupCall = (1U << 14), Invites = (1U << 15), MAX_FIELD = (1U << 15), }; using Flags = base::flags; friend inline constexpr bool is_flag_type(Flag) { return true; }; // Empty "flags" means all events. Flags flags = 0; std::vector> admins; bool allUsers = true; }; inline bool operator==(const FilterValue &a, const FilterValue &b) { return (a.flags == b.flags && a.admins == b.admins && a.allUsers == b.allUsers); } inline bool operator!=(const FilterValue &a, const FilterValue &b) { return !(a == b); } class Widget final : public Window::SectionWidget { public: Widget( QWidget *parent, not_null controller, not_null channel); not_null channel() const; Dialogs::RowDescriptor activeChat() const override; bool hasTopBarShadow() const override { return true; } QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms) override; bool showInternal( not_null memento, const Window::SectionShow ¶ms) override; std::shared_ptr createMemento() override; void setInternalState(const QRect &geometry, not_null memento); // Float player interface. bool floatPlayerHandleWheelEvent(QEvent *e) override; QRect floatPlayerAvailableRect() override; void applyFilter(FilterValue &&value); protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; void showAnimatedHook( const Window::SectionSlideParams ¶ms) override; void showFinishedHook() override; void doSetInnerFocus() override; private: void showFilter(); void onScroll(); void updateAdaptiveLayout(); void saveState(not_null memento); void restoreState(not_null memento); void setupShortcuts(); object_ptr _scroll; QPointer _inner; object_ptr _fixedBar; object_ptr _fixedBarShadow; object_ptr _whatIsThis; }; class SectionMemento : public Window::SectionMemento { public: using Element = HistoryView::Element; SectionMemento(not_null channel) : _channel(channel) { } object_ptr createWidget( QWidget *parent, not_null controller, Window::Column column, const QRect &geometry) override; not_null getChannel() const { return _channel; } void setScrollTop(int scrollTop) { _scrollTop = scrollTop; } int getScrollTop() const { return _scrollTop; } void setAdmins(std::vector> admins) { _admins = std::move(admins); } void setAdminsCanEdit(std::vector> admins) { _adminsCanEdit = std::move(admins); } std::vector> takeAdmins() { return std::move(_admins); } std::vector> takeAdminsCanEdit() { return std::move(_adminsCanEdit); } void setItems( std::vector &&items, std::set &&eventIds, bool upLoaded, bool downLoaded) { _items = std::move(items); _eventIds = std::move(eventIds); _upLoaded = upLoaded; _downLoaded = downLoaded; } void setFilter(FilterValue &&filter) { _filter = std::move(filter); } void setSearchQuery(QString &&query) { _searchQuery = std::move(query); } std::vector takeItems() { return std::move(_items); } std::set takeEventIds() { return std::move(_eventIds); } bool upLoaded() const { return _upLoaded; } bool downLoaded() const { return _downLoaded; } FilterValue takeFilter() { return std::move(_filter); } QString takeSearchQuery() { return std::move(_searchQuery); } private: not_null _channel; int _scrollTop = 0; std::vector> _admins; std::vector> _adminsCanEdit; std::vector _items; std::set _eventIds; bool _upLoaded = false; bool _downLoaded = true; FilterValue _filter; QString _searchQuery; }; } // namespace AdminLog