File indexing completed on 2024-05-26 05:06:02

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "messageattachmentdelegatehelperbase.h"
0010 
0011 #include <QIcon>
0012 #include <QModelIndex>
0013 #include <QRect>
0014 
0015 class LIBRUQOLAWIDGETS_TESTS_EXPORT MessageAttachmentDelegateHelperVideo : public MessageAttachmentDelegateHelperBase
0016 {
0017 public:
0018     explicit MessageAttachmentDelegateHelperVideo(RocketChatAccount *account, QListView *view, TextSelectionImpl *textSelectionImpl);
0019     ~MessageAttachmentDelegateHelperVideo() override;
0020     void
0021     draw(const MessageAttachment &msgAttach, QPainter *painter, QRect messageRect, const QModelIndex &index, const QStyleOptionViewItem &option) const override;
0022     [[nodiscard]] QSize sizeHint(const MessageAttachment &msgAttach, const QModelIndex &index, int maxWidth, const QStyleOptionViewItem &option) const override;
0023     [[nodiscard]] bool handleMouseEvent(const MessageAttachment &msgAttach,
0024                                         QMouseEvent *mouseEvent,
0025                                         QRect attachmentsRect,
0026                                         const QStyleOptionViewItem &option,
0027                                         const QModelIndex &index) override;
0028 
0029 private:
0030     struct VideoLayout {
0031         QString videoPath;
0032         QString title;
0033         QSize titleSize;
0034         QSize descriptionSize;
0035         QRect downloadButtonRect;
0036         QRect showButtonRect;
0037         bool hasDescription = false;
0038     };
0039     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT VideoLayout layoutVideo(const MessageAttachment &msgAttach,
0040                                                                      const QStyleOptionViewItem &option,
0041                                                                      int attachmentsWidth) const;
0042     [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT QPoint adaptMousePosition(const QPoint &pos,
0043                                                                        const MessageAttachment &msgAttach,
0044                                                                        QRect attachmentsRect,
0045                                                                        const QStyleOptionViewItem &option) override;
0046     const QIcon mDownloadIcon;
0047     const QIcon mVisibilityIcon;
0048 };