diff options
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index d5a3d3e..73b466f 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -23,6 +23,7 @@ #include <downloads/downloadswidget.h> #include <version.h> #include <webprofile.h> +#include "profilemanager.h" Browser::Browser(int &argc, char *argv[]) : SingleApplication(argc, argv) @@ -62,7 +63,9 @@ void Browser::registerPlugin(const Plugin &plugin) auto *profileEditor = qobject_cast<ProfileInterface *>(plugin.instance); Q_ASSERT_X(profileEditor != nullptr, "Browser::setup", "profile interface cast failed"); - for(auto it = m_profiles.constBegin(); it != m_profiles.constEnd(); ++it) { + ProfileIterator it(ProfileManager::profileList()); + while(it.hasNext()) { + it.next(); profileEditor->registerProfile(it.value()); } connect(this, &Browser::registerProfile, [=](WebProfile *profile) { @@ -94,26 +97,18 @@ void Browser::setup(const QString &defaultProfile) for(const QFileInfo &f : entries) { auto name = f.baseName(); - auto *profile = WebProfile::loadProfile(name, defaults, f.absoluteFilePath(), this); - m_profiles.insert(name, profile); - connect(profile, &WebProfile::destroyed, this, [=]() { - m_profiles.remove(name); - }); + auto *profile = ProfileManager::loadProfile(f.absoluteFilePath(), defaults); emit registerProfile(profile); } } // set default profile - if(!m_profiles.contains(defaultProfile)) { + if(ProfileManager::profile(defaultProfile) == nullptr) { // if this profile has not been added, it doesn't have a path - auto *profile = WebProfile::loadProfile(defaultProfile, defaults, QString(), this); - m_profiles.insert(defaultProfile, profile); - connect(profile, &WebProfile::destroyed, this, [=]() { - m_profiles.remove(defaultProfile); - }); + auto *profile = ProfileManager::loadProfile(QString(), defaults); emit registerProfile(profile); } - WebProfile::setDefaultProfile(m_profiles.value(defaultProfile)); + WebProfile::setDefaultProfile(ProfileManager::profile(defaultProfile)); } // url request filter @@ -133,14 +128,6 @@ void Browser::setup(const QString &defaultProfile) connect(WebProfile::defaultProfile(), &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload); } -WebProfile *Browser::profile(const QString &name) const -{ - if(m_profiles.contains(name)) - return m_profiles.value(name); - else - return nullptr; -} - void Browser::createSession(const QString &profileName, bool newWindow, const QStringList &urls) { if(m_windows.isEmpty()) { |