aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ProfileEditor/CMakeLists.txt1
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.cpp21
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.h5
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp127
-rw-r--r--plugins/ProfileEditor/forms/profileview.h17
-rw-r--r--plugins/ProfileEditor/forms/profileview.ui109
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp17
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.h8
-rw-r--r--plugins/interfaces.h3
9 files changed, 227 insertions, 81 deletions
diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt
index 7ded842..fc7cf96 100644
--- a/plugins/ProfileEditor/CMakeLists.txt
+++ b/plugins/ProfileEditor/CMakeLists.txt
@@ -23,6 +23,7 @@ target_include_directories(ProfileEditorPlugin
target_link_libraries(ProfileEditorPlugin
PRIVATE Qt5::Widgets
PRIVATE Qt5::WebEngineWidgets
+ PRIVATE web
)
if(WIN32)
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
index 2f0f4a2..427330a 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
@@ -3,11 +3,11 @@
#include "ui_profilemanagerdialog.h"
#include <webprofile.h>
#include <QDir>
+#include <QPointer>
-ProfileManagerDialog::ProfileManagerDialog(QHash<QString, WebProfile *> *profiles, QWidget *parent)
+ProfileManagerDialog::ProfileManagerDialog(const QVector<WebProfile *> &profiles, QWidget *parent)
: QDialog(parent)
, ui(new Ui::ProfileManagerDialog)
- , profiles(profiles)
{
ui->setupUi(this);
@@ -18,8 +18,12 @@ ProfileManagerDialog::ProfileManagerDialog(QHash<QString, WebProfile *> *profile
deleteProfile(ui->listWidget->currentItem());
});
- for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) {
- ui->listWidget->addItem(i.key());
+ for(auto *profile : profiles) {
+ auto *item = new QListWidgetItem(ui->listWidget);
+ item->setText(profile->name());
+
+ auto pointer = QPointer<WebProfile>(profile);
+ item->setData(Qt::UserRole, QVariant::fromValue(pointer));
}
}
@@ -43,7 +47,8 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item)
}
ui->groupBox->setVisible(true);
- auto *v = new ProfileView(profiles->value(item->text()), this);
+ auto profile = item->data(Qt::UserRole).value<QPointer<WebProfile>>();
+ auto *v = new ProfileView(profile.data(), this);
ui->groupBox->layout()->addWidget(v);
v->adjustSize();
}
@@ -60,8 +65,8 @@ void ProfileManagerDialog::deleteProfile(QListWidgetItem *item)
delete i;
}
- auto *profile = profiles->value(item->text());
- Q_CHECK_PTR(profile);
+ auto profile = item->data(Qt::UserRole).value<QPointer<WebProfile>>();
+ Q_ASSERT(!profile.isNull());
qDebug("deleting profile %s", qUtf8Printable(profile->name()));
qDebug("deleting %s: %s", qUtf8Printable(profile->configurationPath()), QFile(profile->configurationPath()).remove() ? "okay" : "failed");
@@ -69,5 +74,5 @@ void ProfileManagerDialog::deleteProfile(QListWidgetItem *item)
qDebug("deleting %s: %s", qUtf8Printable(profile->cachePath()), QDir(profile->cachePath()).removeRecursively() ? "okay" : "failed");
delete item;
- delete profile;
+ delete profile.data();
}
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.h b/plugins/ProfileEditor/forms/profilemanagerdialog.h
index a4b6f83..e182799 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.h
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h
@@ -2,7 +2,7 @@
#define PROFILEMANAGERDIALOG_H
#include <QDialog>
-#include <QHash>
+#include <QVector>
namespace Ui
{
@@ -16,7 +16,7 @@ class ProfileManagerDialog : public QDialog
Q_OBJECT
public:
- explicit ProfileManagerDialog(QHash<QString, WebProfile *> *profiles, QWidget *parent = 0);
+ explicit ProfileManagerDialog(const QVector<WebProfile *> &profiles, QWidget *parent = 0);
~ProfileManagerDialog();
private slots:
@@ -25,7 +25,6 @@ private slots:
private:
Ui::ProfileManagerDialog *ui;
- const QHash<QString, WebProfile *> *profiles;
};
#endif // PROFILEMANAGERDIALOG_H
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index 2d96d43..f2e74ad 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -8,16 +8,20 @@
#include "profileview.h"
#include "ui_profileview.h"
+#include <webprofile.h>
#include <QWebEngineSettings>
+#include <QWebEngineCookieStore>
+#include <QDateTime>
inline void connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr)
{
+ checkBox->setChecked(settings->testAttribute(attr));
QObject::connect(checkBox, &QCheckBox::clicked, [settings, attr](bool checked) {
settings->setAttribute(attr, checked);
});
}
-ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent)
+ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
: QWidget(parent)
, ui(new Ui::ProfileView)
{
@@ -25,28 +29,58 @@ ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent)
m_profile = profile;
ui->setupUi(this);
- loadProfile();
+ // general tab
+ ui->name->setText(profile->name());
+ ui->offTheRecord->setChecked(profile->isOffTheRecord());
+ ui->configurationPath->setText(profile->configurationPath());
// http tab
+ ui->userAgent->setPlainText(m_profile->httpUserAgent());
connect(ui->userAgent, &QPlainTextEdit::textChanged, profile, [=]() {
profile->setHttpUserAgent(ui->userAgent->toPlainText());
});
+
+ ui->acceptLanguage->setPlainText(m_profile->httpAcceptLanguage());
connect(ui->acceptLanguage, &QPlainTextEdit::textChanged, profile, [=]() {
profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText());
});
+
+ ui->cacheType->setCurrentIndex(m_profile->httpCacheType());
connect(ui->cacheType, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
profile->setHttpCacheType(static_cast<QWebEngineProfile::HttpCacheType>(index));
});
+
+ ui->cacheSize->setText(QString::number(m_profile->httpCacheMaximumSize()));
connect(ui->cacheSize, &QLineEdit::textChanged, profile, [=](const QString &text) {
profile->setHttpCacheMaximumSize(text.toInt());
});
+
+ ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy());
connect(ui->cookiePolicy, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
profile->setPersistentCookiesPolicy(static_cast<QWebEngineProfile::PersistentCookiesPolicy>(index));
});
+
connect(ui->clearCache_pushButton, &QPushButton::clicked, profile, &QWebEngineProfile::clearHttpCache);
connect(ui->clearHistory_pushButton, &QPushButton::clicked, profile, &QWebEngineProfile::clearAllVisitedLinks);
- QWebEngineSettings *settings = m_profile->settings();
+ ui->storagePath_lineEdit->setText(m_profile->persistentStoragePath());
+ ui->cachePath_lineEdit->setText(m_profile->cachePath());
+
+ // settings tab
+ loadSettings(profile->settings());
+
+ // cookies tab
+ loadCookies(profile->cookieStore());
+}
+
+ProfileView::~ProfileView()
+{
+ delete ui;
+}
+
+void ProfileView::loadSettings(QWebEngineSettings *settings)
+{
+ // settings
connectSetting(ui->autoloadImages, settings, QWebEngineSettings::AutoLoadImages);
connectSetting(ui->autoloadIcons, settings, QWebEngineSettings::AutoLoadIconsForPage);
@@ -82,57 +116,48 @@ ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent)
connectSetting(ui->printElementBackgrounds, settings, QWebEngineSettings::PrintElementBackgrounds);
}
-ProfileView::~ProfileView()
+void ProfileView::loadCookies(QWebEngineCookieStore *store)
{
- delete ui;
-}
+ //
+ connect(store, &QWebEngineCookieStore::cookieAdded, this, &ProfileView::cookieAdded);
+ connect(store, &QWebEngineCookieStore::cookieRemoved, this, &ProfileView::cookieRemoved);
+
+ connect(ui->cookies_reload, &QPushButton::clicked, store, [=]() {
+ ui->cookies->clearContents();
+ ui->cookies->setRowCount(0);
+ store->loadAllCookies();
+ });
-void ProfileView::loadProfile()
-{
- if(m_profile->storageName().isEmpty())
- setWindowTitle(tr("Off-the-record"));
- else
- setWindowTitle(m_profile->storageName());
+ 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);
+ });
- // http
- ui->userAgent->setPlainText(m_profile->httpUserAgent());
- ui->acceptLanguage->setPlainText(m_profile->httpAcceptLanguage());
- ui->cacheType->setCurrentIndex(m_profile->httpCacheType());
- ui->cacheSize->setText(QString::number(m_profile->httpCacheMaximumSize()));
+}
- // path
- ui->storagePath_lineEdit->setText(m_profile->persistentStoragePath());
- ui->cachePath_lineEdit->setText(m_profile->cachePath());
+void ProfileView::cookieAdded(const QNetworkCookie &cookie)
+{
+ auto index = ui->cookies->rowCount();
+ ui->cookies->setRowCount(index + 1);
+
+ auto *item = new QTableWidgetItem(QString(cookie.name()));
+ item->setData(Qt::UserRole, QVariant::fromValue(cookie));
+ ui->cookies->setItem(index, 0, item);
+ ui->cookies->setItem(index, 1, new QTableWidgetItem(cookie.domain()));
+ ui->cookies->setItem(index, 2, new QTableWidgetItem(cookie.path()));
+ ui->cookies->setItem(index, 3, new QTableWidgetItem(cookie.expirationDate().toString(Qt::RFC2822Date)));
+}
- // settings
- QWebEngineSettings *settings = m_profile->settings();
- ui->autoloadImages->setChecked(settings->testAttribute(QWebEngineSettings::AutoLoadImages));
- ui->javascriptEnabled->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptEnabled));
- ui->javascriptCanOpenWindows->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows));
- ui->javascriptCanAccessClipboard->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard));
- ui->linksIncludedInFocusChain->setChecked(settings->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain));
- ui->localStorageEnabled->setChecked(settings->testAttribute(QWebEngineSettings::LocalStorageEnabled));
- ui->localContentCanAccessRemoteUrls->setChecked(settings->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls));
- ui->xssAuditingEnabled->setChecked(settings->testAttribute(QWebEngineSettings::XSSAuditingEnabled));
- ui->spatialNavigationEnabled->setChecked(settings->testAttribute(QWebEngineSettings::SpatialNavigationEnabled));
- ui->localContentCanAccessFileUrls->setChecked(settings->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls));
- ui->hyperlinkAuditingEnabled->setChecked(settings->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled));
- ui->scrollAnimatorEnabled->setChecked(settings->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled));
- ui->errorPagesEnabled->setChecked(settings->testAttribute(QWebEngineSettings::ErrorPageEnabled));
- ui->ppapiPluginsEnabled->setChecked(settings->testAttribute(QWebEngineSettings::PluginsEnabled));
- ui->fullscreenSupportEnabled->setChecked(settings->testAttribute(QWebEngineSettings::FullScreenSupportEnabled));
- ui->screenCaptureEnabled->setChecked(settings->testAttribute(QWebEngineSettings::ScreenCaptureEnabled));
- ui->webglEnabled->setChecked(settings->testAttribute(QWebEngineSettings::WebGLEnabled));
- ui->canvasEnabled->setChecked(settings->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled));
- ui->autoloadIcons->setChecked(settings->testAttribute(QWebEngineSettings::AutoLoadIconsForPage));
- ui->touchIconsEnabled->setChecked(settings->testAttribute(QWebEngineSettings::TouchIconsEnabled));
- ui->focusOnNavigationEnabled->setChecked(settings->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled));
- ui->printElementBackgrounds->setChecked(settings->testAttribute(QWebEngineSettings::PrintElementBackgrounds));
- ui->allowRunningInsecureContent->setChecked(settings->testAttribute(QWebEngineSettings::AllowRunningInsecureContent));
- ui->allowGeolocationOnInsecureContent->setChecked(settings->testAttribute(QWebEngineSettings::AllowGeolocationOnInsecureOrigins));
- ui->javascriptCanActivateWindows->setChecked(settings->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript));
- ui->showScrollBars->setChecked(settings->testAttribute(QWebEngineSettings::ShowScrollBars));
-
- // policy
- ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy());
+void ProfileView::cookieRemoved(const QNetworkCookie &cookie)
+{
+ for(int i = 0; i < ui->cookies->rowCount(); ++i) {
+ auto *item = ui->cookies->item(i, 0);
+ if(item->data(Qt::UserRole).value<QNetworkCookie>() == cookie) {
+ //qDebug("removing cookie on row %i", i);
+ ui->cookies->removeRow(i);
+ break;
+ }
+ }
}
+
diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h
index 6a8e8ab..6aa7c34 100644
--- a/plugins/ProfileEditor/forms/profileview.h
+++ b/plugins/ProfileEditor/forms/profileview.h
@@ -10,27 +10,34 @@
#define PROFILEDIALOG_H
#include <QWidget>
-#include <QWebEngineProfile>
+#include <QNetworkCookie>
namespace Ui
{
class ProfileView;
}
+class WebProfile;
+class QWebEngineSettings;
+class QWebEngineCookieStore;
class ProfileView : public QWidget
{
Q_OBJECT
public:
- explicit ProfileView(QWebEngineProfile *profile, QWidget *parent = nullptr);
+ explicit ProfileView(WebProfile *profile, QWidget *parent = nullptr);
~ProfileView() override;
-public slots:
- void loadProfile();
+private slots:
+ void loadSettings(QWebEngineSettings *settings);
+ void loadCookies(QWebEngineCookieStore *store);
+
+ void cookieAdded(const QNetworkCookie &cookie);
+ void cookieRemoved(const QNetworkCookie &cookie);
private:
Ui::ProfileView *ui;
- QWebEngineProfile *m_profile;
+ WebProfile *m_profile;
};
#endif // PROFILEDIALOG_H
diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui
index 2f6c889..c1507db 100644
--- a/plugins/ProfileEditor/forms/profileview.ui
+++ b/plugins/ProfileEditor/forms/profileview.ui
@@ -25,6 +25,51 @@
<property name="currentIndex">
<number>0</number>
</property>
+ <widget class="QWidget" name="generalTab">
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="name_label">
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="name">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="offTheRecord">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Off-the-record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="configurationPath">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="configurationPath_label">
+ <property name="text">
+ <string>Configuration</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
<widget class="QWidget" name="httpTab">
<attribute name="title">
<string>HTTP</string>
@@ -171,7 +216,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>276</width>
+ <width>584</width>
<height>855</height>
</rect>
</property>
@@ -413,6 +458,68 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="cookiesTab">
+ <attribute name="title">
+ <string>Cookies</string>
+ </attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTableWidget" name="cookies">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Domain</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Path</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Expires</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QPushButton" name="cookies_reload">
+ <property name="text">
+ <string>Reload</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cookies_delete">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index 2e7b261..d13e819 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -9,7 +9,7 @@
#include "profileeditorplugin.h"
#include "forms/profilemanagerdialog.h"
#include "forms/profileview.h"
-#include <QHash>
+#include <QVector>
#include <webprofile.h>
QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
@@ -22,23 +22,22 @@ QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
});
hash.insert("list-profiles", [this]() -> int {
- for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) {
- qDebug(" - %s", qUtf8Printable(i.key()));
+ for(const WebProfile *profile : qAsConst(profiles)) {
+ qDebug(" - %s", qUtf8Printable(profile->name()));
}
return 0;
});
return hash;
}
-void ProfileEditorPlugin::setProfiles(QHash<QString, WebProfile *> *profiles)
-{
- Q_CHECK_PTR(profiles);
- this->profiles = profiles;
-}
-
QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
{
auto *widget = new ProfileManagerDialog(profiles, parent);
widget->setAttribute(Qt::WA_DeleteOnClose, true);
return widget;
}
+
+void ProfileEditorPlugin::registerProfile(WebProfile *profile)
+{
+ profiles.append(profile);
+}
diff --git a/plugins/ProfileEditor/profileeditorplugin.h b/plugins/ProfileEditor/profileeditorplugin.h
index db82cfb..bc95708 100644
--- a/plugins/ProfileEditor/profileeditorplugin.h
+++ b/plugins/ProfileEditor/profileeditorplugin.h
@@ -9,7 +9,7 @@
#ifndef PROFILEEDITOR_PLUGIN_H
#define PROFILEEDITOR_PLUGIN_H
-#include <QHash>
+#include <QVector>
#include <interfaces.h>
class QWebEngineProfile;
@@ -25,11 +25,13 @@ public:
QHash<QString, std::function<int()>> commands() override;
// ProfileInterface
- void setProfiles(QHash<QString, WebProfile *> *profiles) override;
QDialog *createWidget(QWidget *parent) override;
+public slots:
+ void registerProfile(WebProfile *profile) override;
+
private:
- QHash<QString, WebProfile *> *profiles;
+ QVector<WebProfile *> profiles;
};
#endif //PROFILEEDITOR_PLUGIN_H
diff --git a/plugins/interfaces.h b/plugins/interfaces.h
index 1b653cd..67cd3c6 100644
--- a/plugins/interfaces.h
+++ b/plugins/interfaces.h
@@ -38,8 +38,9 @@ class ProfileInterface
{
public:
virtual ~ProfileInterface() = default;
- virtual void setProfiles(QHash<QString, WebProfile *> *profiles) = 0;
virtual QDialog *createWidget(QWidget *parent = nullptr) = 0;
+
+ virtual void registerProfile(WebProfile *profile) = 0;
};
#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface"