File indexing completed on 2025-01-05 05:14:39

0001 /*
0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com>
0003 
0004 SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 
0007 #include "kmessageboxhelper.h"
0008 
0009 #include <KMessageBox>
0010 #include <KStandardGuiItem>
0011 #include <kwidgetsaddons_version.h>
0012 
0013 KMessageBoxHelper::KMessageBoxHelper()
0014 {
0015 }
0016 
0017 bool KMessageBoxHelper::removeQuestion(QWidget *parent, const QString &text, const QString &caption)
0018 {
0019 #if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
0020     auto r = KMessageBox::questionTwoActions(parent, text, caption, KStandardGuiItem::remove(), KStandardGuiItem::cancel());
0021     return r == KMessageBox::ButtonCode::PrimaryAction;
0022 #else
0023     auto r = KMessageBox::questionYesNo(parent, text, caption);
0024     return r == KMessageBox::Yes;
0025 #endif
0026 }
0027 
0028 bool KMessageBoxHelper::applyQuestion(QWidget *parent, const QString &text, const QString &caption)
0029 {
0030 #if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0)
0031     auto r = KMessageBox::questionTwoActions(parent, text, caption, KStandardGuiItem::apply(), KStandardGuiItem::cancel());
0032     return r == KMessageBox::ButtonCode::PrimaryAction;
0033 #else
0034     auto r = KMessageBox::questionYesNo(parent, text, caption);
0035     return r == KMessageBox::Yes;
0036 #endif
0037 }