File indexing completed on 2024-12-01 04:36:53
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 "myaccountpersonalaccesscreatewidget.h" 0008 #include <KLineEditEventHandler> 0009 #include <KLocalizedString> 0010 #include <QCheckBox> 0011 #include <QFormLayout> 0012 #include <QLineEdit> 0013 0014 MyAccountPersonalAccessCreateWidget::MyAccountPersonalAccessCreateWidget(QWidget *parent) 0015 : QWidget{parent} 0016 , mBypassTwoFactor(new QCheckBox(i18n("Ignore Two Factor Authentication"), this)) 0017 , mTokenName(new QLineEdit(this)) 0018 { 0019 auto formLayout = new QFormLayout(this); 0020 formLayout->setObjectName(QStringLiteral("formLayout")); 0021 0022 mBypassTwoFactor->setObjectName(QStringLiteral("mBypassTwoFactor")); 0023 mTokenName->setObjectName(QStringLiteral("mTokenName")); 0024 mTokenName->setClearButtonEnabled(true); 0025 0026 KLineEditEventHandler::catchReturnKey(mTokenName); 0027 0028 formLayout->addRow(i18n("Name:"), mTokenName); 0029 formLayout->addWidget(mBypassTwoFactor); 0030 0031 connect(mTokenName, &QLineEdit::textChanged, this, [this](const QString &str) { 0032 Q_EMIT updateOkButton(!str.trimmed().isEmpty()); 0033 }); 0034 } 0035 0036 MyAccountPersonalAccessCreateWidget::~MyAccountPersonalAccessCreateWidget() = default; 0037 0038 bool MyAccountPersonalAccessCreateWidget::bypassTwoFactor() const 0039 { 0040 return mBypassTwoFactor->isChecked(); 0041 } 0042 0043 QString MyAccountPersonalAccessCreateWidget::tokenName() const 0044 { 0045 return mTokenName->text().trimmed(); 0046 } 0047 0048 #include "moc_myaccountpersonalaccesscreatewidget.cpp"