File indexing completed on 2024-12-08 04:34:23
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "passwordconfirmwidget.h" 0008 0009 #include <KAuthorized> 0010 #include <KLocalizedString> 0011 #include <KPasswordLineEdit> 0012 #include <QFormLayout> 0013 0014 PasswordConfirmWidget::PasswordConfirmWidget(QWidget *parent) 0015 : QWidget(parent) 0016 , mNewPasswordLineEdit(new KPasswordLineEdit(this)) 0017 , mConfirmPasswordLineEdit(new KPasswordLineEdit(this)) 0018 { 0019 auto mainLayout = new QFormLayout(this); 0020 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0021 mainLayout->setContentsMargins({}); 0022 0023 mNewPasswordLineEdit->setObjectName(QStringLiteral("mNewPasswordLineEdit")); 0024 mainLayout->addRow(i18n("New Password:"), mNewPasswordLineEdit); 0025 mNewPasswordLineEdit->setRevealPasswordAvailable(KAuthorized::authorize(QStringLiteral("lineedit_reveal_password"))); 0026 0027 mConfirmPasswordLineEdit->setObjectName(QStringLiteral("mConfirmPasswordLineEdit")); 0028 mainLayout->addRow(i18n("Confirm Password:"), mConfirmPasswordLineEdit); 0029 mConfirmPasswordLineEdit->setRevealPasswordAvailable(KAuthorized::authorize(QStringLiteral("lineedit_reveal_password"))); 0030 } 0031 0032 PasswordConfirmWidget::~PasswordConfirmWidget() = default; 0033 0034 bool PasswordConfirmWidget::isNewPasswordConfirmed() const 0035 { 0036 const QString password = mConfirmPasswordLineEdit->password(); 0037 return !password.isEmpty() && (password == mNewPasswordLineEdit->password()); 0038 } 0039 0040 QString PasswordConfirmWidget::password() const 0041 { 0042 return mConfirmPasswordLineEdit->password(); 0043 } 0044 0045 #include "moc_passwordconfirmwidget.cpp"