Commit 5cafbed1 authored by Laurent Montel's avatar Laurent Montel 😁

not necessary to create private class here as it's on plugin

parent 76c96e7d
...@@ -31,61 +31,40 @@ ...@@ -31,61 +31,40 @@
using namespace MailTransport; using namespace MailTransport;
class MailTransport::SmtpConfigDialog::Private
{
public:
Private(SmtpConfigDialog *qq)
: transport(nullptr)
, configWidget(nullptr)
, q(qq)
, okButton(nullptr)
{
}
Transport *transport;
SMTPConfigWidget *configWidget;
SmtpConfigDialog *q;
QPushButton *okButton;
void okClicked();
void slotTextChanged(const QString &text);
};
void SmtpConfigDialog::Private::okClicked()
{
configWidget->apply();
transport->save();
}
void SmtpConfigDialog::Private::slotTextChanged(const QString &text)
{
okButton->setEnabled(!text.isEmpty());
}
SmtpConfigDialog::SmtpConfigDialog(Transport *transport, QWidget *parent) SmtpConfigDialog::SmtpConfigDialog(Transport *transport, QWidget *parent)
: QDialog(parent) : QDialog(parent)
, d(new Private(this))
{ {
Q_ASSERT(transport); Q_ASSERT(transport);
d->transport = transport; mTransport = transport;
QVBoxLayout *mainLayout = new QVBoxLayout(this); QVBoxLayout *mainLayout = new QVBoxLayout(this);
d->configWidget = new SMTPConfigWidget(transport, this); mConfigWidget = new SMTPConfigWidget(transport, this);
d->configWidget->setObjectName(QStringLiteral("smtpconfigwidget")); mConfigWidget->setObjectName(QStringLiteral("smtpconfigwidget"));
mainLayout->addWidget(d->configWidget); mainLayout->addWidget(mConfigWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttons")); buttonBox->setObjectName(QStringLiteral("buttons"));
d->okButton = buttonBox->button(QDialogButtonBox::Ok); mOkButton = buttonBox->button(QDialogButtonBox::Ok);
d->okButton->setShortcut(Qt::CTRL | Qt::Key_Return); mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
mainLayout->addWidget(buttonBox); mainLayout->addWidget(buttonBox);
connect(d->okButton, SIGNAL(clicked()), this, SLOT(okClicked())); connect(mOkButton, &QAbstractButton::clicked, this, &SmtpConfigDialog::okClicked);
connect(buttonBox, &QDialogButtonBox::accepted, this, &SmtpConfigDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &SmtpConfigDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SmtpConfigDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &SmtpConfigDialog::reject);
} }
SmtpConfigDialog::~SmtpConfigDialog() SmtpConfigDialog::~SmtpConfigDialog()
{ {
delete d; }
void SmtpConfigDialog::okClicked()
{
mConfigWidget->apply();
mTransport->save();
}
void SmtpConfigDialog::slotTextChanged(const QString &text)
{
mOkButton->setEnabled(!text.isEmpty());
} }
#include "moc_smtpconfigdialog.cpp" #include "moc_smtpconfigdialog.cpp"
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
namespace MailTransport { namespace MailTransport {
class Transport; class Transport;
class SMTPConfigWidget;
class SmtpConfigDialog : public QDialog class SmtpConfigDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
...@@ -33,11 +33,12 @@ public: ...@@ -33,11 +33,12 @@ public:
virtual ~SmtpConfigDialog(); virtual ~SmtpConfigDialog();
private: private:
class Private; void okClicked();
Private *const d; void slotTextChanged(const QString &text);
Q_PRIVATE_SLOT(d, void okClicked()) Transport *mTransport;
Q_PRIVATE_SLOT(d, void slotTextChanged(const QString &)) SMTPConfigWidget *mConfigWidget;
QPushButton *mOkButton;
}; };
} // namespace MailTransport } // 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