aboutsummaryrefslogtreecommitdiff
path: root/src/forms/profileview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/forms/profileview.cpp')
-rw-r--r--src/forms/profileview.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/forms/profileview.cpp b/src/forms/profileview.cpp
new file mode 100644
index 0000000..9d2e9ed
--- /dev/null
+++ b/src/forms/profileview.cpp
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ **
+ ** smolbote: yet another qute browser
+ ** Copyright (C) 2017 Xian Nox
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **
+ ******************************************************************************/
+
+#include "profileview.h"
+#include "ui_profileview.h"
+
+#include <QLineEdit>
+#include <QPlainTextEdit>
+#include <QComboBox>
+#include <QPushButton>
+#include "webengine/webengineprofile.h"
+#include "forms/cookiesform.h"
+
+#include <QDialogButtonBox>
+
+ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::ProfileView)
+{
+ ui->setupUi(this);
+ setProfile(profile);
+
+ // actions
+ connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() {
+ this->_profile->clearHttpCache();
+ });
+ connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() {
+ this->_profile->clearAllVisitedLinks();
+ });
+
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(updateProfile()));
+}
+
+ProfileView::~ProfileView()
+{
+ delete ui;
+}
+
+void ProfileView::setProfile(WebEngineProfile *profile)
+{
+ if(!profile) {
+ return;
+ }
+
+ _profile = profile;
+ if(!_profile->storageName().isEmpty()) {
+ setWindowTitle(_profile->storageName());
+ } else {
+ setWindowTitle(tr("Off-the-record"));
+ }
+
+ m_cookiesForm = new CookiesForm(_profile->cookieStore(), this);
+ ui->tabWidget->addTab(m_cookiesForm, m_cookiesForm->windowTitle());
+
+ // 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());
+
+ // policy
+ ui->cookiePolicy->setCurrentIndex(_profile->persistentCookiesPolicy());
+}
+
+void ProfileView::showProfile()
+{
+ ui->tabWidget->setCurrentIndex(0);
+ show();
+}
+
+void ProfileView::showCookies()
+{
+ ui->tabWidget->setCurrentIndex(4);
+ show();
+}
+
+void ProfileView::updateProfile()
+{
+ 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;
+ }
+}