File indexing completed on 2024-06-09 09:26:27

0001 // clang-format off
0002 /*
0003  * KDiff3 - Text Diff And Merge Tool
0004  *
0005  * SPDX-FileCopyrightText: 2023 Michael Reeves reeves.87@gmail.com
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 // clang-format on
0009 
0010 #ifndef COMPAT_H
0011 #define COMPAT_H
0012 
0013 /*
0014     KF5I18n rightfully complains if included in the auto-test builds as they aren't actually setup
0015     for translations.
0016 */
0017 #ifndef AUTOTEST
0018 
0019 #include <KLocalizedString>
0020 #include <KMessageBox>
0021 #else
0022 #define i18n(expr, ...) expr
0023 #define i18nc(c, expr, ...) expr
0024 #endif
0025 #define KF_VERSION_CHECK(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
0026 #define KF_VERSION KF_VERSION_CHECK(KF_VERSION_MAJOR, KF_VERSION_MINOR, KF_VERSION_PATCH)
0027 
0028 #ifndef AUTOTEST
0029 namespace Compat {
0030 
0031 inline KMessageBox::ButtonCode warningTwoActionsCancel(QWidget *parent,
0032                                                        const QString &text,
0033                                                        const QString &title,
0034                                                        const KGuiItem &primaryAction,
0035                                                        const KGuiItem &secondaryAction,
0036                                                        const KGuiItem &cancelAction = KStandardGuiItem::cancel(),
0037                                                        const QString &dontAskAgainName = QString(),
0038                                                        KMessageBox::Options options = KMessageBox::Options(KMessageBox::Notify | KMessageBox::Dangerous))
0039 {
0040     return KMessageBox::warningTwoActionsCancel(parent,
0041                                                 text,
0042                                                 title,
0043                                                 primaryAction,
0044                                                 secondaryAction,
0045                                                 cancelAction,
0046                                                 dontAskAgainName,
0047                                                 options);
0048 }
0049 
0050 inline KMessageBox::ButtonCode warningTwoActions(QWidget *parent,
0051                                                  const QString &text,
0052                                                  const QString &title,
0053                                                  const KGuiItem &primaryAction,
0054                                                  const KGuiItem &secondaryAction,
0055                                                  const QString &dontAskAgainName = QString(),
0056                                                  KMessageBox::Options options = KMessageBox::Options(KMessageBox::Notify | KMessageBox::Dangerous))
0057 {
0058     return KMessageBox::warningTwoActions(parent,
0059                                           text,
0060                                           title,
0061                                           primaryAction,
0062                                           secondaryAction,
0063                                           dontAskAgainName,
0064                                           options);
0065 }
0066 
0067 constexpr KMessageBox::ButtonCode PrimaryAction = KMessageBox::PrimaryAction;
0068 constexpr KMessageBox::ButtonCode SecondaryAction = KMessageBox::SecondaryAction;
0069 
0070 } //namespace Compat
0071 #endif // ndef AUTOTEST
0072 
0073 #endif /* COMPAT_H */