diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-01 17:27:58 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-01 17:27:58 +0200 |
commit | 329e8de84fc8e0a2e4a04fbaf85ab0e1632c6084 (patch) | |
tree | 864df8426b543d6817d6e364be4889bc6e20d640 /src | |
parent | Middle mouse button closes tab (diff) | |
download | smolbote-329e8de84fc8e0a2e4a04fbaf85ab0e1632c6084.tar.xz |
Only add profiles to profile manager at init
Diffstat (limited to 'src')
-rw-r--r-- | src/browser.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index be9d6b5..3442d66 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -118,20 +118,19 @@ void Browser::setup(const QString &defaultProfile) // register commands for(Plugin p : m_plugins) { - auto *plugin = qobject_cast<PluginInterface *>(p.instance.get()); - if(plugin) { - m_commands.unite(plugin->commands()); - } + if(p.instance->inherits("ProfileInterface")) { auto *profileEditor = qobject_cast<ProfileInterface *>(p.instance.get()); Q_ASSERT_X(profileEditor != nullptr, "Browser::setup", "profile interface cast failed"); - m_commands.insert("profileEditor:edit", [this, profileEditor]() -> int { - QHash<QString,QWebEngineProfile *> p; - for(const QString &key : m_profiles.keys()) { - p.insert(key, m_profiles.value(key)); - } - return profileEditor->createWidget(p, nullptr)->exec(); - }); + + for(const QString &name : m_profiles.keys()) { + profileEditor->addProfile(name, qobject_cast<QWebEngineProfile*>(m_profiles.value(name))); + } + } + + auto *plugin = qobject_cast<PluginInterface *>(p.instance.get()); + if(plugin) { + m_commands.unite(plugin->commands()); } } @@ -234,12 +233,7 @@ MainWindow *Browser::createWindow() if(profileEditor) { auto *profileAction = new QAction(tr("Profile"), window); connect(profileAction, &QAction::triggered, window, [this, profileEditor]() { - QHash<QString,QWebEngineProfile *> p; - for(const QString &key : m_profiles.keys()) { - p.insert(key, m_profiles.value(key)); - } - profileEditor->createWidget(p, nullptr)->show(); - //profileEditor->createWidget(WebProfile::defaultProfile(), nullptr)->show(); + profileEditor->createWidget(nullptr)->show(); }); window->addAction(MainWindow::ToolsMenu, profileAction); } |