"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-4.8.3/Telegram/SourceFiles/info/media/info_media_widget.h" (1 Jun 2023, 3073 Bytes) of package /linux/misc/tdesktop-4.8.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "info_media_widget.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 This file is part of Telegram Desktop,
    3 the official desktop application for the Telegram messaging service.
    4 
    5 For license and copyright information please follow this link:
    6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
    7 */
    8 #pragma once
    9 
   10 #include "info/info_content_widget.h"
   11 #include "storage/storage_shared_media.h"
   12 #include "data/data_search_controller.h"
   13 
   14 namespace Data {
   15 class ForumTopic;
   16 } // namespace Data
   17 
   18 namespace Info::Media {
   19 
   20 using Type = Storage::SharedMediaType;
   21 
   22 std::optional<int> TypeToTabIndex(Type type);
   23 Type TabIndexToType(int index);
   24 
   25 class InnerWidget;
   26 
   27 class Memento final : public ContentMemento {
   28 public:
   29     explicit Memento(not_null<Controller*> controller);
   30     Memento(not_null<PeerData*> peer, PeerId migratedPeerId, Type type);
   31     Memento(not_null<Data::ForumTopic*> topic, Type type);
   32 
   33     using SearchState = Api::DelayedSearchController::SavedState;
   34 
   35     object_ptr<ContentWidget> createWidget(
   36         QWidget *parent,
   37         not_null<Controller*> controller,
   38         const QRect &geometry) override;
   39 
   40     [[nodiscard]] Section section() const override;
   41 
   42     [[nodiscard]] Type type() const {
   43         return _type;
   44     }
   45 
   46     // Only for media, not for downloads.
   47     void setAroundId(FullMsgId aroundId) {
   48         _aroundId = aroundId;
   49     }
   50     [[nodiscard]] FullMsgId aroundId() const {
   51         return _aroundId;
   52     }
   53     void setIdsLimit(int limit) {
   54         _idsLimit = limit;
   55     }
   56     [[nodiscard]] int idsLimit() const {
   57         return _idsLimit;
   58     }
   59 
   60     void setScrollTopItem(GlobalMsgId item) {
   61         _scrollTopItem = item;
   62     }
   63     [[nodiscard]] GlobalMsgId scrollTopItem() const {
   64         return _scrollTopItem;
   65     }
   66     void setScrollTopItemPosition(int64 position) {
   67         _scrollTopItemPosition = position;
   68     }
   69     [[nodiscard]] int64 scrollTopItemPosition() const {
   70         return _scrollTopItemPosition;
   71     }
   72     void setScrollTopShift(int shift) {
   73         _scrollTopShift = shift;
   74     }
   75     [[nodiscard]] int scrollTopShift() const {
   76         return _scrollTopShift;
   77     }
   78     void setSearchState(SearchState &&state) {
   79         _searchState = std::move(state);
   80     }
   81     [[nodiscard]] SearchState searchState() {
   82         return std::move(_searchState);
   83     }
   84 
   85 private:
   86     Memento(
   87         not_null<PeerData*> peer,
   88         Data::ForumTopic *topic,
   89         PeerId migratedPeerId,
   90         Type type);
   91 
   92     Type _type = Type::Photo;
   93     FullMsgId _aroundId;
   94     int _idsLimit = 0;
   95     int64 _scrollTopItemPosition = 0;
   96     GlobalMsgId _scrollTopItem;
   97     int _scrollTopShift = 0;
   98     SearchState _searchState;
   99 
  100 };
  101 
  102 class Widget final : public ContentWidget {
  103 public:
  104     Widget(
  105         QWidget *parent,
  106         not_null<Controller*> controller);
  107 
  108     void setIsStackBottom(bool isStackBottom) override;
  109 
  110     bool showInternal(
  111         not_null<ContentMemento*> memento) override;
  112 
  113     void setInternalState(
  114         const QRect &geometry,
  115         not_null<Memento*> memento);
  116 
  117     rpl::producer<SelectedItems> selectedListValue() const override;
  118     void selectionAction(SelectionAction action) override;
  119 
  120     rpl::producer<QString> title() override;
  121 
  122 private:
  123     void saveState(not_null<Memento*> memento);
  124     void restoreState(not_null<Memento*> memento);
  125 
  126     std::shared_ptr<ContentMemento> doCreateMemento() override;
  127 
  128     InnerWidget *_inner = nullptr;
  129 
  130 };
  131 
  132 } // namespace Info::Media