Commit 8722dba8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use new ConfirmBeforeDeletingMessageBoxDialog

parent a99b2587
Pipeline #74466 passed with stage
in 54 minutes and 29 seconds
......@@ -5,8 +5,10 @@
*/
#include "confirmbeforedeletinginterface.h"
#include "confirmbeforedeletingmanager.h"
#include "confirmbeforedeletingmessageboxdialog.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QPointer>
ConfirmBeforeDeletingInterface::ConfirmBeforeDeletingInterface(QObject *parent)
: MessageViewer::MessageViewerCheckBeforeDeletingInterface(parent)
......@@ -27,7 +29,6 @@ Akonadi::Item::List ConfirmBeforeDeletingInterface::exec(const Akonadi::Item::Li
for (const auto &item : list) {
ConfirmBeforeDeletingRule r;
if (ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(item, checkFoundStr, r)) {
// TODO add checkbox for use same result for a specific check
if (ruleDelete.contains(r)) {
lst << item;
continue;
......@@ -36,15 +37,24 @@ Akonadi::Item::List ConfirmBeforeDeletingInterface::exec(const Akonadi::Item::Li
continue;
}
auto result =
KMessageBox::questionYesNoCancel(parentWidget(), i18n("Do you want to delete this email?\n%1", checkFoundStr), i18n("Confirm Delete Mail"));
if (result == KMessageBox::Yes) {
QPointer<ConfirmBeforeDeletingMessageBoxDialog> dlg = new ConfirmBeforeDeletingMessageBoxDialog(parentWidget());
dlg->setInfo(i18n("Do you want to delete this email?\n%1", checkFoundStr));
const int result = dlg->exec();
auto button = static_cast<QDialogButtonBox::StandardButton>(result);
if (button == QDialogButtonBox::StandardButton::Yes) {
lst << item;
ruleDelete.append(r);
} else if (result == KMessageBox::No) {
ruleNotDelete.append(r);
} else if (result == KMessageBox::Cancel) {
if (dlg->useSameResult()) {
ruleDelete.append(r);
}
delete dlg;
} else if (button == QDialogButtonBox::StandardButton::No) {
if (dlg->useSameResult()) {
ruleNotDelete.append(r);
}
delete dlg;
} else if (button == QDialogButtonBox::StandardButton::Cancel) {
lst.clear();
delete dlg;
break;
}
} else {
......
......@@ -9,6 +9,7 @@
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
ConfirmBeforeDeletingMessageBoxDialog::ConfirmBeforeDeletingMessageBoxDialog(QWidget *parent)
: QDialog(parent)
......@@ -24,8 +25,15 @@ ConfirmBeforeDeletingMessageBoxDialog::ConfirmBeforeDeletingMessageBoxDialog(QWi
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::Cancel | QDialogButtonBox::No, this);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
mainLayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfirmBeforeDeletingMessageBoxDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfirmBeforeDeletingMessageBoxDialog::reject);
connect(buttonBox->button(QDialogButtonBox::Yes), &QPushButton::clicked, this, [this]() {
done(QDialogButtonBox::Yes);
});
connect(buttonBox->button(QDialogButtonBox::No), &QPushButton::clicked, this, [this]() {
done(QDialogButtonBox::No);
});
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, [this]() {
done(QDialogButtonBox::Cancel);
});
}
ConfirmBeforeDeletingMessageBoxDialog::~ConfirmBeforeDeletingMessageBoxDialog()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment