File indexing completed on 2024-10-06 07:30:29

0001 /*
0002     SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef KMESSAGEBOX_KDEVCOMPAT
0008 #define KMESSAGEBOX_KDEVCOMPAT
0009 
0010 #include <KMessageBox>
0011 #include <kwidgetsaddons_version.h>
0012 
0013 // Temporary private porting helper to avoid if-else cluttering of the codebase.
0014 // Once KF5_DEP_VERSION >= 5.100 is reached:
0015 // * rm all #include <KMessageBox_KDevCompat>
0016 // * git rm KMessageBox_KDevCompat
0017 #if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 100, 0)
0018 namespace KMessageBox {
0019 
0020 inline constexpr auto PrimaryAction = KMessageBox::Yes;
0021 inline constexpr auto SecondaryAction = KMessageBox::No;
0022 
0023 inline ButtonCode questionTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction,
0024                                      const QString &dontAskAgainName = QString(), Options options = Notify)
0025 {
0026     return questionYesNo(parent, text, title, primaryAction, secondaryAction, dontAskAgainName, options);
0027 }
0028 
0029 inline ButtonCode questionTwoActionsCancel(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction,
0030                                            const KGuiItem &secondaryAction, const KGuiItem &cancelAction = KStandardGuiItem::cancel(),
0031                                            const QString &dontAskAgainName = QString(), Options options = Notify)
0032 {
0033     return questionYesNoCancel(parent, text, title, primaryAction, secondaryAction, cancelAction, dontAskAgainName, options);
0034 }
0035 
0036 inline ButtonCode warningTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction,
0037                                     const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous))
0038 {
0039     return warningYesNo(parent, text, title, primaryAction, secondaryAction, dontAskAgainName, options);
0040 }
0041 
0042 inline ButtonCode warningTwoActionsList(QWidget *parent, const QString &text, const QStringList &strlist, const QString &title, const KGuiItem &primaryAction,
0043                                         const KGuiItem &secondaryAction, const QString &dontAskAgainName = QString(),
0044                                         Options options = Options(Notify | Dangerous))
0045 {
0046     return warningYesNoList(parent, text, strlist, title, primaryAction, secondaryAction, dontAskAgainName, options);
0047 }
0048 
0049 inline ButtonCode warningTwoActionsCancel(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction,
0050                                           const KGuiItem &secondaryAction, const KGuiItem &cancelAction = KStandardGuiItem::cancel(),
0051                                           const QString &dontAskAgainName = QString(), Options options = Options(Notify | Dangerous))
0052 {
0053     return warningYesNoCancel(parent, text, title, primaryAction, secondaryAction, cancelAction, dontAskAgainName, options);
0054 }
0055 
0056 } // namespace KMessageBox
0057 #endif
0058 
0059 #endif // KMESSAGEBOX_KDEVCOMPAT