diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/browser.cpp | 6 | ||||
-rw-r--r-- | src/webengine/webprofile.cpp | 358 | ||||
-rw-r--r-- | src/webengine/webprofile.h | 43 |
3 files changed, 213 insertions, 194 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 05d9a0b..525f02c 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -59,7 +59,9 @@ inline QHash<QString, WebProfile *> loadProfiles(const QString &location) if(profilesDir.exists()) { const QFileInfoList entries = profilesDir.entryInfoList({ "*.profile" }, QDir::Files | QDir::Readable); for(const auto &entry : entries) { - list.insert(entry.baseName(), new WebProfile(entry.baseName())); + auto *profile = new WebProfile(entry.baseName()); + loadProfile(profile, entry.absoluteFilePath()); + list.insert(entry.baseName(), profile); } } @@ -99,7 +101,7 @@ void Browser::setup(const QString &defaultProfile) // load profiles { - auto *otr = new WebProfile(this); + auto *otr = new WebProfile(m_config->section("profile"), this); m_profiles.insert(tr("Off-the-record"), otr); m_profiles.unite(loadProfiles(QString::fromStdString(m_config->value<std::string>("profile.path").value()))); diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp index 54aab5a..28b1bd1 100644 --- a/src/webengine/webprofile.cpp +++ b/src/webengine/webprofile.cpp @@ -14,7 +14,178 @@ WebProfile *WebProfile::profile = nullptr; -WebProfile::WebProfile(QObject *parent) +void loadProfile(WebProfile *profile, const QString &path) +{ + // return if there is no config file + if(!QFileInfo::exists(path)) + return; + +#ifdef QT_DEBUG + qDebug("Reading config for profile '%s': %s", qUtf8Printable(profile->name()), qUtf8Printable(path)); +#endif + QSettings config(path, QSettings::IniFormat); + + config.beginGroup("properties"); + for(const QString &key : config.childKeys()) { + profile->setProperty(qUtf8Printable(key), config.value(key)); + } + config.endGroup(); // properties + +// m_search = config.value("search", conf.value("profile.search")).toString(); +// m_homepage = config.value("homepage", conf["profile.homepage"]).toUrl(); +// m_newtab = config.value("newtab", conf["profile.newtab"]).toUrl(); + +// config.beginGroup("http"); +// setHttpUserAgent(config.value("userAgent", httpUserAgent()).toString()); +// setHttpAcceptLanguage(config.value("accept-lang", httpAcceptLanguage()).toString()); +// { +// QString cacheType = config.value("cacheType").toString(); +// if(cacheType == "memory") { +// setHttpCacheType(QWebEngineProfile::MemoryHttpCache); +// } else if(cacheType == "disk") { +// setHttpCacheType(QWebEngineProfile::DiskHttpCache); +// } else if(cacheType == "disabled") { +// setHttpCacheType(QWebEngineProfile::NoCache); +// } +// } +// setHttpCacheMaximumSize(config.value("cacheSize", httpCacheMaximumSize()).toInt()); +// config.endGroup(); // http + +// config.beginGroup("policy"); +// { +// QString cookies = config.value("cookies").toString(); +// if(cookies == "disabled") { +// setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); +// } else if(cookies == "allow") { +// setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies); +// } else if(cookies == "force") { +// setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); +// } +// } +// config.endGroup(); // policy + +// config.beginGroup("attributes"); +// QWebEngineSettings *s = settings(); +// s->setAttribute(QWebEngineSettings::AutoLoadImages, +// config.value("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)).toBool()); +// s->setAttribute(QWebEngineSettings::JavascriptEnabled, +// config.value("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, +// config.value("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)).toBool()); +// s->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, +// config.value("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)).toBool()); +// s->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, +// config.value("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)).toBool()); +// s->setAttribute(QWebEngineSettings::LocalStorageEnabled, +// config.value("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, +// config.value("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)).toBool()); +// s->setAttribute(QWebEngineSettings::XSSAuditingEnabled, +// config.value("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, +// config.value("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, +// config.value("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)).toBool()); +// s->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, +// config.value("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, +// config.value("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::ErrorPageEnabled, +// config.value("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::PluginsEnabled, +// config.value("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, +// config.value("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, +// config.value("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::WebGLEnabled, +// config.value("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, +// config.value("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, +// config.value("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)).toBool()); +// s->setAttribute(QWebEngineSettings::TouchIconsEnabled, +// config.value("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, +// config.value("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)).toBool()); +// s->setAttribute(QWebEngineSettings::PrintElementBackgrounds, +// config.value("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)).toBool()); +// s->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, +// config.value("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)).toBool()); +// config.endGroup(); // attributes +} + +//void WebProfile::saveProfile(const QString &path) +//{ +// 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()); +// switch(httpCacheType()) { +// case MemoryHttpCache: +// config.setValue("cacheType", "memory"); +// break; +// case DiskHttpCache: +// config.setValue("cacheType", "disk"); +// break; +// case NoCache: +// config.setValue("cacheType", "disabled"); +// break; +// } +// config.setValue("cacheSize", httpCacheMaximumSize()); +// config.endGroup(); // http + +// config.beginGroup("policy"); +// switch(persistentCookiesPolicy()) { +// case NoPersistentCookies: +// config.setValue("cookies", "disabled"); +// break; +// case AllowPersistentCookies: +// config.setValue("cookies", "allow"); +// break; +// case ForcePersistentCookies: +// config.setValue("cookies", "force"); +// break; +// } +// config.endGroup(); // policy + +// QWebEngineSettings *s = settings(); +// config.beginGroup("attributes"); +// config.setValue("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)); +// config.setValue("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)); +// config.setValue("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)); +// config.setValue("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)); +// config.setValue("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)); +// config.setValue("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)); +// config.setValue("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)); +// config.setValue("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)); +// config.setValue("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)); +// config.setValue("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)); +// config.setValue("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)); +// config.setValue("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)); +// config.setValue("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)); +// config.setValue("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)); +// config.setValue("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)); +// config.setValue("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)); +// config.setValue("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)); +// config.setValue("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)); +// config.setValue("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)); +// config.setValue("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)); +//#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +// config.setValue("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)); +// config.setValue("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)); +// config.setValue("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)); +//#endif +// config.endGroup(); // attributes + +// config.sync(); +//} + +WebProfile::WebProfile(const QHash<QString, QString> &defaults, QObject *parent) : QWebEngineProfile(parent) { m_name = tr("Off-the-record"); @@ -23,7 +194,9 @@ WebProfile::WebProfile(QObject *parent) qDebug("Creating off-the-record profile"); #endif - // Off-the-record profiles have no persistent path + m_search = defaults.value("profile.search"); + m_homepage = QUrl::fromUserInput(defaults.value("profile.homepage")); + m_newtab = QUrl::fromUserInput(defaults.value("profile.newtab")); } WebProfile::WebProfile(const QString &name, QObject *parent) @@ -37,184 +210,3 @@ WebProfile::WebProfile(const QString &name, QObject *parent) } WebProfile::~WebProfile() = default; - -QString WebProfile::name() const -{ - return m_name; -} - -QUrl WebProfile::homepage() const -{ - return m_homepage; -} - -QUrl WebProfile::newtab() const -{ - return m_newtab; -} - -void WebProfile::loadProfile(QHash<QString, QString> conf) -{ - if(isOffTheRecord()) - m_configPath = conf.value("profile.path") + "/otr.ini"; - else - m_configPath = conf.value("profile.path") + "/" + storageName() + "/profile.ini"; - -#ifdef QT_DEBUG - qDebug("Reading config for profile '%s': %s", qUtf8Printable(m_name), qUtf8Printable(m_configPath)); -#endif - QSettings config(m_configPath, QSettings::IniFormat); - - m_search = config.value("search", conf.value("profile.search")).toString(); - m_homepage = config.value("homepage", conf["profile.homepage"]).toUrl(); - m_newtab = config.value("newtab", conf["profile.newtab"]).toUrl(); - - config.beginGroup("http"); - setHttpUserAgent(config.value("userAgent", httpUserAgent()).toString()); - setHttpAcceptLanguage(config.value("accept-lang", httpAcceptLanguage()).toString()); - { - QString cacheType = config.value("cacheType").toString(); - if(cacheType == "memory") { - setHttpCacheType(QWebEngineProfile::MemoryHttpCache); - } else if(cacheType == "disk") { - setHttpCacheType(QWebEngineProfile::DiskHttpCache); - } else if(cacheType == "disabled") { - setHttpCacheType(QWebEngineProfile::NoCache); - } - } - setHttpCacheMaximumSize(config.value("cacheSize", httpCacheMaximumSize()).toInt()); - config.endGroup(); // http - - config.beginGroup("policy"); - { - QString cookies = config.value("cookies").toString(); - if(cookies == "disabled") { - setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); - } else if(cookies == "allow") { - setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies); - } else if(cookies == "force") { - setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); - } - } - config.endGroup(); // policy - - config.beginGroup("attributes"); - QWebEngineSettings *s = settings(); - s->setAttribute(QWebEngineSettings::AutoLoadImages, - config.value("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)).toBool()); - s->setAttribute(QWebEngineSettings::JavascriptEnabled, - config.value("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, - config.value("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)).toBool()); - s->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, - config.value("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)).toBool()); - s->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, - config.value("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)).toBool()); - s->setAttribute(QWebEngineSettings::LocalStorageEnabled, - config.value("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, - config.value("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)).toBool()); - s->setAttribute(QWebEngineSettings::XSSAuditingEnabled, - config.value("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, - config.value("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, - config.value("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)).toBool()); - s->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, - config.value("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, - config.value("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::ErrorPageEnabled, - config.value("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::PluginsEnabled, - config.value("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, - config.value("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, - config.value("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::WebGLEnabled, - config.value("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, - config.value("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, - config.value("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)).toBool()); - s->setAttribute(QWebEngineSettings::TouchIconsEnabled, - config.value("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, - config.value("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)).toBool()); - s->setAttribute(QWebEngineSettings::PrintElementBackgrounds, - config.value("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)).toBool()); - s->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, - config.value("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)).toBool()); - config.endGroup(); // attributes -} - -void WebProfile::saveProfile(const QString &path) -{ - 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()); - switch(httpCacheType()) { - case MemoryHttpCache: - config.setValue("cacheType", "memory"); - break; - case DiskHttpCache: - config.setValue("cacheType", "disk"); - break; - case NoCache: - config.setValue("cacheType", "disabled"); - break; - } - config.setValue("cacheSize", httpCacheMaximumSize()); - config.endGroup(); // http - - config.beginGroup("policy"); - switch(persistentCookiesPolicy()) { - case NoPersistentCookies: - config.setValue("cookies", "disabled"); - break; - case AllowPersistentCookies: - config.setValue("cookies", "allow"); - break; - case ForcePersistentCookies: - config.setValue("cookies", "force"); - break; - } - config.endGroup(); // policy - - QWebEngineSettings *s = settings(); - config.beginGroup("attributes"); - config.setValue("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)); - config.setValue("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)); - config.setValue("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)); - config.setValue("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)); - config.setValue("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)); - config.setValue("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)); - config.setValue("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)); - config.setValue("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)); - config.setValue("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)); - config.setValue("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)); - config.setValue("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)); - config.setValue("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)); - config.setValue("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)); - config.setValue("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)); - config.setValue("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)); - config.setValue("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)); - config.setValue("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)); - config.setValue("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)); - config.setValue("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)); - config.setValue("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)); -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - config.setValue("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)); - config.setValue("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)); - config.setValue("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)); -#endif - config.endGroup(); // attributes - - config.sync(); -} diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h index ddb642c..e11d7c5 100644 --- a/src/webengine/webprofile.h +++ b/src/webengine/webprofile.h @@ -17,8 +17,14 @@ class WebProfile : public QWebEngineProfile { Q_OBJECT + + //Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath) + Q_PROPERTY(QString search READ search WRITE setSearch) + Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage) + Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab) + public: - explicit WebProfile(QObject *parent = nullptr); + explicit WebProfile(const QHash<QString, QString> &defaults, QObject *parent = nullptr); explicit WebProfile(const QString &name, QObject *parent = nullptr); ~WebProfile() override; @@ -34,13 +40,34 @@ public: return WebProfile::profile; } - QString name() const; + QString name() const + { + return m_name; + } QString search() const { return m_search; } - QUrl homepage() const; - QUrl newtab() const; + void setSearch(const QString &url) + { + m_search = url; + } + QUrl homepage() const + { + return m_homepage; + } + void setHomepage(const QUrl &url) + { + m_homepage = url; + } + QUrl newtab() const + { + return m_newtab; + } + void setNewtab(const QUrl &url) + { + m_newtab = url; + } void addBookmark(const QString &title, const QString &url) { @@ -51,18 +78,16 @@ public: signals: void addBookmarkRequested(const QString &title, const QString &url); -public slots: - void loadProfile(QHash<QString, QString> conf); - void saveProfile(const QString &path = QString()); - private: static WebProfile *profile; - QString m_configPath; QString m_name; QString m_search = QString("about:blank"); QUrl m_homepage = QUrl("about:blank"); QUrl m_newtab = QUrl("about:blank"); }; +void loadProfile(WebProfile *profile, const QString &path); +//WebProfile *saveProfile(const QString &path); + #endif // SMOLBOTE_WEBENGINEPROFILE_H |