File indexing completed on 2024-05-19 11:33:49

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2012 David Faure <faure+bluesystems@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef FRAMEWORKINTEGRATIONPLUGIN_H
0009 #define FRAMEWORKINTEGRATIONPLUGIN_H
0010 
0011 #include <KMessageBoxDontAskAgainInterface>
0012 #include <KMessageBoxNotifyInterface>
0013 #include <QObject>
0014 
0015 class KConfig;
0016 
0017 class KMessageBoxDontAskAgainConfigStorage : public KMessageBoxDontAskAgainInterface
0018 {
0019 public:
0020     KMessageBoxDontAskAgainConfigStorage()
0021         : KMessageBox_againConfig(nullptr)
0022     {
0023     }
0024     ~KMessageBoxDontAskAgainConfigStorage() override
0025     {
0026     }
0027 
0028 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 100)
0029     bool shouldBeShownYesNo(const QString &dontShowAgainName, KMessageBox::ButtonCode &result) override;
0030 #else
0031     bool shouldBeShownTwoActions(const QString &dontShowAgainName, KMessageBox::ButtonCode &result) override;
0032 #endif
0033     bool shouldBeShownContinue(const QString &dontShowAgainName) override;
0034 #if KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 100)
0035     void saveDontShowAgainYesNo(const QString &dontShowAgainName, KMessageBox::ButtonCode result) override;
0036 #else
0037     void saveDontShowAgainTwoActions(const QString &dontShowAgainName, KMessageBox::ButtonCode result) override;
0038 #endif
0039     void saveDontShowAgainContinue(const QString &dontShowAgainName) override;
0040     void enableAllMessages() override;
0041     void enableMessage(const QString &dontShowAgainName) override;
0042     void setConfig(KConfig *cfg) override
0043     {
0044         KMessageBox_againConfig = cfg;
0045     }
0046 
0047 private:
0048     KConfig *KMessageBox_againConfig;
0049 };
0050 
0051 class KMessageBoxNotify : public KMessageBoxNotifyInterface
0052 {
0053 public:
0054     void sendNotification(QMessageBox::Icon notificationType, const QString &message, QWidget *parent) override;
0055 };
0056 
0057 class KFrameworkIntegrationPlugin : public QObject
0058 {
0059     Q_PLUGIN_METADATA(IID "org.kde.FrameworkIntegrationPlugin")
0060     Q_OBJECT
0061 public:
0062     KFrameworkIntegrationPlugin();
0063 
0064 public Q_SLOTS:
0065     void reparseConfiguration();
0066 
0067 private:
0068     KMessageBoxDontAskAgainConfigStorage m_dontAskAgainConfigStorage;
0069     KMessageBoxNotify m_notify;
0070 };
0071 
0072 #endif // FRAMEWORKINTEGRATIONPLUGIN_H