diff options
Diffstat (limited to 'src/browser.h')
-rw-r--r-- | src/browser.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/browser.h b/src/browser.h index e871202..2148484 100644 --- a/src/browser.h +++ b/src/browser.h @@ -16,6 +16,8 @@ #include <functional> #include <memory> #include <singleapplication.h> +#include <QMenu> +#include <QPluginLoader> class Configuration; class BookmarksWidget; @@ -23,7 +25,6 @@ class DownloadsWidget; class Filter; class MainWindow; class ProfileManager; -class QPluginLoader; class Browser : public SingleApplication, public BrowserInterface { Q_OBJECT @@ -47,6 +48,7 @@ public: QPair<QString, Profile *> loadProfile(const QString &id, bool isOffTheRecord = true) override; void removeProfile(const QString &id) override; + QPluginLoader *addPlugin(const QString &path = QString()); void setConfiguration(std::unique_ptr<Configuration> &config); void setup(QVector<QPluginLoader *> plugins); @@ -61,6 +63,21 @@ public slots: MainWindow *createWindow(); private: + struct PluginInfo { + explicit PluginInfo(QPluginLoader *l) { + this->loader = l; + } + ~PluginInfo() { + loader->unload(); + for(auto *m : menus) + m->deleteLater(); + }; + + QPluginLoader *loader; + QVector<QMenu *> menus; + }; + void addPluginTo(PluginInfo *info, MainWindow *window); + Q_DISABLE_COPY(Browser) std::unique_ptr<Configuration> m_config; @@ -70,7 +87,7 @@ private: std::unique_ptr<Filter> m_urlFilter; QVector<MainWindow *> m_windows; - QVector<QPluginLoader *> m_plugins; + QVector<PluginInfo*> m_plugins; }; #endif // SMOLBOTE_BROWSER_H |