diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-08-04 13:12:32 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-08-04 13:12:32 +0200 |
commit | a85dc7d9133c3cf4c94a2ef37db4f53a3d0e4c91 (patch) | |
tree | 81cc123c4afbaf726fbc4a8a6b87d50732432b4b /src/webengine | |
parent | Updated documentation (diff) | |
download | smolbote-a85dc7d9133c3cf4c94a2ef37db4f53a3d0e4c91.tar.xz |
Profile window fixes
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/webengineprofile.cpp | 60 | ||||
-rw-r--r-- | src/webengine/webengineprofile.h | 8 |
2 files changed, 45 insertions, 23 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()); diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h index e225462..f457f53 100644 --- a/src/webengine/webengineprofile.h +++ b/src/webengine/webengineprofile.h @@ -29,16 +29,18 @@ class WebEngineProfile : public QWebEngineProfile { Q_OBJECT public: + explicit WebEngineProfile(QObject *parent = Q_NULLPTR); explicit WebEngineProfile(const QString &name, QObject *parent = Q_NULLPTR); ~WebEngineProfile(); QString name() const; + QUrl homepage() const; - QUrl newtab() const; + void setHomepage(const QUrl &url); - // TODO: remove - ProfileView *dialog(); + QUrl newtab() const; + void setNewtab(const QUrl &url); signals: |