1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/*******************************************************************************
**
** 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>
#include <QFormLayout>
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->m_profile->clearHttpCache();
});
connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() {
this->m_profile->clearAllVisitedLinks();
});
//connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(updateProfile()));
}
ProfileView::~ProfileView()
{
delete ui;
}
void ProfileView::setProfile(WebEngineProfile *profile)
{
if(!profile) {
return;
}
//Q_ASSERT(profile);
m_profile = profile;
setWindowTitle(m_profile->name());
m_cookiesForm = new CookiesForm(m_profile->cookieStore(), this);
//ui->tabWidget->addTab(m_cookiesForm, m_cookiesForm->windowTitle());
// general
ui->homepage_lineEdit->setText(m_profile->homepage().toString());
ui->newtab_lineEdit->setText(m_profile->newtab().toString());
// 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());
// policy
ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy());
//ui->formLayout_3->addWidget(m_cookiesForm);
ui->verticalLayout_3->addWidget(m_cookiesForm);
}
void ProfileView::showProfile()
{
ui->tabWidget->setCurrentIndex(0);
show();
}
void ProfileView::showCookies()
{
ui->tabWidget->setCurrentIndex(2);
show();
}
void ProfileView::updateProfile()
{
qDebug("Updating profile [%s]...", qUtf8Printable(m_profile->name()));
// general
m_profile->setHomepage(QUrl::fromUserInput(ui->homepage_lineEdit->text()));
m_profile->setNewtab(QUrl::fromUserInput(ui->newtab_lineEdit->text()));
// http
m_profile->setHttpUserAgent(ui->userAgent->toPlainText());
m_profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText());
switch (ui->cacheType->currentIndex()) {
case 0:
m_profile->setHttpCacheType(QWebEngineProfile::MemoryHttpCache);
break;
case 1:
m_profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
break;
case 2:
m_profile->setHttpCacheType(QWebEngineProfile::NoCache);
break;
default:
break;
}
m_profile->setHttpCacheMaximumSize(ui->cacheSize->text().toInt());
// policy
switch (ui->cookiePolicy->currentIndex()) {
case 0:
m_profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
break;
case 1:
m_profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
break;
case 2:
m_profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
break;
default:
break;
}
m_profile->saveProfile();
}
|