From 329e8de84fc8e0a2e4a04fbaf85ab0e1632c6084 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 1 Jun 2018 17:27:58 +0200 Subject: Only add profiles to profile manager at init --- src/browser.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src') 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(p.instance.get()); - if(plugin) { - m_commands.unite(plugin->commands()); - } + if(p.instance->inherits("ProfileInterface")) { auto *profileEditor = qobject_cast(p.instance.get()); Q_ASSERT_X(profileEditor != nullptr, "Browser::setup", "profile interface cast failed"); - m_commands.insert("profileEditor:edit", [this, profileEditor]() -> int { - QHash 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(m_profiles.value(name))); + } + } + + auto *plugin = qobject_cast(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 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); } -- cgit v1.2.1