aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ConfigurationEditor/configurationeditorplugin.cpp8
-rw-r--r--plugins/ConfigurationEditor/configurationeditorplugin.h11
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp15
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.h12
-rw-r--r--plugins/interfaces.h31
5 files changed, 22 insertions, 55 deletions
diff --git a/plugins/ConfigurationEditor/configurationeditorplugin.cpp b/plugins/ConfigurationEditor/configurationeditorplugin.cpp
index 93b1c69..0d44a8a 100644
--- a/plugins/ConfigurationEditor/configurationeditorplugin.cpp
+++ b/plugins/ConfigurationEditor/configurationeditorplugin.cpp
@@ -18,13 +18,7 @@ CommandHash_t ConfigurationEditorPlugin::commands()
QDialog *ConfigurationEditorPlugin::createWidget(QWidget *parent)
{
- auto *dlg = new ConfigurationDialog(m_config, parent);
+ auto *dlg = new ConfigurationDialog(browser->getConfiguration(), parent);
dlg->setAttribute(Qt::WA_DeleteOnClose, true);
return dlg;
}
-
-void ConfigurationEditorPlugin::setConfiguration(Configuration *cfg)
-{
- Q_CHECK_PTR(cfg);
- m_config = cfg;
-}
diff --git a/plugins/ConfigurationEditor/configurationeditorplugin.h b/plugins/ConfigurationEditor/configurationeditorplugin.h
index 6054723..6bb72ce 100644
--- a/plugins/ConfigurationEditor/configurationeditorplugin.h
+++ b/plugins/ConfigurationEditor/configurationeditorplugin.h
@@ -5,22 +5,17 @@
#include <interfaces.h>
class QDialog;
-class ConfigurationEditorPlugin : public QObject, public PluginInterface, public ConfigurationInterface
+class ConfigurationEditorPlugin : public QObject, public PluginInterface
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID ProfileInterfaceIid FILE "ConfigurationEditor.json")
- Q_INTERFACES(PluginInterface ConfigurationInterface)
+ Q_PLUGIN_METADATA(IID PluginInterfaceIid FILE "ConfigurationEditor.json")
+ Q_INTERFACES(PluginInterface)
public:
// PluginInterface
CommandHash_t commands() override;
QDialog *createWidget(QWidget *parent = nullptr) override;
- // ConfigurationInterface
- void setConfiguration(Configuration *cfg) override;
-
-private:
- Configuration *m_config = nullptr;
};
#endif // CONFIGURATIONEDITOR_PLUGIN_H
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index d13e819..5d5c18a 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -20,24 +20,13 @@ QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
auto *dialog = createWidget(nullptr);
return dialog->exec();
});
-
- hash.insert("list-profiles", [this]() -> int {
- for(const WebProfile *profile : qAsConst(profiles)) {
- qDebug(" - %s", qUtf8Printable(profile->name()));
- }
- return 0;
- });
return hash;
}
QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
{
- auto *widget = new ProfileManagerDialog(profiles, parent);
+ Q_CHECK_PTR(browser);
+ auto *widget = new ProfileManagerDialog(browser->profiles(), parent);
widget->setAttribute(Qt::WA_DeleteOnClose, true);
return widget;
}
-
-void ProfileEditorPlugin::registerProfile(WebProfile *profile)
-{
- profiles.append(profile);
-}
diff --git a/plugins/ProfileEditor/profileeditorplugin.h b/plugins/ProfileEditor/profileeditorplugin.h
index bc95708..c3e08af 100644
--- a/plugins/ProfileEditor/profileeditorplugin.h
+++ b/plugins/ProfileEditor/profileeditorplugin.h
@@ -14,11 +14,11 @@
class QWebEngineProfile;
class QDialog;
-class ProfileEditorPlugin : public QObject, public PluginInterface, public ProfileInterface
+class ProfileEditorPlugin : public QObject, public PluginInterface
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID ProfileInterfaceIid FILE "ProfileEditor.json")
- Q_INTERFACES(PluginInterface ProfileInterface)
+ Q_PLUGIN_METADATA(IID PluginInterfaceIid FILE "ProfileEditor.json")
+ Q_INTERFACES(PluginInterface)
public:
// PluginInterface
@@ -26,12 +26,6 @@ public:
// ProfileInterface
QDialog *createWidget(QWidget *parent) override;
-
-public slots:
- void registerProfile(WebProfile *profile) override;
-
-private:
- QVector<WebProfile *> profiles;
};
#endif //PROFILEEDITOR_PLUGIN_H
diff --git a/plugins/interfaces.h b/plugins/interfaces.h
index aad43c1..fc8eac8 100644
--- a/plugins/interfaces.h
+++ b/plugins/interfaces.h
@@ -20,6 +20,13 @@ class QDialog;
class WebProfile;
class Configuration;
+class BrowserInterface
+{
+public:
+ virtual Configuration *getConfiguration() const = 0;
+ virtual const QVector<WebProfile *> profiles() const = 0;
+};
+
struct Plugin
{
QString name;
@@ -36,29 +43,17 @@ public:
virtual ~PluginInterface() = default;
virtual CommandHash_t commands() = 0;
virtual QDialog *createWidget(QWidget *parent = nullptr) = 0;
-};
-class ProfileInterface
-{
-public:
- virtual ~ProfileInterface() = default;
- virtual void registerProfile(WebProfile *profile) = 0;
-};
+ void setBrowserInterface(BrowserInterface *browser)
+ {
+ this->browser = browser;
+ }
-class ConfigurationInterface
-{
-public:
- virtual ~ConfigurationInterface() = default;
- virtual void setConfiguration(Configuration *cfg) = 0;
+protected:
+ BrowserInterface *browser = nullptr;
};
#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface"
Q_DECLARE_INTERFACE(PluginInterface, PluginInterfaceIid)
-#define ProfileInterfaceIid "net.iserlohn-fortress.smolbote.ProfileInterface"
-Q_DECLARE_INTERFACE(ProfileInterface, ProfileInterfaceIid)
-
-#define ConfigurationInterfaceIid "net.iserlohn-fortress.smolbote.ConfigurationInterface"
-Q_DECLARE_INTERFACE(ConfigurationInterface, ConfigurationInterfaceIid)
-
#endif // SMOLBOTE_PLUGIN_INTERFACES_H