aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/web/webprofile.cpp14
-rw-r--r--lib/web/webprofile.h9
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp13
-rw-r--r--src/browser.h2
4 files changed, 33 insertions, 5 deletions
diff --git a/lib/web/webprofile.cpp b/lib/web/webprofile.cpp
index 37338b9..1124261 100644
--- a/lib/web/webprofile.cpp
+++ b/lib/web/webprofile.cpp
@@ -79,6 +79,13 @@ WebProfile::WebProfile(const QString &name, const QString &configPath, QObject *
#ifdef QT_DEBUG
qDebug("Creating otr profile %s", qUtf8Printable(m_name));
#endif
+
+ connect(this->cookieStore(), &QWebEngineCookieStore::cookieAdded, this, [this](const QNetworkCookie &cookie) {
+ m_cookies.append(cookie);
+ });
+ connect(this->cookieStore(), &QWebEngineCookieStore::cookieRemoved, this, [this](const QNetworkCookie &cookie) {
+ m_cookies.removeAll(cookie);
+ });
}
WebProfile::WebProfile(const QString &storageName, const QString &name, const QString &configPath, QObject *parent)
@@ -90,6 +97,13 @@ WebProfile::WebProfile(const QString &storageName, const QString &name, const QS
#ifdef QT_DEBUG
qDebug("Creating profile %s", qUtf8Printable(m_name));
#endif
+
+ connect(this->cookieStore(), &QWebEngineCookieStore::cookieAdded, this, [this](const QNetworkCookie &cookie) {
+ m_cookies.append(cookie);
+ });
+ connect(this->cookieStore(), &QWebEngineCookieStore::cookieRemoved, this, [this](const QNetworkCookie &cookie) {
+ m_cookies.removeAll(cookie);
+ });
}
QString WebProfile::search() const
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 9e9fd3e..279e6bf 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -13,6 +13,8 @@
#include <QUrl>
#include <QString>
#include <QWebEngineProfile>
+#include <QVector>
+#include <QNetworkCookie>
class WebProfile : public QWebEngineProfile
{
@@ -60,6 +62,11 @@ public:
return m_configPath;
}
+ const QVector<QNetworkCookie> cookies() const
+ {
+ return qAsConst(m_cookies);
+ }
+
// search url
QString search() const;
void setSearch(const QString &url);
@@ -103,6 +110,8 @@ private:
QString m_search = QString("about:blank");
QUrl m_homepage = QUrl("about:blank");
QUrl m_newtab = QUrl("about:blank");
+
+ QVector<QNetworkCookie> m_cookies;
};
WebProfile* loadProfile(const QString &name, const QHash<QString, QString> &defaults, const QString &path = QString(), QObject *parent = nullptr);
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index f2e74ad..7ab8d39 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -71,6 +71,9 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
// cookies tab
loadCookies(profile->cookieStore());
+ for(const auto &c : profile->cookies()) {
+ cookieAdded(c);
+ }
}
ProfileView::~ProfileView()
@@ -129,11 +132,13 @@ void ProfileView::loadCookies(QWebEngineCookieStore *store)
});
connect(ui->cookies_delete, &QPushButton::clicked, store, [=]() {
- auto index = ui->cookies->currentRow();
- auto cookie = ui->cookies->item(index, 0)->data(Qt::UserRole).value<QNetworkCookie>();
- store->deleteCookie(cookie);
+ for(auto *item : ui->cookies->selectedItems()) {
+ if(item->column() == 0) {
+ auto cookie = item->data(Qt::UserRole).value<QNetworkCookie>();
+ store->deleteCookie(cookie);
+ }
+ }
});
-
}
void ProfileView::cookieAdded(const QNetworkCookie &cookie)
diff --git a/src/browser.h b/src/browser.h
index 9e606dd..b727059 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -71,7 +71,7 @@ private:
std::shared_ptr<DownloadsWidget> m_downloads;
std::shared_ptr<UrlRequestInterceptor> m_urlFilter;
- QHash<QString, WebProfile*> m_profiles;
+ QMap<QString, WebProfile*> m_profiles;
QVector<MainWindow *> m_windows;
QVector<Plugin> m_plugins;
QHash<QString, std::function<int()>> m_commands;