File indexing completed on 2025-01-19 04:46:45

0001 /*
0002    SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "mailmergedialog.h"
0008 #include "widgets/mailmergewidget.h"
0009 
0010 #include <KLocalizedString>
0011 #include <QDialogButtonBox>
0012 #include <QPushButton>
0013 #include <QVBoxLayout>
0014 
0015 using namespace MailMerge;
0016 MailMergeDialog::MailMergeDialog(QWidget *parent)
0017     : QDialog(parent)
0018     , mMailMergeWidget(new MailMergeWidget(this))
0019     , mPreview(new QPushButton(i18n("Preview"), this))
0020 {
0021     auto mainLayout = new QVBoxLayout(this);
0022     setWindowTitle(i18nc("@title:window", "Mail Merge"));
0023     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
0024     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0025 
0026     mMailMergeWidget->setObjectName(QLatin1StringView("mailmergewidget"));
0027     mainLayout->addWidget(mMailMergeWidget);
0028 
0029     buttonBox->setObjectName(QLatin1StringView("buttonbox"));
0030     okButton->setDefault(true);
0031     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0032     connect(buttonBox, &QDialogButtonBox::accepted, this, &MailMergeDialog::accept);
0033     connect(buttonBox, &QDialogButtonBox::rejected, this, &MailMergeDialog::reject);
0034     mainLayout->addWidget(buttonBox);
0035 
0036     buttonBox->addButton(mPreview, QDialogButtonBox::ActionRole);
0037     connect(mPreview, &QPushButton::clicked, this, &MailMergeDialog::slotPreview);
0038     mainLayout->addStretch();
0039 }
0040 
0041 MailMergeDialog::~MailMergeDialog() = default;
0042 
0043 void MailMergeDialog::slotPreview()
0044 {
0045     // TODO show generated email
0046 }
0047 
0048 #include "moc_mailmergedialog.cpp"