File indexing completed on 2024-05-05 17:43:13

0001 /*
0002  *   SPDX-FileCopyrightText: 2017 Ivan Cukic <ivan.cukic (at) kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "namechooserwidget.h"
0008 #include "ui_namechooserwidget.h"
0009 
0010 #include "vault.h"
0011 
0012 class NameChooserWidget::Private
0013 {
0014 public:
0015     Ui::NameChooserWidget ui;
0016 
0017     NameChooserWidget *const q;
0018     Private(NameChooserWidget *parent)
0019         : q(parent)
0020     {
0021     }
0022 };
0023 
0024 NameChooserWidget::NameChooserWidget()
0025     : DialogDsl::DialogModule(false)
0026     , d(new Private(this))
0027 {
0028     d->ui.setupUi(this);
0029 
0030     connect(d->ui.editVaultName, &QLineEdit::textChanged, this, [this](const QString &text) {
0031         Q_UNUSED(text);
0032         setIsValid(!d->ui.editVaultName->text().isEmpty());
0033     });
0034 }
0035 
0036 NameChooserWidget::~NameChooserWidget()
0037 {
0038 }
0039 
0040 PlasmaVault::Vault::Payload NameChooserWidget::fields() const
0041 {
0042     return {{KEY_NAME, d->ui.editVaultName->text()}};
0043 }
0044 
0045 void NameChooserWidget::init(const PlasmaVault::Vault::Payload &payload)
0046 {
0047     const auto name = payload[KEY_NAME].toString();
0048 
0049     d->ui.editVaultName->setText(name);
0050     setIsValid(!d->ui.editVaultName->text().isEmpty());
0051 }