File indexing completed on 2022-11-29 20:24:01

0001 /*
0002     SPDX-FileCopyrightText: 2015-2022 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "configurecustomsettingdialog.h"
0009 #include "configurecustomsettingwidget.h"
0010 
0011 #include <KLocalizedString>
0012 #include <QDialogButtonBox>
0013 #include <QPushButton>
0014 #include <QVBoxLayout>
0015 
0016 ConfigureCustomSettingDialog::ConfigureCustomSettingDialog(QWidget *parent)
0017     : QDialog(parent)
0018     , mCustomSettingWidget(new ConfigureCustomSettingWidget(this))
0019 {
0020     auto mainLayout = new QVBoxLayout(this);
0021     setWindowTitle(i18nc("@title:window", "Add custom rule"));
0022 
0023     mCustomSettingWidget->setObjectName(QStringLiteral("customsettingwidget"));
0024     mainLayout->addWidget(mCustomSettingWidget);
0025 
0026     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
0027     buttonBox->setObjectName(QStringLiteral("buttonbox"));
0028     connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
0029     connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0030     QPushButton *buttonOk = buttonBox->button(QDialogButtonBox::Ok);
0031     buttonOk->setEnabled(false);
0032     connect(mCustomSettingWidget, &ConfigureCustomSettingWidget::enableButton, buttonOk, &QWidget::setEnabled);
0033     mainLayout->addWidget(buttonBox);
0034 }
0035 
0036 ConfigureCustomSettingDialog::~ConfigureCustomSettingDialog() = default;
0037 
0038 void ConfigureCustomSettingDialog::setRule(const QString &rule)
0039 {
0040     setWindowTitle(i18nc("@title:window", "Edit custom rule"));
0041     mCustomSettingWidget->setRule(rule);
0042 }
0043 
0044 QString ConfigureCustomSettingDialog::rule() const
0045 {
0046     return mCustomSettingWidget->rule();
0047 }