File indexing completed on 2024-05-12 16:27:12
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 "channelpassworddialog.h" 0008 #include "channelpasswordwidget.h" 0009 #include <KLocalizedString> 0010 #include <QDialogButtonBox> 0011 #include <QPushButton> 0012 #include <QVBoxLayout> 0013 0014 ChannelPasswordDialog::ChannelPasswordDialog(QWidget *parent) 0015 : QDialog(parent) 0016 , mChannelPasswordWidget(new ChannelPasswordWidget(this)) 0017 { 0018 setWindowTitle(i18nc("@title:window", "Add Password")); 0019 auto mainLayout = new QVBoxLayout(this); 0020 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0021 0022 mChannelPasswordWidget->setObjectName(QStringLiteral("mChannelPasswordWidget")); 0023 mainLayout->addWidget(mChannelPasswordWidget); 0024 0025 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0026 buttonBox->setObjectName(QStringLiteral("button")); 0027 connect(buttonBox, &QDialogButtonBox::accepted, this, &ChannelPasswordDialog::accept); 0028 connect(buttonBox, &QDialogButtonBox::rejected, this, &ChannelPasswordDialog::reject); 0029 mainLayout->addWidget(buttonBox); 0030 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 0031 okButton->setEnabled(false); 0032 connect(mChannelPasswordWidget, &ChannelPasswordWidget::updateOkButton, this, [okButton](bool state) { 0033 okButton->setEnabled(state); 0034 }); 0035 } 0036 0037 ChannelPasswordDialog::~ChannelPasswordDialog() = default; 0038 0039 QString ChannelPasswordDialog::password() const 0040 { 0041 return mChannelPasswordWidget->password(); 0042 } 0043 0044 #include "moc_channelpassworddialog.cpp"