MailTransport

smtpconfigdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "smtpconfigdialog.h"
8using namespace Qt::Literals::StringLiterals;
9
10#include "smtpconfigwidget.h"
11#include "transport.h"
12#include "transportmanager.h"
13
14#include <QDialogButtonBox>
15#include <QPushButton>
16#include <QStyle>
17#include <QVBoxLayout>
18
19using namespace MailTransport;
20
21SmtpConfigDialog::SmtpConfigDialog(Transport *transport, QWidget *parent)
22 : QDialog(parent)
23{
24 Q_ASSERT(transport);
25 mTransport = transport;
26 auto mainLayout = new QVBoxLayout(this);
27 mainLayout->setContentsMargins({});
28 mConfigWidget = new SMTPConfigWidget(transport, this);
29 mConfigWidget->setObjectName("smtpconfigwidget"_L1);
30 mainLayout->addWidget(mConfigWidget);
32 buttonBox->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
33 style()->pixelMetric(QStyle::PM_LayoutTopMargin),
34 style()->pixelMetric(QStyle::PM_LayoutRightMargin),
35 style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
36 buttonBox->setObjectName("buttons"_L1);
37 mOkButton = buttonBox->button(QDialogButtonBox::Ok);
38 mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
39 mainLayout->addWidget(buttonBox);
40
41 connect(mOkButton, &QAbstractButton::clicked, this, &SmtpConfigDialog::okClicked);
42 connect(buttonBox, &QDialogButtonBox::accepted, this, &SmtpConfigDialog::accept);
43 connect(buttonBox, &QDialogButtonBox::rejected, this, &SmtpConfigDialog::reject);
44}
45
46SmtpConfigDialog::~SmtpConfigDialog() = default;
47
48void SmtpConfigDialog::okClicked()
49{
50 mConfigWidget->apply();
51 mTransport->save();
52}
53
54void SmtpConfigDialog::slotTextChanged(const QString &text)
55{
56 mOkButton->setEnabled(!text.isEmpty());
57}
58
59#include "moc_smtpconfigdialog.cpp"
Represents the settings of a specific mail transport.
Definition transport.h:33
void clicked(bool checked)
bool isEmpty() const const
PM_LayoutLeftMargin
Key_Return
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.