Actualizaciones varias: mejoras en cuenta, sincronización, UI
This commit is contained in:
+91
-21
@@ -19,9 +19,20 @@ MainMainWindow::MainMainWindow(QWidget *parent)
|
||||
connectModels();
|
||||
setWindowTitle("Wino Mail DTK");
|
||||
resize(1280, 820);
|
||||
// Setup progress bar in status bar
|
||||
m_progressBar = new QProgressBar(this);
|
||||
m_progressBar->setMaximumWidth(120);
|
||||
m_progressBar->setVisible(false);
|
||||
statusBar()->addPermanentWidget(m_progressBar);
|
||||
// Connect mail service progress/status signals
|
||||
connect(m_mailService, &MailService::progressChanged, this, &MainMainWindow::onProgressChanged);
|
||||
connect(m_mailService, &MailService::statusMessage, this, &MainMainWindow::onStatusMessage);
|
||||
// Provide account service to settings view
|
||||
m_settingsView->setAccountService(m_accountService);
|
||||
}
|
||||
|
||||
void MainMainWindow::setupUI() {
|
||||
void MainMainWindow::setupUI()
|
||||
{
|
||||
// === Global stylesheet ===
|
||||
this->setStyleSheet(
|
||||
"QMainWindow { background-color: #f5f5f7; }"
|
||||
@@ -58,7 +69,7 @@ void MainMainWindow::setupUI() {
|
||||
|
||||
// Page 1: Compose
|
||||
m_composeView = new ComposeView();
|
||||
connect(m_composeView, &ComposeView::sendRequested, [this](const QString &to, const QString &cc, const QString &bcc, const QString &subject, const QString &body, const QDateTime &scheduleTime) {
|
||||
connect(m_composeView, &ComposeView::sendRequested, [this](const QString &to, const QString &cc, const QString &bcc, const QString &subject, const QString &body, const QDateTime &scheduleTime, const QString &fromAddr) {
|
||||
QString msg;
|
||||
if (scheduleTime.isValid()) {
|
||||
msg = QString("Message scheduled for: %1").arg(scheduleTime.toString("dd/MM/yyyy hh:mm AP"));
|
||||
@@ -83,16 +94,16 @@ void MainMainWindow::setupUI() {
|
||||
// Create standalone window
|
||||
QMainWindow *detachedWin = new QMainWindow();
|
||||
detachedWin->setWindowTitle("Compose - Wino Mail");
|
||||
|
||||
|
||||
// Assign central widget and ensure it's visible and sized
|
||||
detachedWin->setCentralWidget(composeView);
|
||||
composeView->setMinimumSize(800, 600);
|
||||
composeView->update();
|
||||
|
||||
|
||||
detachedWin->resize(800, 600);
|
||||
detachedWin->setAttribute(Qt::WA_DeleteOnClose);
|
||||
detachedWin->show();
|
||||
|
||||
|
||||
statusBar()->showMessage("Compose view detached to separate window", 3000);
|
||||
});
|
||||
m_stack->addWidget(m_composeView);
|
||||
@@ -103,6 +114,8 @@ void MainMainWindow::setupUI() {
|
||||
AccountSetupDialog dlg(m_accountService, this);
|
||||
dlg.exec();
|
||||
});
|
||||
connect(m_settingsView, &SettingsView::accountEditRequested, this, &MainMainWindow::onAccountEditRequested);
|
||||
connect(m_settingsView, &SettingsView::accountDeleteRequested, this, &MainMainWindow::onAccountDeleteRequested);
|
||||
connect(m_settingsView, &SettingsView::themeChanged, [this](const QString &theme) {
|
||||
statusBar()->showMessage(QString("Theme changed to: %1 (restart may be required)").arg(theme), 3000);
|
||||
});
|
||||
@@ -123,7 +136,8 @@ void MainMainWindow::setupUI() {
|
||||
switchToPage(PageMail);
|
||||
}
|
||||
|
||||
void MainMainWindow::setupSidebar() {
|
||||
void MainMainWindow::setupSidebar()
|
||||
{
|
||||
m_sidebar = new QListWidget();
|
||||
m_sidebar->setFixedWidth(64);
|
||||
m_sidebar->setIconSize(QSize(24, 24));
|
||||
@@ -146,7 +160,8 @@ void MainMainWindow::setupSidebar() {
|
||||
connect(m_sidebar, &QListWidget::currentRowChanged, this, &MainMainWindow::onNavChanged);
|
||||
}
|
||||
|
||||
void MainMainWindow::setupMailPage() {
|
||||
void MainMainWindow::setupMailPage()
|
||||
{
|
||||
m_mailPage = new QWidget();
|
||||
QHBoxLayout *mailLayout = new QHBoxLayout(m_mailPage);
|
||||
mailLayout->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -191,9 +206,11 @@ void MainMainWindow::setupMailPage() {
|
||||
mailLayout->addWidget(m_folderSplitter);
|
||||
}
|
||||
|
||||
void MainMainWindow::connectModels() {
|
||||
void MainMainWindow::connectModels()
|
||||
{
|
||||
m_accountService = new AccountService(this);
|
||||
m_mailService = new MailService(this);
|
||||
m_mailService = new MailService(m_accountService, this);
|
||||
m_composeView->setAccountService(m_accountService);
|
||||
|
||||
m_folderModel = new FolderListModel(m_accountService, this);
|
||||
m_emailModel = new EmailListModel(this);
|
||||
@@ -206,11 +223,13 @@ void MainMainWindow::connectModels() {
|
||||
connect(m_folderTree, &QTreeView::clicked, this, &MainMainWindow::onFolderSelected);
|
||||
}
|
||||
|
||||
void MainMainWindow::onNavChanged(int index) {
|
||||
void MainMainWindow::onNavChanged(int index)
|
||||
{
|
||||
switchToPage(static_cast<Page>(index));
|
||||
}
|
||||
|
||||
void MainMainWindow::switchToPage(int pageIndex) {
|
||||
void MainMainWindow::switchToPage(int pageIndex)
|
||||
{
|
||||
m_stack->setCurrentIndex(pageIndex);
|
||||
m_sidebar->blockSignals(true);
|
||||
m_sidebar->setCurrentRow(pageIndex);
|
||||
@@ -219,7 +238,8 @@ void MainMainWindow::switchToPage(int pageIndex) {
|
||||
// Show/hide toolbar actions per page
|
||||
}
|
||||
|
||||
void MainMainWindow::onFolderSelected(const QModelIndex &index) {
|
||||
void MainMainWindow::onFolderSelected(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
|
||||
int itemType = index.data(FolderListModel::ItemTypeRole).toInt();
|
||||
@@ -240,7 +260,8 @@ void MainMainWindow::onFolderSelected(const QModelIndex &index) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainMainWindow::onEmailSelected(int mailId) {
|
||||
void MainMainWindow::onEmailSelected(int mailId)
|
||||
{
|
||||
m_currentMailId = mailId;
|
||||
std::optional<MailItem> item = MailItemDao::findById(mailId);
|
||||
if (!item.has_value()) {
|
||||
@@ -256,11 +277,13 @@ void MainMainWindow::onEmailSelected(int mailId) {
|
||||
m_emailViewer->setMailItem(&mail);
|
||||
}
|
||||
|
||||
void MainMainWindow::onComposeRequested() {
|
||||
void MainMainWindow::onComposeRequested()
|
||||
{
|
||||
switchToPage(PageCompose);
|
||||
}
|
||||
|
||||
void MainMainWindow::onReaderReplyRequested(const MailItem *item) {
|
||||
void MainMainWindow::onReaderReplyRequested(const MailItem *item)
|
||||
{
|
||||
if (item) {
|
||||
m_composeView->setTo(item->sender());
|
||||
m_composeView->setSubject("Re: " + item->subject());
|
||||
@@ -268,29 +291,32 @@ void MainMainWindow::onReaderReplyRequested(const MailItem *item) {
|
||||
switchToPage(PageCompose);
|
||||
}
|
||||
|
||||
void MainMainWindow::onNewMessage() {
|
||||
void MainMainWindow::onNewMessage()
|
||||
{
|
||||
switchToPage(PageCompose);
|
||||
}
|
||||
|
||||
void MainMainWindow::openMailInIndependentWindow(int mailId) {
|
||||
void MainMainWindow::openMailInIndependentWindow(int mailId)
|
||||
{
|
||||
std::optional<MailItem> item = MailItemDao::findById(mailId);
|
||||
if (!item.has_value()) return;
|
||||
|
||||
QMainWindow *detachedWin = new QMainWindow();
|
||||
detachedWin->setWindowTitle(QString("Mail - %1").arg(item->subject()));
|
||||
|
||||
|
||||
ReaderView *detachedReader = new ReaderView();
|
||||
detachedReader->setMailItem(&item.value());
|
||||
|
||||
|
||||
detachedWin->setCentralWidget(detachedReader);
|
||||
detachedWin->resize(800, 600);
|
||||
detachedWin->setAttribute(Qt::WA_DeleteOnClose);
|
||||
detachedWin->show();
|
||||
|
||||
|
||||
statusBar()->showMessage("Opened mail in independent window", 3000);
|
||||
}
|
||||
|
||||
void MainMainWindow::createToolBar() {
|
||||
void MainMainWindow::createToolBar()
|
||||
{
|
||||
m_toolBar = addToolBar("Main Toolbar");
|
||||
m_toolBar->setMovable(false);
|
||||
|
||||
@@ -317,4 +343,48 @@ void MainMainWindow::createToolBar() {
|
||||
connect(deleteAction, &QAction::triggered, [this]() {
|
||||
statusBar()->showMessage("Delete would be implemented here", 3000);
|
||||
});
|
||||
}
|
||||
|
||||
void MainMainWindow::onProgressChanged(int percent)
|
||||
{
|
||||
if (percent < 0 || percent > 100) {
|
||||
m_progressBar->setVisible(false);
|
||||
return;
|
||||
}
|
||||
m_progressBar->setValue(percent);
|
||||
m_progressBar->setVisible(true);
|
||||
}
|
||||
|
||||
void MainMainWindow::onStatusMessage(const QString &msg)
|
||||
{
|
||||
// Show temporary message in status bar (timeout 5000 ms)
|
||||
statusBar()->showMessage(msg, 5000);
|
||||
}
|
||||
|
||||
void MainMainWindow::onAddAccountRequested()
|
||||
{
|
||||
AccountSetupDialog *dialog = new AccountSetupDialog(m_accountService, this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setWindowFlag(Qt::Window, true); // make it an independent window
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MainMainWindow::onAccountEditRequested(int accountId)
|
||||
{
|
||||
QMessageBox::information(this, "Debug", QString("Edit account slot called for ID %1").arg(accountId));
|
||||
Account* account = m_accountService->findAccountById(accountId);
|
||||
if (!account) {
|
||||
statusBar()->showMessage(QString("Error: account %1 not found").arg(accountId), 3000);
|
||||
return;
|
||||
}
|
||||
AccountSetupDialog dlg(m_accountService, this);
|
||||
dlg.loadAccountForEditing(*account);
|
||||
dlg.exec();
|
||||
delete account;
|
||||
}
|
||||
|
||||
void MainMainWindow::onAccountDeleteRequested(int accountId)
|
||||
{
|
||||
Q_UNUSED(accountId);
|
||||
statusBar()->showMessage(QString("Delete account %1 requested").arg(accountId), 3000);
|
||||
}
|
||||
Reference in New Issue
Block a user