aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webengineprofile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webengineprofile.cpp')
-rw-r--r--src/webengine/webengineprofile.cpp60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index 0a16cd5..583be3e 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -23,23 +23,38 @@
#include <QSettings>
#include <QWebEngineSettings>
-WebEngineProfile::WebEngineProfile(const QString &name, QObject *parent) :
+WebEngineProfile::WebEngineProfile(QObject *parent) :
QWebEngineProfile(parent)
{
- if(name.isEmpty()) {
- m_name = tr("Off-the-record");
- // off-the-record should have no storage or cache
- } else {
- m_name = name;
- setPersistentStoragePath(sSettings->value("browser.profile.path").toString() + name);
- setCachePath(sSettings->value("browser.profile.path").toString() + name);
- }
+ m_name = tr("Off-the-record");
- QString profilePath = sSettings->value("browser.profile.path").toString() + name + "/profile.ini";
- if(QFile::exists(profilePath)) {
+ // Off-the-record profiles have no persistent path
- qDebug("Reading profile from [%s]", qUtf8Printable(profilePath));
- QSettings config(profilePath, QSettings::IniFormat);
+ m_homepage = sSettings->value("browser.profile.new.homepage").toUrl();
+ m_newtab = sSettings->value("browser.profile.new.newtab").toUrl();
+}
+
+WebEngineProfile::WebEngineProfile(const QString &name, QObject *parent) :
+ QWebEngineProfile(name, parent)
+{
+ m_name = name;
+ setPersistentStoragePath(sSettings->value("browser.profile.storagePath").toString() + name);
+ setCachePath(sSettings->value("browser.profile.cachePath").toString() + name);
+
+ // Read profile settings
+ QString profileIniPath = sSettings->value("browser.profile.path").toString() + name + "/profile.ini";
+
+ // If none exist, use the defaults
+ if(!QFile::exists(profileIniPath)) {
+ qDebug("Creating new profile...");
+ m_homepage = sSettings->value("browser.profile.new.homepage").toUrl();
+ m_newtab = sSettings->value("browser.profile.new.newtab").toUrl();
+
+ // Else read them
+ } else {
+
+ qDebug("Reading profile from [%s]", qUtf8Printable(profileIniPath));
+ QSettings config(profileIniPath, QSettings::IniFormat);
m_homepage = config.value("homepage", m_homepage).toUrl();
m_newtab = config.value("newtab", m_newtab).toUrl();
@@ -117,17 +132,14 @@ QString WebEngineProfile::name() const
return m_name;
}
-ProfileView *WebEngineProfile::dialog()
+QUrl WebEngineProfile::homepage() const
{
- if(m_profileDialog == nullptr) {
- m_profileDialog = new ProfileView(this);
- }
- return m_profileDialog;
+ return m_homepage;
}
-QUrl WebEngineProfile::homepage() const
+void WebEngineProfile::setHomepage(const QUrl &url)
{
- return m_homepage;
+ m_homepage = url;
}
QUrl WebEngineProfile::newtab() const
@@ -135,10 +147,18 @@ QUrl WebEngineProfile::newtab() const
return m_newtab;
}
+void WebEngineProfile::setNewtab(const QUrl &url)
+{
+ m_newtab = url;
+}
+
void WebEngineProfile::saveProfile()
{
QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat);
+ config.setValue("homepage", homepage().toString());
+ config.setValue("newtab", newtab().toString());
+
config.beginGroup("http");
config.setValue("userAgent", httpUserAgent());
config.setValue("accept-lang", httpAcceptLanguage());