Backup before implementing tag editor for To/Cc/Bcc fields

This commit is contained in:
2026-07-05 15:32:12 +02:00
parent 4569c174f0
commit 933cce39b9
5 changed files with 82 additions and 6 deletions
+65 -1
View File
@@ -2,6 +2,9 @@
#include <QFrame>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QDebug>
#include <QTimer>
#include <QTextList>
#include <QTextTable>
#include <QTextCursor>
@@ -114,6 +117,8 @@ void RichTextEditor::setupToolbar(QVBoxLayout *layout) {
);
connect(m_signatureButton, &QToolButton::clicked, this, &RichTextEditor::signatureClicked);
m_toolbar->addWidget(m_signatureButton);
QAction *editSigAct = m_signatureMenu->addAction(tr("Editar firmas"));
connect(editSigAct, &QAction::triggered, this, &RichTextEditor::signatureEditRequested);
m_toolbar->addSeparator();
@@ -265,6 +270,7 @@ ComposeView::ComposeView(QWidget *parent) : QWidget(parent) {
setupUI();
// Connect the rich text editor's signature signal to our slot
connect(m_bodyEditor, &RichTextEditor::signatureClicked, this, &ComposeView::onSignatureClicked);
connect(m_bodyEditor, &RichTextEditor::signatureEditRequested, this, &ComposeView::onSignatureEditRequested);
}
ComposeView::~ComposeView() {
@@ -527,6 +533,38 @@ void ComposeView::setupUI() {
m_schedulePanel->setVisible(false);
mainLayout->addWidget(m_schedulePanel);
// Attachment section
QHBoxLayout *attachmentLayout = new QHBoxLayout();
QLabel *attachmentLabel = new QLabel(tr("Attachments:"));
attachmentLabel->setFixedWidth(80);
attachmentLabel->setStyleSheet("font-weight: bold; color: #555;");
attachmentLayout->addWidget(attachmentLabel);
m_attachButton = new QToolButton();
m_attachButton->setIcon(QIcon(QStringLiteral(":/icons/attachment.svg")));
m_attachButton->setToolTip(tr("Add attachment"));
m_attachButton->setIconSize(QSize(20,20));
m_attachButton->setStyleSheet("QToolButton { border: none; padding: 5px; } QToolButton:hover { background: #e0e0e0; border-radius: 3px; }");
bool connected = connect(m_attachButton, &QToolButton::clicked, this, &ComposeView::onAddAttachmentClicked);
qDebug() << "Attach button connected:" << connected;
attachmentLayout->addWidget(m_attachButton);
m_attachmentList = new QListWidget();
m_attachmentList->setSelectionMode(QAbstractItemView::SingleSelection);
m_attachmentList->setMaximumHeight(60);
m_attachmentList->setStyleSheet("QListWidget { border: 1px solid #d1d1d6; border-radius: 4px; }");
attachmentLayout->addWidget(m_attachmentList, 1);
m_removeAttachmentButton = new QToolButton();
m_removeAttachmentButton->setIcon(QIcon(QStringLiteral(":/icons/trash.svg")));
m_removeAttachmentButton->setToolTip(tr("Remove selected attachment"));
m_removeAttachmentButton->setIconSize(QSize(20,20));
m_removeAttachmentButton->setStyleSheet("QToolButton { border: none; padding: 5px; } QToolButton:hover { background: #e0e0e0; border-radius: 3px; }");
connect(m_removeAttachmentButton, &QToolButton::clicked, this, &ComposeView::onRemoveAttachmentClicked);
attachmentLayout->addWidget(m_removeAttachmentButton);
mainLayout->addLayout(attachmentLayout);
// Action buttons row
QHBoxLayout *actionsLayout = new QHBoxLayout();
@@ -557,7 +595,7 @@ void ComposeView::setupUI() {
m_sendSplit->setStyleSheet(
"QToolButton { background-color: #1976D2; color: white; border: none; border-radius: 4px; padding: 8px 24px; font-weight: bold; }"
"QToolButton:hover { background-color: #1565C0; }"
"QToolButton::menu-button { border-left: 1px solid rgba(255,255,255,0.3); padding-left: 8px; padding-right: 8px; }"
"QToolButton::menu-button { border-left: 1px solid rgba(255,255,255,0.3); padding-left: 8px; padding-right: 8px; width: 40px;}"
"QToolButton::menu-button:hover { background-color: #1565C0; border-top-right-radius: 4px; border-bottom-right-radius: 4px; }"
);
connect(m_sendSplit, &QToolButton::clicked, this, &ComposeView::onSendClicked);
@@ -629,4 +667,30 @@ void ComposeView::startNewEmail(const QString &initialRecipient) {
m_toField->setText(initialRecipient);
m_toField->setFocus();
}
void ComposeView::onAddAttachmentClicked()
{
qDebug() << "Attach button clicked";
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Attachments"), QString(), tr("All Files (*)"));
if (files.isEmpty())
return;
for (const QString &file : files) {
m_attachmentFiles.append(file);
QListWidgetItem *item = new QListWidgetItem(QFileInfo(file).fileName(), m_attachmentList);
item->setToolTip(file);
}
QMessageBox::information(this, tr("Attachments"), tr("Attached %1 file(s).").arg(files.count()));
}
void ComposeView::onRemoveAttachmentClicked()
{
QListWidgetItem *item = m_attachmentList->currentItem();
if (!item)
return;
int row = m_attachmentList->row(item);
m_attachmentList->takeItem(row);
m_attachmentFiles.removeAt(row);
delete item;
}
#include "composeview.moc"