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 "confirmbeforedeletingmessageboxdialog.h"
0008 #include "confirmbeforedeletingmessageboxwidget.h"
0009 
0010 #include <KLocalizedString>
0011 #include <QDialogButtonBox>
0012 #include <QPushButton>
0013 #include <QVBoxLayout>
0014 ConfirmBeforeDeletingMessageBoxDialog::ConfirmBeforeDeletingMessageBoxDialog(QWidget *parent)
0015     : QDialog(parent)
0016     , mConfirmBeforeDeletingWidget(new ConfirmBeforeDeletingMessageBoxWidget(this))
0017 {
0018     setWindowTitle(i18nc("@title:window", "Confirm Delete Mail"));
0019 
0020     auto mainLayout = new QVBoxLayout(this);
0021     mainLayout->setObjectName(QLatin1StringView("mainLayout"));
0022     mConfirmBeforeDeletingWidget->setObjectName(QLatin1StringView("mConfirmBeforeDeletingWidget"));
0023     mainLayout->addWidget(mConfirmBeforeDeletingWidget);
0024 
0025     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::Cancel | QDialogButtonBox::No, this);
0026     buttonBox->setObjectName(QLatin1StringView("buttonBox"));
0027     mainLayout->addWidget(buttonBox);
0028     connect(buttonBox, &QDialogButtonBox::clicked, this, [this, buttonBox](QAbstractButton *button) {
0029         QDialogButtonBox::StandardButton code = buttonBox->standardButton(button);
0030         if (code != QDialogButtonBox::NoButton) {
0031             done(code);
0032         }
0033     });
0034 }
0035 
0036 ConfirmBeforeDeletingMessageBoxDialog::~ConfirmBeforeDeletingMessageBoxDialog() = default;
0037 
0038 void ConfirmBeforeDeletingMessageBoxDialog::setInfo(const QString &str)
0039 {
0040     mConfirmBeforeDeletingWidget->setInfo(str);
0041 }
0042 
0043 bool ConfirmBeforeDeletingMessageBoxDialog::useSameResult() const
0044 {
0045     return mConfirmBeforeDeletingWidget->useSameResult();
0046 }
0047 
0048 #include "moc_confirmbeforedeletingmessageboxdialog.cpp"