File indexing completed on 2024-04-21 04:42:38

0001 /*
0002     SPDX-FileCopyrightText: 2012 Dawit Alemayehu <adawit@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef WEBPLUGINFACTORY_H
0008 #define WEBPLUGINFACTORY_H
0009 
0010 #include <KWebPluginFactory>
0011 
0012 #include <QWidget>
0013 #include <QPointer>
0014 
0015 class KWebKitPart;
0016 class QPoint;
0017 
0018 class FakePluginWidget : public QWidget
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(bool swapping READ swapping)
0022 
0023 public:
0024     FakePluginWidget(uint id, const QUrl& url, const QString& mimeType, QWidget* parent = nullptr);
0025     bool swapping() const { return m_swapping; }
0026 
0027 Q_SIGNALS:
0028     void pluginLoaded(uint);
0029 
0030 private Q_SLOTS:
0031     void loadAll();
0032     void load(bool loadAll = false);
0033     void showContextMenu(const QPoint&);
0034     void updateScrollPoisition(int, int, const QRect&);
0035 
0036 private:
0037     bool m_swapping;
0038     bool m_updateScrollPosition;
0039     QString m_mimeType;
0040     uint m_id;
0041 };
0042 
0043 class WebPluginFactory : public KWebPluginFactory
0044 {
0045     Q_OBJECT
0046 public:
0047     explicit WebPluginFactory (KWebKitPart* part, QObject* parent = nullptr);
0048     QObject* create (const QString&, const QUrl&, const QStringList&, const QStringList&) const override;
0049     void resetPluginOnDemandList();
0050 
0051 private Q_SLOTS:
0052     void loadedPlugin(uint);
0053 
0054 private:
0055     QPointer<KWebKitPart> mPart;
0056     mutable QList<uint> mPluginsLoadedOnDemand;
0057 };
0058 
0059 #endif