Akonadi

renamefavoritedialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2011-2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "renamefavoritedialog_p.h"
8 
9 #include <KLocalizedString>
10 
11 #include <QPushButton>
12 
13 using namespace Akonadi;
14 
15 RenameFavoriteDialog::RenameFavoriteDialog(const QString &value, const QString &defaultName, QWidget *parent)
16  : QDialog(parent)
17  , m_defaultName(defaultName)
18 {
19  ui.setupUi(this);
20 
21  connect(ui.lineEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
22  ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.trimmed().isEmpty());
23  });
24  connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &RenameFavoriteDialog::accept);
25  connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &RenameFavoriteDialog::reject);
26  connect(ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, [this]() {
27  ui.lineEdit->setText(m_defaultName);
28  });
29 
30  ui.lineEdit->setText(value);
31 }
32 
33 QString RenameFavoriteDialog::newName() const
34 {
35  return ui.lineEdit->text();
36 }
void clicked(bool checked)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void textChanged(const QString &text)
void setupUi(QWidget *widget)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.