File indexing completed on 2025-01-05 04:49:34
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "sendmailconfigdialog.h" 0008 #include "sendmailconfigwidget.h" 0009 0010 #include <MailTransport/Transport> 0011 0012 #include <QDialogButtonBox> 0013 #include <QPushButton> 0014 #include <QVBoxLayout> 0015 0016 using namespace MailTransport; 0017 0018 SendMailConfigDialog::SendMailConfigDialog(MailTransport::Transport *transport, QWidget *parent) 0019 : QDialog(parent) 0020 , mTransport(transport) 0021 , mConfigWidget(new MailTransport::SendmailConfigWidget(transport, this)) 0022 { 0023 Q_ASSERT(transport); 0024 auto mainLayout = new QVBoxLayout(this); 0025 mConfigWidget->setObjectName(QLatin1StringView("sendmailconfigwidget")); 0026 mainLayout->addWidget(mConfigWidget); 0027 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0028 buttonBox->setObjectName(QLatin1StringView("buttonbox")); 0029 mOkButton = buttonBox->button(QDialogButtonBox::Ok); 0030 mOkButton->setEnabled(false); 0031 mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return); 0032 mainLayout->addWidget(buttonBox); 0033 0034 connect(mOkButton, &QAbstractButton::clicked, this, &SendMailConfigDialog::okClicked); 0035 connect(buttonBox, &QDialogButtonBox::accepted, this, &SendMailConfigDialog::accept); 0036 connect(buttonBox, &QDialogButtonBox::rejected, this, &SendMailConfigDialog::reject); 0037 connect(mConfigWidget, &MailTransport::SendmailConfigWidget::enableButtonOk, this, &SendMailConfigDialog::slotEnabledOkButton); 0038 slotEnabledOkButton(!mConfigWidget->pathIsEmpty()); 0039 } 0040 0041 SendMailConfigDialog::~SendMailConfigDialog() = default; 0042 0043 void SendMailConfigDialog::slotEnabledOkButton(bool b) 0044 { 0045 mOkButton->setEnabled(b); 0046 } 0047 0048 void SendMailConfigDialog::okClicked() 0049 { 0050 mConfigWidget->apply(); 0051 mTransport->save(); 0052 } 0053 0054 void SendMailConfigDialog::slotTextChanged(const QString &text) 0055 { 0056 mOkButton->setEnabled(!text.isEmpty()); 0057 } 0058 0059 #include "moc_sendmailconfigdialog.cpp"