File indexing completed on 2024-12-01 04:36:52

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 "myaccountpersonalaccesscreatedialog.h"
0008 #include "myaccountpersonalaccesscreatewidget.h"
0009 #include <KLocalizedString>
0010 #include <QDialogButtonBox>
0011 #include <QPushButton>
0012 #include <QVBoxLayout>
0013 
0014 MyAccountPersonalAccessCreateDialog::MyAccountPersonalAccessCreateDialog(QWidget *parent)
0015     : QDialog(parent)
0016     , mCreateWidget(new MyAccountPersonalAccessCreateWidget(this))
0017 {
0018     setWindowTitle(i18nc("@title:window", "Create Personal Token"));
0019     auto mainLayout = new QVBoxLayout(this);
0020     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0021 
0022     mCreateWidget->setObjectName(QStringLiteral("mCreateWidget"));
0023     mainLayout->addWidget(mCreateWidget);
0024 
0025     auto button = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
0026     button->setObjectName(QStringLiteral("button"));
0027     mainLayout->addWidget(button);
0028     connect(button, &QDialogButtonBox::rejected, this, &MyAccountPersonalAccessCreateDialog::reject);
0029     connect(button, &QDialogButtonBox::accepted, this, &MyAccountPersonalAccessCreateDialog::accept);
0030 
0031     QPushButton *okButton = button->button(QDialogButtonBox::Ok);
0032     okButton->setText(i18n("Create"));
0033     okButton->setEnabled(false);
0034     connect(mCreateWidget, &MyAccountPersonalAccessCreateWidget::updateOkButton, okButton, &QPushButton::setEnabled);
0035 }
0036 
0037 MyAccountPersonalAccessCreateDialog::~MyAccountPersonalAccessCreateDialog() = default;
0038 
0039 bool MyAccountPersonalAccessCreateDialog::bypassTwoFactor() const
0040 {
0041     return mCreateWidget->bypassTwoFactor();
0042 }
0043 
0044 QString MyAccountPersonalAccessCreateDialog::tokenName() const
0045 {
0046     return mCreateWidget->tokenName();
0047 }
0048 
0049 #include "moc_myaccountpersonalaccesscreatedialog.cpp"