10#include "mailwidget.h"
11#include "editor/generalinfoeditor/mail/mailtypecombobox.h"
12#include "editor/widgets/preferredlineeditwidget.h"
13#include <KLocalizedString>
18MailWidget::MailWidget(
QWidget *parent)
20 , mMailEdit(new PreferredLineEditWidget(this))
21 , mMailType(new
Akonadi::MailTypeCombobox(this))
26 layout->setSpacing(0);
27 layout->setContentsMargins({});
29 mMailEdit->setTrapReturnKey(
true);
30 mMailEdit->setPlaceholderText(
i18nc(
"@info:placeholder",
"Add an Email Account"));
32 layout->addWidget(mMailEdit);
33 connect(mMailEdit, &PreferredLineEditWidget::preferredChanged,
this, &MailWidget::slotPreferredChanged);
36 layout->addWidget(mMailType);
40 mAddButton->setToolTip(
i18nc(
"@info:tooltip",
"Add an Email"));
42 layout->addWidget(mAddButton);
46 mRemoveButton->setToolTip(
i18nc(
"@info:tooltip",
"Remove Email"));
48 layout->addWidget(mRemoveButton);
51MailWidget::~MailWidget() =
default;
53void MailWidget::slotPreferredChanged()
55 Q_EMIT preferredChanged(
this);
58void MailWidget::clearWidget()
61 mEmail = KContacts::Email();
62 mMailType->setCurrentIndex(0);
65void MailWidget::updateAddRemoveButton(
bool addButtonEnabled)
67 mAddButton->setEnabled(addButtonEnabled);
70void MailWidget::setMail(
const KContacts::Email &email)
73 mMailEdit->setText(email.mail());
74 mMailType->setCurrentIndex(mMailType->findData((
int)email.type()));
75 setPreferred(email.isPreferred());
78KContacts::Email MailWidget::email()
80 mEmail.setEmail(mMailEdit->text());
82 mEmail.setPreferred(mMailEdit->preferred());
86void MailWidget::setPreferred(
bool b)
88 mMailEdit->setPreferred(b);
91void MailWidget::setReadOnly(
bool readOnly)
93 mMailEdit->setReadOnly(readOnly);
94 mMailType->setEnabled(!readOnly);
95 mAddButton->setEnabled(!readOnly);
96 mRemoveButton->setEnabled(!readOnly);
99void MailWidget::slotAddMail()
104void MailWidget::slotRemoveMail()
106 Q_EMIT removeWidget(
this);
109#include "moc_mailwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
A widget for editing the display name of a contact.
QIcon fromTheme(const QString &name)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)