diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-01-13 14:51:25 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-01-13 14:51:25 +0100 |
commit | 0eb32befbc93a19103415e8e6f0805182ee02030 (patch) | |
tree | 8163fbdcc92e12ae6b7416af004f1164e0410db4 | |
parent | Profile config loading and saving (diff) | |
download | smolbote-0eb32befbc93a19103415e8e6f0805182ee02030.tar.xz |
Added all QtWebEngineProfile options to ProfileDialog
-rw-r--r-- | src/forms/profiledialog.cpp | 63 | ||||
-rw-r--r-- | src/forms/profiledialog.h | 2 | ||||
-rw-r--r-- | src/forms/profiledialog.ui | 212 |
3 files changed, 230 insertions, 47 deletions
diff --git a/src/forms/profiledialog.cpp b/src/forms/profiledialog.cpp index b485419..286d85c 100644 --- a/src/forms/profiledialog.cpp +++ b/src/forms/profiledialog.cpp @@ -2,6 +2,9 @@ #include "ui_profiledialog.h" #include <QLineEdit> +#include <QPlainTextEdit> +#include <QComboBox> +#include <QPushButton> ProfileDialog::ProfileDialog(QWebEngineProfile *profile, QWidget *parent) : QDialog(parent), @@ -10,11 +13,29 @@ ProfileDialog::ProfileDialog(QWebEngineProfile *profile, QWidget *parent) : _profile = profile; ui->setupUi(this); - ui->userAgent_lineEdit->setText(_profile->httpUserAgent()); + + // http + ui->userAgent->setPlainText(_profile->httpUserAgent()); + ui->acceptLanguage->setPlainText(_profile->httpAcceptLanguage()); + ui->cacheType->setCurrentIndex(_profile->httpCacheType()); + ui->cacheSize->setText(QString::number(_profile->httpCacheMaximumSize())); + + // path ui->storagePath_lineEdit->setText(_profile->persistentStoragePath()); ui->cachePath_lineEdit->setText(_profile->cachePath()); - connect(this, SIGNAL(accepted()), this, SLOT(saveProfile())); + // policy + ui->cookiePolicy->setCurrentIndex(_profile->persistentCookiesPolicy()); + + // actions + connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { + this->_profile->clearHttpCache(); + }); + connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() { + this->_profile->clearAllVisitedLinks(); + }); + + connect(this, SIGNAL(accepted()), this, SLOT(updateProfile())); } ProfileDialog::~ProfileDialog() @@ -22,8 +43,40 @@ ProfileDialog::~ProfileDialog() delete ui; } -void ProfileDialog::saveProfile() +void ProfileDialog::updateProfile() { - qDebug("Saving profile..."); - _profile->setHttpUserAgent(ui->userAgent_lineEdit->text()); + qDebug("Updating profile..."); + + // http + _profile->setHttpUserAgent(ui->userAgent->toPlainText()); + _profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText()); + switch (ui->cacheType->currentIndex()) { + case 0: + _profile->setHttpCacheType(QWebEngineProfile::MemoryHttpCache); + break; + case 1: + _profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); + break; + case 2: + _profile->setHttpCacheType(QWebEngineProfile::NoCache); + break; + default: + break; + } + _profile->setHttpCacheMaximumSize(ui->cacheSize->text().toInt()); + + // policy + switch (ui->cookiePolicy->currentIndex()) { + case 0: + _profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); + break; + case 1: + _profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies); + break; + case 2: + _profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); + break; + default: + break; + } } diff --git a/src/forms/profiledialog.h b/src/forms/profiledialog.h index 98426d0..c78f892 100644 --- a/src/forms/profiledialog.h +++ b/src/forms/profiledialog.h @@ -17,7 +17,7 @@ public: ~ProfileDialog(); private slots: - void saveProfile(); + void updateProfile(); private: QWebEngineProfile *_profile; diff --git a/src/forms/profiledialog.ui b/src/forms/profiledialog.ui index 097d9cb..528d672 100644 --- a/src/forms/profiledialog.ui +++ b/src/forms/profiledialog.ui @@ -11,50 +11,180 @@ </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Profile</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>User Agent</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="userAgent_lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Storage Path</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="storagePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Cache Path</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="cachePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="httpTab"> + <attribute name="title"> + <string>HTTP</string> + </attribute> + <layout class="QFormLayout" name="formLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>User Agent</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPlainTextEdit" name="userAgent"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Accept Language</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Cache Type</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Cache Size</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPlainTextEdit" name="acceptLanguage"/> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="cacheType"> + <item> + <property name="text"> + <string>Memory Cache</string> + </property> + </item> + <item> + <property name="text"> + <string>Disk Cache</string> + </property> + </item> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="cacheSize"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="pathTab"> + <attribute name="title"> + <string>Paths</string> + </attribute> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Storage Path</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="storagePath_lineEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Cache Path</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="cachePath_lineEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="policiesTab"> + <attribute name="title"> + <string>Policies</string> + </attribute> + <layout class="QFormLayout" name="formLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Cookies</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="cookiePolicy"> + <item> + <property name="text"> + <string>No Persistent Cookies</string> + </property> + </item> + <item> + <property name="text"> + <string>Allow Persistent Cookies</string> + </property> + </item> + <item> + <property name="text"> + <string>Force Persistent Cookies</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="actionsTab"> + <attribute name="title"> + <string>Actions</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="clearHistory_pushButton"> + <property name="text"> + <string>Clear History</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="clearCache_pushButton"> + <property name="text"> + <string>Clear Cache</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> + </widget> + </widget> </item> <item> <widget class="QDialogButtonBox" name="buttonBox"> |