diff options
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 375796c..e248a3f 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -58,30 +58,20 @@ void Browser::setConfiguration(std::unique_ptr<Configuration> &config) m_config = std::move(config); } -void Browser::registerPlugin(const Plugin &plugin) +Configuration *Browser::getConfiguration() const { Q_ASSERT(m_config); + return m_config.get(); +} - if(plugin.instance->inherits("ProfileInterface")) { - auto *profileEditor = qobject_cast<ProfileInterface *>(plugin.instance); - Q_ASSERT_X(profileEditor != nullptr, "Browser::setup", "profile interface cast failed"); - - ProfileIterator it(ProfileManager::profileList()); - while(it.hasNext()) { - it.next(); - profileEditor->registerProfile(it.value()); - } - connect(this, &Browser::registerProfile, [=](WebProfile *profile) { - profileEditor->registerProfile(profile); - }); - } +void Browser::registerPlugin(const Plugin &plugin) +{ + Q_ASSERT(m_config); - if(plugin.instance->inherits("ConfigurationInterface")) { - auto *configEditor = qobject_cast<ConfigurationInterface *>(plugin.instance); - Q_CHECK_PTR(configEditor); - configEditor->setConfiguration(m_config.get()); - } + auto *p = qobject_cast<PluginInterface *>(plugin.instance); + Q_CHECK_PTR(p); + p->setBrowserInterface(this); m_plugins.append(plugin); } @@ -117,7 +107,6 @@ void Browser::setup(const QString &defaultProfile) auto *profile = ProfileManager::loadProfile(f.absoluteFilePath(), defaults); connect(profile, &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload); profile->setRequestInterceptor(m_urlFilter.get()); - emit registerProfile(profile); } } @@ -127,7 +116,6 @@ void Browser::setup(const QString &defaultProfile) auto *profile = ProfileManager::loadProfile(QString(), defaults); connect(profile, &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload); profile->setRequestInterceptor(m_urlFilter.get()); - emit registerProfile(profile); } WebProfile::setDefaultProfile(ProfileManager::profile(defaultProfile)); } @@ -139,6 +127,12 @@ void Browser::setup(const QString &defaultProfile) }); } +const QVector<WebProfile *> Browser::profiles() const +{ + const QMap<QString, WebProfile *> profileList = ProfileManager::profileList(); + return QVector<WebProfile *>::fromList(profileList.values()); +} + void Browser::createSession(const QJsonObject &object) { MainWindow *mainwindow = nullptr; |