File indexing completed on 2024-12-22 04:45:39

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "administratorinviteuserswidget.h"
0008 #include <KLocalizedString>
0009 #include <QHBoxLayout>
0010 #include <QLabel>
0011 #include <QLineEdit>
0012 
0013 AdministratorInviteUsersWidget::AdministratorInviteUsersWidget(QWidget *parent)
0014     : QWidget{parent}
0015     , mListEmails(new QLineEdit(this))
0016 {
0017     auto mainLayout = new QHBoxLayout(this);
0018     mainLayout->setContentsMargins({});
0019     mainLayout->setObjectName(QStringLiteral("formLayout"));
0020 
0021     auto label = new QLabel(i18n("Emails:"), this);
0022     label->setObjectName(QStringLiteral("label"));
0023 
0024     mListEmails->setObjectName(QStringLiteral("mListEmails"));
0025     mListEmails->setPlaceholderText(i18n("Use ',' for separate emails"));
0026 
0027     mainLayout->addWidget(label);
0028     mainLayout->addWidget(mListEmails);
0029     connect(mListEmails, &QLineEdit::textChanged, this, [this](const QString &text) {
0030         Q_EMIT updateButtonOk(!text.trimmed().isEmpty());
0031     });
0032 }
0033 
0034 AdministratorInviteUsersWidget::~AdministratorInviteUsersWidget() = default;
0035 
0036 QStringList AdministratorInviteUsersWidget::emails() const
0037 {
0038     return mListEmails->text().split(QLatin1Char(','), Qt::SkipEmptyParts);
0039 }
0040 
0041 #include "moc_administratorinviteuserswidget.cpp"