- CompactMailDelegate: card-based view for narrow panels (<420px) * Avatar with hash-based color, sender + date (relative format) * Subject line with attachment icon * Action buttons: flag, delete, category, more (context menu) * Unread highlight with light blue background + bold sender - MailListView: automatic switch between tree/table (wide) and list/cards (narrow) * QStackedWidget with QTreeView + QListView sharing same proxy model * resizeEvent threshold at 420px * Signals forwarded to MainMainWindow for actions - FolderTreeDelegate: custom paint for folder tree * Unread count badge (blue pill) right-aligned on folder nodes * Account nodes bold, folder nodes normal weight * Proper indentation per depth level - MailItemDao::countUnreadByFolderId() for real-time unread counts - MainMainWindow handlers for compact actions (flag, delete, category, more menu)
155 lines
4.9 KiB
C++
155 lines
4.9 KiB
C++
#pragma once
|
|
|
|
#include <QMainWindow>
|
|
#include <QStackedWidget>
|
|
#include <QListWidget>
|
|
#include <QSplitter>
|
|
#include <QTreeView>
|
|
#include <QStatusBar>
|
|
#include <QProgressBar>
|
|
#include <QToolBar>
|
|
#include <QAction>
|
|
#include <QToolButton>
|
|
#include <QLabel>
|
|
#include <QHBoxLayout>
|
|
#include <QMouseEvent>
|
|
#include <QWindowStateChangeEvent>
|
|
|
|
#include "ui/readerview.h"
|
|
#include "ui/maillistview.h"
|
|
#include "ui/composeview.h"
|
|
#include "ui/settingsview.h"
|
|
#include "ui/contactsview.h"
|
|
#include "ui/calendarview.h"
|
|
#include "ui/models/FolderListModel.h"
|
|
#include "ui/models/EmailListModel.h"
|
|
#include "ui/categorytreewidget.h"
|
|
#include "ui/templatesmanagerdialog.h"
|
|
#include "services/accountservice.h"
|
|
#include "services/mailservice.h"
|
|
|
|
class MainMainWindow : public QMainWindow {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainMainWindow(QWidget *parent = nullptr);
|
|
~MainMainWindow() override = default;
|
|
|
|
protected:
|
|
// Frameless window handling
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
|
|
void changeEvent(QEvent *event) override;
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
private slots:
|
|
void onNavChanged(int index);
|
|
void onFolderSelected(const QModelIndex &index);
|
|
void onEmailSelected(int mailId);
|
|
void onComposeRequested();
|
|
void onReaderReplyRequested(int mailId);
|
|
void onReaderForwardRequested(int mailId);
|
|
void onReaderDeleteRequested(int mailId);
|
|
void onNewMessage();
|
|
void openMailInIndependentWindow(int mailId);
|
|
void onAddAccountRequested();
|
|
void onAccountEditRequested(int accountId);
|
|
void onAccountDeleteRequested(int accountId);
|
|
void onProgressChanged(int percent);
|
|
void onStatusMessage(const QString &msg);
|
|
void onSyncRequested();
|
|
void onSettingsRequested();
|
|
void updateMaximizeButtonIcon();
|
|
void onCategorySelected(const Category& cat);
|
|
void onCategoryDoubleClicked(const Category& cat);
|
|
void onAssignCategoryRequested(qint64 mailId, qint64 categoryId);
|
|
void onCategoryCreated(const Category& cat);
|
|
void onCategoryEdited(const Category& cat);
|
|
void onCategoryDeleted(qint64 categoryId);
|
|
void onRulesChanged();
|
|
void onRunRulesOnFolder();
|
|
void onRunRulesOnSelected();
|
|
void showRulesManager();
|
|
void showTemplatesManager();
|
|
|
|
// MailListView action handlers (from compact delegate)
|
|
void onFlagRequested(int mailId);
|
|
void onDeleteRequested(int mailId);
|
|
void onCategoryRequested(int mailId);
|
|
void onMoreRequested(int mailId, const QPoint &globalPos);
|
|
|
|
// Slots for embedded compose view
|
|
void onEmbeddedSendRequested(const QString &to, const QString &cc, const QString &bcc,
|
|
const QString &subject, const QString &body,
|
|
const QDateTime &scheduleTime,
|
|
const QString &fromAddress,
|
|
const QStringList &attachmentPaths);
|
|
void onEmbeddedDiscardRequested();
|
|
void onEmbeddedDetachRequested(QWidget *widget);
|
|
private:
|
|
void setupUI();
|
|
void setupSidebar();
|
|
void setupMailPage();
|
|
void connectModels();
|
|
void createTitleBar();
|
|
void switchToPage(int pageIndex);
|
|
QWidget *createTitleButton(const QString &iconName, const QString &tooltip, std::function<void()> slot);
|
|
QWidget *createWindowControlButton(const QString &iconName, const QString &tooltip, std::function<void()> slot);
|
|
void updateCategoryTreeForAccount(qint64 accountId);
|
|
void assignCategoryToSelectedMails(qint64 categoryId);
|
|
|
|
// Navigation
|
|
QListWidget *m_sidebar;
|
|
QStackedWidget *m_stack;
|
|
|
|
enum Page {
|
|
PageMail = 0,
|
|
PageCompose,
|
|
PageSettings,
|
|
PageContacts,
|
|
PageCalendar
|
|
};
|
|
|
|
// Mail page widgets
|
|
QWidget *m_mailPage;
|
|
QSplitter *m_folderSplitter;
|
|
QTreeView *m_folderTree;
|
|
CategoryTreeWidget *m_categoryTree;
|
|
MailListView *m_mailListView;
|
|
ReaderView *m_emailViewer;
|
|
QStackedWidget *m_viewerStack;
|
|
QWidget *m_placeholderWidget;
|
|
ComposeView *m_embeddedComposeView;
|
|
|
|
// Other pages
|
|
ComposeView *m_composeView;
|
|
SettingsView *m_settingsView;
|
|
ContactsView *m_contactsView;
|
|
CalendarView *m_calendarView;
|
|
|
|
// Services & Models
|
|
FolderListModel *m_folderModel;
|
|
EmailListModel *m_emailModel;
|
|
AccountService *m_accountService = nullptr;
|
|
MailService *m_mailService = nullptr;
|
|
|
|
// Frameless title bar
|
|
QWidget *m_titleBar;
|
|
QToolButton *m_maximizeButton;
|
|
QToolButton *m_closeButton;
|
|
QPoint m_dragPos;
|
|
bool m_dragging = false;
|
|
Qt::WindowStates m_lastWindowState;
|
|
|
|
// Resize handling (item 3)
|
|
QPoint m_resizeStartPos;
|
|
QRect m_resizeStartGeom;
|
|
bool m_resizing = false;
|
|
Qt::Edges m_resizeEdges = Qt::Edges();
|
|
|
|
int m_currentFolderId;
|
|
int m_currentMailId;
|
|
};
|