Line data Source code
1 : #pragma once
2 :
3 : #include <QFrame>
4 : #include <QList>
5 :
6 : #include "data/Models.h"
7 :
8 : class QHBoxLayout;
9 : class QToolButton;
10 :
11 : // Attachment bar displayed below the mail header.
12 : // Shows clickable chips for each attachment (filename + size).
13 : // Hidden when no attachments are present.
14 : class AttachmentBar : public QFrame {
15 19 : Q_OBJECT
16 :
17 : public:
18 : explicit AttachmentBar(QWidget *parent = nullptr);
19 :
20 : // Set the list of attachments to display.
21 : // Clears any previous content.
22 : void setAttachments(const QList<Attachment> &attachments);
23 6 : const QList<Attachment> &attachments() const { return m_attachments; }
24 :
25 : // Clear the bar and hide it.
26 : void clear();
27 :
28 : signals:
29 : // Emitted when user clicks on an attachment chip.
30 : void downloadRequested(qint64 attachmentId, const QString &filename);
31 :
32 : // T-71.6: Emitted when user clicks a PDF chip — MailView opens it inline
33 : // via PdfViewerWidget. Only emitted for PDFs; non-PDFs still emit
34 : // downloadRequested. A separate download button on the chip keeps the
35 : // save-to-disk path available for PDFs.
36 : void viewInlineRequested(qint64 attachmentId);
37 :
38 : // Emitted when user clicks "Save All".
39 : void downloadAllRequested();
40 :
41 : protected:
42 : void changeEvent(QEvent *event) override;
43 :
44 : private:
45 : // Format bytes into human-readable string: "1.2 KB", "3.4 MB"
46 : static QString formatSize(qint64 bytes);
47 :
48 : void retranslateUi();
49 :
50 : QList<Attachment> m_attachments;
51 : QHBoxLayout *m_layout;
52 : bool m_retranslating = false; // T-76.B3: re-entrancy guard for retranslateUi
53 : };
|