Commit 8de7bd57 authored by Laurent Montel's avatar Laurent Montel 😁

not necessary to create private class

parent 25a6b460
......@@ -29,70 +29,49 @@
using namespace MailTransport;
class MailTransport::SendMailConfigDialog::Private
{
public:
Private(SendMailConfigDialog *qq)
: transport(nullptr)
, configWidget(nullptr)
, q(qq)
, okButton(nullptr)
{
}
Transport *transport;
SendmailConfigWidget *configWidget;
SendMailConfigDialog *q;
QPushButton *okButton;
void okClicked();
void slotTextChanged(const QString &text);
void slotEnabledOkButton(bool);
};
void SendMailConfigDialog::Private::slotEnabledOkButton(bool b)
{
okButton->setEnabled(b);
}
void SendMailConfigDialog::Private::okClicked()
{
configWidget->apply();
transport->save();
}
void SendMailConfigDialog::Private::slotTextChanged(const QString &text)
{
okButton->setEnabled(!text.isEmpty());
}
SendMailConfigDialog::SendMailConfigDialog(Transport *transport, QWidget *parent)
: QDialog(parent)
, d(new Private(this))
, mTransport(transport)
, mConfigWidget(nullptr)
, mOkButton(nullptr)
{
Q_ASSERT(transport);
d->transport = transport;
QVBoxLayout *mainLayout = new QVBoxLayout(this);
d->configWidget = new MailTransport::SendmailConfigWidget(transport, this);
d->configWidget->setObjectName(QStringLiteral("sendmailconfigwidget"));
mainLayout->addWidget(d->configWidget);
mConfigWidget = new MailTransport::SendmailConfigWidget(transport, this);
mConfigWidget->setObjectName(QStringLiteral("sendmailconfigwidget"));
mainLayout->addWidget(mConfigWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
d->okButton = buttonBox->button(QDialogButtonBox::Ok);
d->okButton->setEnabled(false);
d->okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setEnabled(false);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
mainLayout->addWidget(buttonBox);
connect(d->okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
connect(mOkButton, &QAbstractButton::clicked, this, &SendMailConfigDialog::okClicked);
connect(buttonBox, &QDialogButtonBox::accepted, this, &SendMailConfigDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SendMailConfigDialog::reject);
connect(d->configWidget, SIGNAL(enableButtonOk(bool)), this, SLOT(slotEnabledOkButton(bool)));
d->slotEnabledOkButton(!d->configWidget->pathIsEmpty());
connect(mConfigWidget, &SendmailConfigWidget::enableButtonOk, this, &SendMailConfigDialog::slotEnabledOkButton);
slotEnabledOkButton(!mConfigWidget->pathIsEmpty());
}
SendMailConfigDialog::~SendMailConfigDialog()
{
delete d;
}
void SendMailConfigDialog::slotEnabledOkButton(bool b)
{
mOkButton->setEnabled(b);
}
void SendMailConfigDialog::okClicked()
{
mConfigWidget->apply();
mTransport->save();
}
void SendMailConfigDialog::slotTextChanged(const QString &text)
{
mOkButton->setEnabled(!text.isEmpty());
}
#include "moc_sendmailconfigdialog.cpp"
......@@ -21,9 +21,9 @@
#define MAILTRANSPORT_SENDMAILTRANSPORTCONFIGDIALOG_H
#include <QDialog>
namespace MailTransport {
class Transport;
class SendmailConfigWidget;
class SendMailConfigDialog : public QDialog
{
......@@ -33,12 +33,13 @@ public:
virtual ~SendMailConfigDialog();
private:
class Private;
Private *const d;
void okClicked();
void slotTextChanged(const QString &text);
void slotEnabledOkButton(bool);
Q_PRIVATE_SLOT(d, void okClicked())
Q_PRIVATE_SLOT(d, void slotTextChanged(const QString &))
Q_PRIVATE_SLOT(d, void slotEnabledOkButton(bool))
Transport *mTransport;
MailTransport::SendmailConfigWidget *mConfigWidget;
QPushButton *mOkButton;
};
} // namespace MailTransport
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment