2026-06-17 22:44:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QTextBrowser>
|
|
|
|
|
#include <QPushButton>
|
2026-08-17 15:34:49 +02:00
|
|
|
#include <QListWidget>
|
2026-06-17 22:44:27 +02:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
2026-08-23 14:49:58 +02:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QScrollArea>
|
|
|
|
|
#include <QFrame>
|
|
|
|
|
#include <QMenu>
|
2026-06-17 22:44:27 +02:00
|
|
|
#include "core/mailitem.h"
|
|
|
|
|
|
|
|
|
|
class ReaderView : public QWidget {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit ReaderView(QWidget *parent = nullptr);
|
|
|
|
|
~ReaderView() override = default;
|
|
|
|
|
|
|
|
|
|
void setMailItem(const MailItem* item);
|
2026-08-23 14:49:58 +02:00
|
|
|
void setDarkMode(bool dark);
|
2026-06-17 22:44:27 +02:00
|
|
|
|
|
|
|
|
signals:
|
2026-08-23 14:49:58 +02:00
|
|
|
void replyRequested(int mailId);
|
|
|
|
|
void forwardRequested(int mailId);
|
|
|
|
|
void deleteRequested(int mailId);
|
2026-06-18 18:58:27 +02:00
|
|
|
void detachRequested();
|
2026-08-23 14:49:58 +02:00
|
|
|
void openAttachmentRequested(const QString &path);
|
2026-06-18 18:58:27 +02:00
|
|
|
|
2026-08-23 14:49:58 +02:00
|
|
|
private slots:
|
|
|
|
|
void onReplyClicked();
|
|
|
|
|
void onForwardClicked();
|
|
|
|
|
void onDeleteClicked();
|
|
|
|
|
void onDetachClicked();
|
2026-06-17 22:44:27 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setupUI();
|
2026-08-23 14:49:58 +02:00
|
|
|
void setupBodyViewer();
|
|
|
|
|
void setupAttachmentsArea();
|
|
|
|
|
void setupFindBar();
|
|
|
|
|
void applyEmailCss();
|
|
|
|
|
void updateZoom();
|
|
|
|
|
void refreshCurrentMail();
|
|
|
|
|
QString sanitizeHtml(const QString &html);
|
|
|
|
|
QString formatAddress(const QString &raw);
|
|
|
|
|
QString formatDate(const QDateTime &dt);
|
|
|
|
|
QIcon mimeIcon(const QString &mimeType);
|
|
|
|
|
void showAttachmentContextMenu(const QPoint &pos, const QString &path, const QString &name);
|
2026-06-17 22:44:27 +02:00
|
|
|
|
2026-08-23 14:49:58 +02:00
|
|
|
// Header
|
|
|
|
|
QWidget *m_headerWidget;
|
|
|
|
|
QLabel *m_avatarLabel;
|
2026-06-17 22:44:27 +02:00
|
|
|
QLabel *m_subjectLabel;
|
|
|
|
|
QLabel *m_fromLabel;
|
|
|
|
|
QLabel *m_dateLabel;
|
2026-08-23 14:49:58 +02:00
|
|
|
QLabel *m_toLabel;
|
|
|
|
|
|
|
|
|
|
// Actions
|
|
|
|
|
QToolButton *m_replyButton;
|
|
|
|
|
QToolButton *m_forwardButton;
|
|
|
|
|
QToolButton *m_deleteButton;
|
|
|
|
|
QToolButton *m_detachButton;
|
|
|
|
|
QToolButton *m_moreButton;
|
|
|
|
|
|
|
|
|
|
// Body
|
|
|
|
|
QScrollArea *m_scrollArea;
|
2026-06-17 22:44:27 +02:00
|
|
|
QTextBrowser *m_bodyViewer;
|
2026-08-23 14:49:58 +02:00
|
|
|
QWidget *m_bodyContainer;
|
|
|
|
|
QVBoxLayout *m_bodyLayout;
|
|
|
|
|
qreal m_zoomFactor = 1.0;
|
|
|
|
|
|
|
|
|
|
// Attachments
|
|
|
|
|
QFrame *m_attachmentsFrame;
|
|
|
|
|
QVBoxLayout *m_attachmentsLayout;
|
|
|
|
|
QLabel *m_attachmentsHeader;
|
2026-08-17 15:34:49 +02:00
|
|
|
QListWidget *m_attachmentList;
|
2026-06-17 22:44:27 +02:00
|
|
|
|
2026-08-23 14:49:58 +02:00
|
|
|
// Find bar
|
|
|
|
|
QFrame *m_findBar;
|
|
|
|
|
QLineEdit *m_findInput;
|
|
|
|
|
QToolButton *m_findPrevButton;
|
|
|
|
|
QToolButton *m_findNextButton;
|
|
|
|
|
QToolButton *m_findCloseButton;
|
|
|
|
|
QLabel *m_findCountLabel;
|
|
|
|
|
|
|
|
|
|
// Toolbar (zoom, etc.)
|
|
|
|
|
QFrame *m_toolbar;
|
|
|
|
|
QToolButton *m_zoomInButton;
|
|
|
|
|
QToolButton *m_zoomOutButton;
|
|
|
|
|
QToolButton *m_zoomResetButton;
|
|
|
|
|
QLabel *m_zoomLabel;
|
|
|
|
|
|
|
|
|
|
int m_currentMailId = -1;
|
|
|
|
|
bool m_darkMode = false;
|
|
|
|
|
QString m_baseCss;
|
|
|
|
|
bool m_allowExternalImages = false;
|
|
|
|
|
QToolButton *m_loadImagesButton = nullptr;
|
2026-06-17 22:44:27 +02:00
|
|
|
};
|