aboutsummaryrefslogtreecommitdiff
path: root/plugins/ProfileEditor
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ProfileEditor')
-rw-r--r--plugins/ProfileEditor/CMakeLists.txt3
-rw-r--r--plugins/ProfileEditor/forms/newprofiledialog.cpp19
-rw-r--r--plugins/ProfileEditor/forms/newprofiledialog.h24
-rw-r--r--plugins/ProfileEditor/forms/newprofiledialog.ui78
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.cpp26
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.h7
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.ui3
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp15
-rw-r--r--plugins/ProfileEditor/forms/profileview.h9
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp5
10 files changed, 178 insertions, 11 deletions
diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt
index be65d8e..f294c30 100644
--- a/plugins/ProfileEditor/CMakeLists.txt
+++ b/plugins/ProfileEditor/CMakeLists.txt
@@ -14,6 +14,9 @@ add_library(ProfileEditorPlugin SHARED
forms/profilemanagerdialog.cpp
forms/profilemanagerdialog.h
forms/profilemanagerdialog.ui
+ forms/newprofiledialog.cpp
+ forms/newprofiledialog.h
+ forms/newprofiledialog.ui
)
target_include_directories(ProfileEditorPlugin
diff --git a/plugins/ProfileEditor/forms/newprofiledialog.cpp b/plugins/ProfileEditor/forms/newprofiledialog.cpp
new file mode 100644
index 0000000..04415de
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newprofiledialog.cpp
@@ -0,0 +1,19 @@
+#include "newprofiledialog.h"
+#include "ui_newprofiledialog.h"
+
+NewProfileDialog::NewProfileDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::NewProfileDialog)
+{
+ ui->setupUi(this);
+}
+
+NewProfileDialog::~NewProfileDialog()
+{
+ delete ui;
+}
+
+const QString NewProfileDialog::getId() const
+{
+ return ui->id_lineEdit->text();
+}
diff --git a/plugins/ProfileEditor/forms/newprofiledialog.h b/plugins/ProfileEditor/forms/newprofiledialog.h
new file mode 100644
index 0000000..6fa0a27
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newprofiledialog.h
@@ -0,0 +1,24 @@
+#ifndef NEWPROFILEDIALOG_H
+#define NEWPROFILEDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class NewProfileDialog;
+}
+
+class NewProfileDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit NewProfileDialog(QWidget *parent = nullptr);
+ ~NewProfileDialog();
+
+ const QString getId() const;
+
+private:
+ Ui::NewProfileDialog *ui;
+};
+
+#endif // NEWPROFILEDIALOG_H
diff --git a/plugins/ProfileEditor/forms/newprofiledialog.ui b/plugins/ProfileEditor/forms/newprofiledialog.ui
new file mode 100644
index 0000000..c46c3b3
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newprofiledialog.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewProfileDialog</class>
+ <widget class="QDialog" name="NewProfileDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>78</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>New Profile</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="id_label">
+ <property name="text">
+ <string>ID</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="id_lineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>NewProfileDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>NewProfileDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
index 427330a..dac4a61 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
@@ -4,6 +4,7 @@
#include <webprofile.h>
#include <QDir>
#include <QPointer>
+#include "newprofiledialog.h"
ProfileManagerDialog::ProfileManagerDialog(const QVector<WebProfile *> &profiles, QWidget *parent)
: QDialog(parent)
@@ -14,16 +15,20 @@ ProfileManagerDialog::ProfileManagerDialog(const QVector<WebProfile *> &profiles
connect(ui->listWidget, &QListWidget::itemPressed, this, &ProfileManagerDialog::showProfile);
showProfile(nullptr);
+ connect(ui->new_pushButton, &QPushButton::clicked, this, [=]() {
+ auto *profileDlg = new NewProfileDialog(this);
+ if(profileDlg->exec() == QDialog::Accepted) {
+ emit createProfile(profileDlg->getId());
+ }
+ delete profileDlg;
+ });
+
connect(ui->delete_pushButton, &QPushButton::clicked, this, [=]() {
deleteProfile(ui->listWidget->currentItem());
});
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));
+ addProfile(profile);
}
}
@@ -32,6 +37,17 @@ ProfileManagerDialog::~ProfileManagerDialog()
delete ui;
}
+void ProfileManagerDialog::addProfile(WebProfile *profile)
+{
+ Q_CHECK_PTR(profile);
+
+ auto *item = new QListWidgetItem(ui->listWidget);
+ item->setText(profile->name());
+
+ auto pointer = QPointer<WebProfile>(profile);
+ item->setData(Qt::UserRole, QVariant::fromValue(pointer));
+}
+
void ProfileManagerDialog::showProfile(QListWidgetItem *item)
{
// clear out groupbox layout
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.h b/plugins/ProfileEditor/forms/profilemanagerdialog.h
index e182799..4f468c5 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.h
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h
@@ -19,6 +19,13 @@ public:
explicit ProfileManagerDialog(const QVector<WebProfile *> &profiles, QWidget *parent = 0);
~ProfileManagerDialog();
+signals:
+ void createProfile(const QString &id);
+ void updateProfile(const QString &id);
+
+public slots:
+ void addProfile(WebProfile *profile);
+
private slots:
void showProfile(QListWidgetItem *item);
void deleteProfile(QListWidgetItem *item);
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.ui b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
index f7acdec..f41b1b0 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.ui
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
@@ -43,9 +43,6 @@
<layout class="QHBoxLayout" name="buttons_horizontalLayout">
<item>
<widget class="QPushButton" name="new_pushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>New</string>
</property>
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index 87546e5..85dde12 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -13,10 +13,11 @@
#include <QWebEngineCookieStore>
#include <QDateTime>
-inline void connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr)
+void ProfileView::connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr)
{
checkBox->setChecked(settings->testAttribute(attr));
- QObject::connect(checkBox, &QCheckBox::clicked, [settings, attr](bool checked) {
+ connect(checkBox, &QCheckBox::clicked, [this, settings, attr](bool checked) {
+ this->m_isChanged = true;
settings->setAttribute(attr, checked);
});
}
@@ -37,26 +38,31 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
// http tab
ui->userAgent->setPlainText(m_profile->httpUserAgent());
connect(ui->userAgent, &QPlainTextEdit::textChanged, profile, [=]() {
+ this->m_isChanged = true;
profile->setHttpUserAgent(ui->userAgent->toPlainText());
});
ui->acceptLanguage->setPlainText(m_profile->httpAcceptLanguage());
connect(ui->acceptLanguage, &QPlainTextEdit::textChanged, profile, [=]() {
+ this->m_isChanged = true;
profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText());
});
ui->cacheType->setCurrentIndex(m_profile->httpCacheType());
connect(ui->cacheType, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
+ this->m_isChanged = true;
profile->setHttpCacheType(static_cast<QWebEngineProfile::HttpCacheType>(index));
});
ui->cacheSize->setText(QString::number(m_profile->httpCacheMaximumSize()));
connect(ui->cacheSize, &QLineEdit::textChanged, profile, [=](const QString &text) {
+ this->m_isChanged = true;
profile->setHttpCacheMaximumSize(text.toInt());
});
ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy());
connect(ui->cookiePolicy, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) {
+ this->m_isChanged = true;
profile->setPersistentCookiesPolicy(static_cast<QWebEngineProfile::PersistentCookiesPolicy>(index));
});
@@ -81,6 +87,11 @@ ProfileView::~ProfileView()
delete ui;
}
+bool ProfileView::isChanged() const
+{
+ return m_isChanged;
+}
+
void ProfileView::loadSettings(QWebEngineSettings *settings)
{
// settings
diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h
index 6aa7c34..6c77982 100644
--- a/plugins/ProfileEditor/forms/profileview.h
+++ b/plugins/ProfileEditor/forms/profileview.h
@@ -11,6 +11,7 @@
#include <QWidget>
#include <QNetworkCookie>
+#include <QWebEngineSettings>
namespace Ui
{
@@ -18,8 +19,9 @@ class ProfileView;
}
class WebProfile;
-class QWebEngineSettings;
class QWebEngineCookieStore;
+class QCheckBox;
+
class ProfileView : public QWidget
{
Q_OBJECT
@@ -28,6 +30,8 @@ public:
explicit ProfileView(WebProfile *profile, QWidget *parent = nullptr);
~ProfileView() override;
+ bool isChanged() const;
+
private slots:
void loadSettings(QWebEngineSettings *settings);
void loadCookies(QWebEngineCookieStore *store);
@@ -38,6 +42,9 @@ private slots:
private:
Ui::ProfileView *ui;
WebProfile *m_profile;
+ bool m_isChanged = false;
+
+ void connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr);
};
#endif // PROFILEDIALOG_H
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index 5d5c18a..32b0b8d 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -28,5 +28,10 @@ QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
Q_CHECK_PTR(browser);
auto *widget = new ProfileManagerDialog(browser->profiles(), parent);
widget->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ connect(widget, &ProfileManagerDialog::createProfile, this, [=](const QString &id) {
+ auto newProfile = browser->loadProfile(id);
+ widget->addProfile(newProfile.second);
+ });
return widget;
}