File indexing completed on 2024-11-24 04:43:06

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "confirmbeforedeletingcreateruledialog.h"
0008 #include <KLocalizedString>
0009 #include <QDialogButtonBox>
0010 #include <QPushButton>
0011 #include <QVBoxLayout>
0012 
0013 ConfirmBeforeDeletingCreateRuleDialog::ConfirmBeforeDeletingCreateRuleDialog(QWidget *parent)
0014     : QDialog(parent)
0015     , mConfirmBeforeDeletingCreateRuleWidget(new ConfirmBeforeDeletingCreateRuleWidget(this))
0016 {
0017     setWindowTitle(i18nc("@title:window", "Configure Rule"));
0018     auto mainLayout = new QVBoxLayout(this);
0019     mainLayout->setObjectName(QLatin1StringView("mainlayout"));
0020 
0021     mConfirmBeforeDeletingCreateRuleWidget->setObjectName(QLatin1StringView("mConfirmBeforeDeletingCreateRuleWidget"));
0022     mainLayout->addWidget(mConfirmBeforeDeletingCreateRuleWidget);
0023 
0024     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
0025     buttonBox->setObjectName(QLatin1StringView("buttonBox"));
0026     mainLayout->addWidget(buttonBox);
0027     connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfirmBeforeDeletingCreateRuleDialog::accept);
0028     connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfirmBeforeDeletingCreateRuleDialog::reject);
0029     auto okButton = buttonBox->button(QDialogButtonBox::Ok);
0030     okButton->setEnabled(false);
0031     connect(mConfirmBeforeDeletingCreateRuleWidget, &ConfirmBeforeDeletingCreateRuleWidget::updateOkButton, okButton, &QPushButton::setEnabled);
0032 }
0033 
0034 ConfirmBeforeDeletingCreateRuleDialog::~ConfirmBeforeDeletingCreateRuleDialog() = default;
0035 
0036 ConfirmBeforeDeletingCreateRuleWidget::ConfirmBeforeDeletingInfo ConfirmBeforeDeletingCreateRuleDialog::info() const
0037 {
0038     return mConfirmBeforeDeletingCreateRuleWidget->info();
0039 }
0040 
0041 void ConfirmBeforeDeletingCreateRuleDialog::setInfo(const ConfirmBeforeDeletingCreateRuleWidget::ConfirmBeforeDeletingInfo &info)
0042 {
0043     mConfirmBeforeDeletingCreateRuleWidget->setInfo(info);
0044 }
0045 
0046 #include "moc_confirmbeforedeletingcreateruledialog.cpp"