File indexing completed on 2024-12-22 04:46:05
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 0014 class LIBRUQOLAWIDGETS_TESTS_EXPORT MessageAttachmentDelegateHelperSound : public MessageAttachmentDelegateHelperBase 0015 { 0016 public: 0017 explicit MessageAttachmentDelegateHelperSound(RocketChatAccount *account, QListView *view, TextSelectionImpl *textSelectionImpl); 0018 ~MessageAttachmentDelegateHelperSound() override; 0019 void 0020 draw(const MessageAttachment &msgAttach, QPainter *painter, QRect messageRect, const QModelIndex &index, const QStyleOptionViewItem &option) const override; 0021 [[nodiscard]] QSize sizeHint(const MessageAttachment &msgAttach, const QModelIndex &index, int maxWidth, const QStyleOptionViewItem &option) const override; 0022 [[nodiscard]] bool handleMouseEvent(const MessageAttachment &msgAttach, 0023 QMouseEvent *mouseEvent, 0024 QRect attachmentsRect, 0025 const QStyleOptionViewItem &option, 0026 const QModelIndex &index) override; 0027 0028 private: 0029 struct SoundLayout { 0030 QString audioPath; 0031 QString title; 0032 QSize titleSize; 0033 QSize descriptionSize; 0034 QRect playerVolumeButtonRect; 0035 QRect downloadButtonRect; 0036 bool hasDescription = false; 0037 }; 0038 [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT QPoint adaptMousePosition(const QPoint &pos, 0039 const MessageAttachment &msgAttach, 0040 QRect attachmentsRect, 0041 const QStyleOptionViewItem &option) override; 0042 [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT SoundLayout layoutSound(const MessageAttachment &msgAttach, 0043 const QStyleOptionViewItem &option, 0044 int attachmentsWidth) const; 0045 const QIcon mPlayerVolumeIcon; 0046 const QIcon mDownloadIcon; 0047 };