diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/browser.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 56eed96..e266024 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -70,6 +70,13 @@ void Browser::registerPlugin(const Plugin &plugin) }); } + if(plugin.instance->inherits("ConfigurationInterface")) { + auto *configEditor = qobject_cast<ConfigurationInterface *>(plugin.instance); + Q_CHECK_PTR(configEditor); + + configEditor->setConfiguration(m_config.get()); + } + m_plugins.append(plugin); } @@ -193,15 +200,17 @@ MainWindow *Browser::createWindow() window->addAction(MainWindow::ToolsMenu, downloadsAction); for(const Plugin &p : qAsConst(m_plugins)) { - if(p.instance->inherits("ProfileInterface")) { - auto *profileEditor = qobject_cast<ProfileInterface *>(p.instance); - auto *profileAction = new QAction(tr("Profile"), window); - profileAction->setShortcut(p.shortcut); - connect(profileAction, &QAction::triggered, window, [profileEditor]() { - profileEditor->createWidget(nullptr)->show(); - }); - window->addAction(MainWindow::ToolsMenu, profileAction); - } + auto *plugin = qobject_cast<PluginInterface *>(p.instance); + Q_CHECK_PTR(plugin); + + auto *pluginAction = new QAction(p.name, window); + pluginAction->setShortcut(p.shortcut); + + connect(pluginAction, &QAction::triggered, window, [=]() { + plugin->createWidget(window)->exec(); + }); + window->addAction(MainWindow::ToolsMenu, pluginAction); + } m_windows.append(window); |