aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/web/profilemanager.cpp15
-rw-r--r--lib/web/webprofile.cpp23
-rw-r--r--lib/web/webprofile.h33
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp5
-rw-r--r--plugins/ProfileEditor/forms/profileview.ui8
5 files changed, 49 insertions, 35 deletions
diff --git a/lib/web/profilemanager.cpp b/lib/web/profilemanager.cpp
index b747bf6..960a03a 100644
--- a/lib/web/profilemanager.cpp
+++ b/lib/web/profilemanager.cpp
@@ -41,19 +41,22 @@ WebProfile *ProfileManager::loadProfile(const QString &path)
ptr->profile = new WebProfile(id, ptr->settings.value("name", id).toString(), nullptr);
}
Q_CHECK_PTR(ptr->profile);
+ connect(ptr->profile, &WebProfile::nameChanged, [this, id](const QString &name) {
+ this->m_profiles.at(id)->settings.setValue("name", name);
+ });
ptr->profile->setSearch(ptr->settings.value("search", defaults.value("profile.search")).toString());
- connect(ptr->profile, &WebProfile::searchChanged, &ptr->settings, [this, id](const QString &url) {
+ connect(ptr->profile, &WebProfile::searchChanged, [this, id](const QString &url) {
this->m_profiles.at(id)->settings.setValue("search", url);
});
ptr->profile->setHomepage(ptr->settings.value("homepage", defaults.value("profile.homepage")).toUrl());
- connect(ptr->profile, &WebProfile::homepageChanged, &ptr->settings, [this, id](const QUrl &url) {
+ connect(ptr->profile, &WebProfile::homepageChanged, [this, id](const QUrl &url) {
this->m_profiles.at(id)->settings.setValue("homepage", url);
});
ptr->profile->setNewtab(ptr->settings.value("newtab", defaults.value("profile.newtab")).toUrl());
- connect(ptr->profile, &WebProfile::newtabChanged, &ptr->settings, [this, id](const QUrl &url) {
+ connect(ptr->profile, &WebProfile::newtabChanged, [this, id](const QUrl &url) {
this->m_profiles.at(id)->settings.setValue("newtab", url);
});
@@ -65,6 +68,9 @@ WebProfile *ProfileManager::loadProfile(const QString &path)
}
}
ptr->settings.endGroup(); // properties
+ connect(ptr->profile, &WebProfile::propertyChanged, [this, id](const QString &property, const QVariant &value) {
+ this->m_profiles.at(id)->settings.setValue("properties/" + property, value);
+ });
ptr->settings.beginGroup("attributes");
{
@@ -76,6 +82,9 @@ WebProfile *ProfileManager::loadProfile(const QString &path)
}
}
ptr->settings.endGroup();
+ connect(ptr->profile, &WebProfile::attributeChanged, [this, id](const QWebEngineSettings::WebAttribute attr, const bool value) {
+ this->m_profiles.at(id)->settings.setValue("attributes/" + QString::number(attr), value);
+ });
m_profiles[id] = std::move(ptr);
return m_profiles.at(id)->profile;
diff --git a/lib/web/webprofile.cpp b/lib/web/webprofile.cpp
index d42bb26..4d31376 100644
--- a/lib/web/webprofile.cpp
+++ b/lib/web/webprofile.cpp
@@ -48,6 +48,17 @@ WebProfile::WebProfile(const QString &storageName, const QString &name, QObject
});
}
+const QString WebProfile::name() const
+{
+ return m_name;
+}
+
+void WebProfile::setName(const QString &name)
+{
+ m_name = name;
+ emit nameChanged(name);
+}
+
QString WebProfile::search() const
{
return m_search;
@@ -84,35 +95,35 @@ void WebProfile::setNewtab(const QUrl &url)
void WebProfile::setCachePath(const QString &path)
{
QWebEngineProfile::setCachePath(path);
- emit cachePathChanged(QWebEngineProfile::cachePath());
+ emit propertyChanged("cachePath", path);
}
void WebProfile::setPersistentStoragePath(const QString &path)
{
QWebEngineProfile::setPersistentStoragePath(path);
- emit persistentStoragePathChanged(QWebEngineProfile::persistentStoragePath());
+ emit propertyChanged("persistentStoragePath", path);
}
void WebProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
{
QWebEngineProfile::setHttpAcceptLanguage(httpAcceptLanguage);
- emit httpAcceptLanguageChanged(QWebEngineProfile::httpAcceptLanguage());
+ emit propertyChanged("httpAcceptLanguage", httpAcceptLanguage);
}
void WebProfile::setHttpCacheMaximumSize(int maxSize)
{
QWebEngineProfile::setHttpCacheMaximumSize(maxSize);
- emit httpCacheMaximumSizeChanged(QWebEngineProfile::httpCacheMaximumSize());
+ emit propertyChanged("httpCacheMaximumSize", maxSize);
}
void WebProfile::setHttpUserAgent(const QString &userAgent)
{
QWebEngineProfile::setHttpUserAgent(userAgent);
- emit httpUserAgentChanged(QWebEngineProfile::httpUserAgent());
+ emit propertyChanged("httpUserAgent", userAgent);
}
void WebProfile::setSpellCheckEnabled(bool enable)
{
QWebEngineProfile::setSpellCheckEnabled(enable);
- emit spellCheckEnabledChanged(QWebEngineProfile::isSpellCheckEnabled());
+ emit propertyChanged("spellCheckEnabed", enable);
}
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 260ff36..2282afe 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -16,24 +16,26 @@
#include <QVector>
#include <QNetworkCookie>
#include <QMap>
+#include <QWebEngineSettings>
class WebProfile : public QWebEngineProfile
{
Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString search READ search WRITE setSearch NOTIFY searchChanged)
Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab NOTIFY newtabChanged)
// QWebEngineProfile should-be properties
- Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged)
- Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged)
+ Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY propertyChanged)
+ Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY propertyChanged)
- Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged)
- Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged)
- Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged)
+ Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY propertyChanged)
+ Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY propertyChanged)
+ Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY propertyChanged)
- Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged)
+ Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY propertyChanged)
public:
// off-the-record constructor
@@ -54,10 +56,8 @@ public:
return WebProfile::profile;
}
- QString name() const
- {
- return m_name;
- }
+ const QString name() const;
+ void setName(const QString &name);
const QVector<QNetworkCookie> cookies() const
{
@@ -86,18 +86,13 @@ public:
void setSpellCheckEnabled(bool enable);
signals:
+ void nameChanged(const QString &name);
void searchChanged(const QString &url);
void homepageChanged(const QUrl &url);
void newtabChanged(const QUrl &url);
- void cachePathChanged(const QString &path);
- void persistentStoragePathChanged(const QString &path);
-
- void httpAcceptLanguageChanged(const QString &httpAcceptLanguage);
- void httpCacheMaximumSizeChanged(int maxSize);
- void httpUserAgentChanged(const QString &userAgent);
-
- void spellCheckEnabledChanged(bool enable);
+ void propertyChanged(const QString &name, const QVariant &value);
+ void attributeChanged(const QWebEngineSettings::WebAttribute attribute, const bool value);
private:
static WebProfile *profile;
@@ -110,6 +105,4 @@ private:
QVector<QNetworkCookie> m_cookies;
};
-//WebProfile *saveProfile(WebProfile *profile, const QString &path);
-
#endif // SMOLBOTE_WEBENGINEPROFILE_H
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index 2ffb119..caa9723 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -20,6 +20,7 @@ void ProfileView::connectSetting(QCheckBox *checkBox, QWebEngineSettings *settin
connect(checkBox, &QCheckBox::clicked, [this, settings, attr](bool checked) {
this->m_isChanged = true;
settings->setAttribute(attr, checked);
+ emit m_profile->attributeChanged(attr, checked);
});
}
@@ -33,6 +34,10 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
// general tab
ui->name->setText(profile->name());
+ connect(ui->name, &QLineEdit::editingFinished, profile, [=]() {
+ profile->setName(ui->name->text());
+ });
+
ui->offTheRecord->setChecked(profile->isOffTheRecord());
ui->homepage->setText(profile->homepage().toString());
diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui
index 2b25184..74b6d5d 100644
--- a/plugins/ProfileEditor/forms/profileview.ui
+++ b/plugins/ProfileEditor/forms/profileview.ui
@@ -38,11 +38,7 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QLineEdit" name="name">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
+ <widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="offTheRecord">
@@ -253,7 +249,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>584</width>
+ <width>276</width>
<height>855</height>
</rect>
</property>