diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-23 12:50:10 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-23 12:50:10 +0200 |
commit | 41329fae5f819eee8c394571125f11f0a0b67cd9 (patch) | |
tree | e8e36f9b8458ee809114714e497c4a43a19949ef /src | |
parent | Add Configuration::setValue and Configuration::setShortcut (diff) | |
download | smolbote-41329fae5f819eee8c394571125f11f0a0b67cd9.tar.xz |
Add ConfigurationEditor plugin
Removed poi-config
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); |