1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include <QtWidgets/QPushButton>
5
6#include "qfilternamedialog_p.h"
7
8QT_BEGIN_NAMESPACE
9
10QFilterNameDialog::QFilterNameDialog(QWidget *parent)
11 : QDialog(parent)
12{
13 m_ui.setupUi(this);
14 connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
15 this, &QDialog::accept);
16 connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked,
17 this, &QDialog::reject);
18 connect(m_ui.lineEdit, &QLineEdit::textChanged,
19 this, &QFilterNameDialog::updateOkButton);
20 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
21}
22
23void QFilterNameDialog::setFilterName(const QString &filter)
24{
25 m_ui.lineEdit->setText(filter);
26 m_ui.lineEdit->selectAll();
27}
28
29QString QFilterNameDialog::filterName() const
30{
31 return m_ui.lineEdit->text();
32}
33
34void QFilterNameDialog::updateOkButton()
35{
36 m_ui.buttonBox->button(QDialogButtonBox::Ok)
37 ->setDisabled(m_ui.lineEdit->text().isEmpty());
38}
39
40QT_END_NAMESPACE
41

source code of qttools/src/assistant/help/qfilternamedialog.cpp