"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-2.6.1/Telegram/SourceFiles/window/window_media_preview.h" (24 Feb 2021, 2130 Bytes) of package /linux/misc/tdesktop-2.6.1.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 "window_media_preview.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 "media/clip/media_clip_reader.h"
   11 #include "ui/effects/animations.h"
   12 #include "data/data_file_origin.h"
   13 #include "ui/rp_widget.h"
   14 
   15 namespace Data {
   16 class PhotoMedia;
   17 class DocumentMedia;
   18 } // namespace Data
   19 
   20 namespace Lottie {
   21 class SinglePlayer;
   22 } // namespace Lottie
   23 
   24 namespace Window {
   25 
   26 class SessionController;
   27 
   28 class MediaPreviewWidget : public Ui::RpWidget, private base::Subscriber {
   29 public:
   30     MediaPreviewWidget(
   31         QWidget *parent,
   32         not_null<Window::SessionController*> controller);
   33 
   34     void showPreview(
   35         Data::FileOrigin origin,
   36         not_null<DocumentData*> document);
   37     void showPreview(
   38         Data::FileOrigin origin,
   39         not_null<PhotoData*> photo);
   40     void hidePreview();
   41 
   42     ~MediaPreviewWidget();
   43 
   44 protected:
   45     void paintEvent(QPaintEvent *e) override;
   46     void resizeEvent(QResizeEvent *e) override;
   47 
   48 private:
   49     void validateGifAnimation();
   50     void startGifAnimation(const Media::Clip::ReaderPointer &gif);
   51     QSize currentDimensions() const;
   52     QPixmap currentImage() const;
   53     void setupLottie();
   54     void startShow();
   55     void fillEmojiString();
   56     void resetGifAndCache();
   57     [[nodiscard]] QRect updateArea() const;
   58 
   59     not_null<Window::SessionController*> _controller;
   60 
   61     Ui::Animations::Simple _a_shown;
   62     bool _hiding = false;
   63     Data::FileOrigin _origin;
   64     PhotoData *_photo = nullptr;
   65     DocumentData *_document = nullptr;
   66     std::shared_ptr<Data::PhotoMedia> _photoMedia;
   67     std::shared_ptr<Data::DocumentMedia> _documentMedia;
   68     Media::Clip::ReaderPointer _gif, _gifThumbnail;
   69     crl::time _gifLastPosition = 0;
   70     std::unique_ptr<Lottie::SinglePlayer> _lottie;
   71 
   72     int _emojiSize;
   73     std::vector<not_null<EmojiPtr>> _emojiList;
   74 
   75     void clipCallback(Media::Clip::Notification notification);
   76 
   77     enum CacheStatus {
   78         CacheNotLoaded,
   79         CacheThumbLoaded,
   80         CacheLoaded,
   81     };
   82     mutable CacheStatus _cacheStatus = CacheNotLoaded;
   83     mutable QPixmap _cache;
   84     mutable QSize _cachedSize;
   85 
   86 };
   87 
   88 } // namespace Window