2026-06-17 22:44:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QStackedWidget>
|
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QSplitter>
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
#include <QStatusBar>
|
2026-07-05 10:45:44 +02:00
|
|
|
#include <QProgressBar>
|
2026-06-17 22:44:27 +02:00
|
|
|
#include <QToolBar>
|
|
|
|
|
#include <QAction>
|
2026-08-23 14:49:58 +02:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
#include <QWindowStateChangeEvent>
|
2026-06-17 22:44:27 +02:00
|
|
|
|
|
|
|
|
#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"
|
2026-08-23 14:49:58 +02:00
|
|
|
#include "ui/categorytreewidget.h"
|
|
|
|
|
#include "ui/templatesmanagerdialog.h"
|
2026-06-17 22:44:27 +02:00
|
|
|
#include "services/accountservice.h"
|
|
|
|
|
#include "services/mailservice.h"
|
|
|
|
|
|
|
|
|
|
class MainMainWindow : public QMainWindow {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit MainMainWindow(QWidget *parent = nullptr);
|
|
|
|
|
~MainMainWindow() override = default;
|
|
|
|
|
|
2026-08-23 14:49:58 +02:00
|
|
|
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;
|
2026-08-23 16:59:17 +02:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2026-08-23 14:49:58 +02:00
|
|
|
|
2026-06-17 22:44:27 +02:00
|
|
|
private slots:
|
|
|
|
|
void onNavChanged(int index);
|
|
|
|
|
void onFolderSelected(const QModelIndex &index);
|
|
|
|
|
void onEmailSelected(int mailId);
|
|
|
|
|
void onComposeRequested();
|
2026-08-23 14:49:58 +02:00
|
|
|
void onReaderReplyRequested(int mailId);
|
|
|
|
|
void onReaderForwardRequested(int mailId);
|
|
|
|
|
void onReaderDeleteRequested(int mailId);
|
2026-06-17 22:44:27 +02:00
|
|
|
void onNewMessage();
|
2026-06-18 18:58:27 +02:00
|
|
|
void openMailInIndependentWindow(int mailId);
|
2026-07-05 10:45:44 +02:00
|
|
|
void onAddAccountRequested();
|
|
|
|
|
void onAccountEditRequested(int accountId);
|
|
|
|
|
void onAccountDeleteRequested(int accountId);
|
|
|
|
|
void onProgressChanged(int percent);
|
|
|
|
|
void onStatusMessage(const QString &msg);
|
2026-08-23 14:49:58 +02:00
|
|
|
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();
|
2026-06-17 22:44:27 +02:00
|
|
|
|
2026-08-24 23:25:13 +02:00
|
|
|
// 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);
|
|
|
|
|
|
2026-08-17 15:34:49 +02:00
|
|
|
// 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);
|
2026-06-17 22:44:27 +02:00
|
|
|
private:
|
|
|
|
|
void setupUI();
|
|
|
|
|
void setupSidebar();
|
|
|
|
|
void setupMailPage();
|
|
|
|
|
void connectModels();
|
2026-08-23 14:49:58 +02:00
|
|
|
void createTitleBar();
|
2026-06-17 22:44:27 +02:00
|
|
|
void switchToPage(int pageIndex);
|
2026-08-23 14:49:58 +02:00
|
|
|
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);
|
2026-06-17 22:44:27 +02:00
|
|
|
|
|
|
|
|
// 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;
|
2026-08-23 14:49:58 +02:00
|
|
|
CategoryTreeWidget *m_categoryTree;
|
2026-06-17 22:44:27 +02:00
|
|
|
MailListView *m_mailListView;
|
|
|
|
|
ReaderView *m_emailViewer;
|
2026-08-17 15:34:49 +02:00
|
|
|
QStackedWidget *m_viewerStack;
|
|
|
|
|
QWidget *m_placeholderWidget;
|
|
|
|
|
ComposeView *m_embeddedComposeView;
|
2026-06-17 22:44:27 +02:00
|
|
|
|
|
|
|
|
// Other pages
|
|
|
|
|
ComposeView *m_composeView;
|
|
|
|
|
SettingsView *m_settingsView;
|
|
|
|
|
ContactsView *m_contactsView;
|
|
|
|
|
CalendarView *m_calendarView;
|
|
|
|
|
|
|
|
|
|
// Services & Models
|
|
|
|
|
FolderListModel *m_folderModel;
|
|
|
|
|
EmailListModel *m_emailModel;
|
2026-08-17 15:34:49 +02:00
|
|
|
AccountService *m_accountService = nullptr;
|
|
|
|
|
MailService *m_mailService = nullptr;
|
2026-06-17 22:44:27 +02:00
|
|
|
|
2026-08-23 14:49:58 +02:00
|
|
|
// 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();
|
|
|
|
|
|
2026-06-17 22:44:27 +02:00
|
|
|
int m_currentFolderId;
|
2026-06-23 01:34:13 +02:00
|
|
|
int m_currentMailId;
|
2026-08-17 15:34:49 +02:00
|
|
|
};
|