Repository navigation
Expand file tree
/
Copy pathpreferencewindow.cpp
More file actions
248 lines (240 loc) · 13.1 KB
/
Copy pathpreferencewindow.cpp
File metadata and controls
248 lines (240 loc) · 13.1 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* Copyright 2011 Anand Bose <anandbose@in.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "preferencewindow.h"
#include "preferences.h"
#include <QtGui/QLabel>
PreferenceWindow::PreferenceWindow(Preferences *prefs)
{
preferences = prefs;
/* Home page tab */
/* Home Page */
homePageGroupBox = new QGroupBox(tr("Home page"),this);
showLastVisitedRadioButton = new QRadioButton(tr("Show last visited page"),this);
showHomePageRadioButton = new QRadioButton(tr("Show home page"),this);
homePageLabel = new QLabel(tr("Home page:"));
homePageUrlLineEdit = new QLineEdit;
//// selectHomePageTempleteButton = new QPushButton(tr("Select home page"));
homePageRadioButtonLayout = new QVBoxLayout;
homePageRadioButtonLayout->addWidget(showLastVisitedRadioButton);
homePageRadioButtonLayout->addWidget(showHomePageRadioButton);
homePageUrlLayout = new QHBoxLayout;
homePageUrlLayout->addWidget(homePageLabel);
homePageUrlLayout->addWidget(homePageUrlLineEdit);
// homePageUrlLayout->addWidget(selectHomePageTempleteButton);
homepageMainLayout = new QVBoxLayout;
homepageMainLayout->addLayout(homePageRadioButtonLayout);
homepageMainLayout->addLayout(homePageUrlLayout);
homepageMainLayout->addStretch();
homePageGroupBox->setLayout(homepageMainLayout);
tab1Layout = new QHBoxLayout;
tab1Layout->addWidget(homePageGroupBox);
page1 = new QWidget;
page1->setLayout(tab1Layout);
/* End of Home Page */
/* End of Home page tab */
/* Miscallaneous tab */
miscSettingsGroupBox = new QGroupBox(tr("Miscallaneous Settings"),this);
autoLoadImagesCheckBox = new QCheckBox(tr("Automatically load images"),this);
autoLoadImagesCheckBox->setToolTip(tr("Specifies whether images are automatically loaded in web pages."));
DnsPrefetchCheckBox = new QCheckBox(tr("Enable DNS prefetch"),this);
DnsPrefetchCheckBox->setToolTip(tr("Specifies whether QtWebkit will try to pre-fetch DNS entries to speed up browsing."));
EnableJavascriptCheckBox = new QCheckBox(tr("Enable Java Script"),this);
EnableJavascriptCheckBox->setToolTip(tr("Enables or disables the running of JavaScript programs."));
EnableJavaAppletsCheckBox = new QCheckBox(tr("Enable Java Applets"),this);
EnableJavaAppletsCheckBox->setToolTip(tr("Enables or disables Java applets."));
JavascriptCanOpenWindowsCheckBox = new QCheckBox(tr("Java script can open windows"),this);
JavascriptCanOpenWindowsCheckBox->setToolTip(tr("Specifies whether JavaScript programs can open new windows."));
JavascriptCanAccessClipboardCheckBox = new QCheckBox(tr("Java script can access ClipBoard"),this);
JavascriptCanAccessClipboardCheckBox->setToolTip(tr("Specifies whether JavaScript programs can read or write to the clipboard."));
EnableSpatialNavigationCheckBox = new QCheckBox(tr("Enable spatial navigation"),this);
EnableSpatialNavigationCheckBox->setToolTip(tr("Enables or disables the Spatial Navigation feature, which consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be trying to reach towards the right and which element he probably wants."));
PrintElementBackgroundsCheckBox = new QCheckBox(tr("Print element backgrounds"),this);
PrintElementBackgroundsCheckBox->setToolTip(tr("Specifies whether the background color and images are also drawn when the page is printed."));
LocalContentCanAccessFileUrlsCheckBox = new QCheckBox(tr("Local content can access files"),this);
LocalContentCanAccessFileUrlsCheckBox->setToolTip(tr("Specifies whether locally loaded documents are allowed to access remote urls."));
EnableXSSAuditingCheckBox = new QCheckBox(tr("Enable XSS Auditing"),this);
EnableXSSAuditingCheckBox->setToolTip(tr("Specifies whether load requests should be monitored for cross-site scripting attempts. Suspicious scripts will be blocked and reported in the inspector's JavaScript console. Enabling this feature might have an impact on performance and it is disabled by default."));
EnableAcceleratedCompositingCheckBox = new QCheckBox(tr("Enable acclerated compositing"),this);
EnableAcceleratedCompositingCheckBox->setToolTip(tr("This feature, when used in conjunction with QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and opacity properties will be rendered by composing the cached content of the animated elements."));
EnableSiteSpecificQuirksCheckBox = new QCheckBox(tr("Enable site specific quirks"),this);
EnableSiteSpecificQuirksCheckBox->setToolTip(tr("This setting enables WebKit's workaround for broken sites. It is enabled by default."));
miscTabLayout = new QVBoxLayout;
miscTabLayout->addWidget(autoLoadImagesCheckBox);
miscTabLayout->addWidget(DnsPrefetchCheckBox);
miscTabLayout->addWidget(EnableJavascriptCheckBox);
miscTabLayout->addWidget(EnableJavaAppletsCheckBox);
miscTabLayout->addWidget(JavascriptCanOpenWindowsCheckBox);
miscTabLayout->addWidget(JavascriptCanAccessClipboardCheckBox);
miscTabLayout->addWidget(EnableSpatialNavigationCheckBox);
miscTabLayout->addWidget(PrintElementBackgroundsCheckBox);
miscTabLayout->addWidget(LocalContentCanAccessFileUrlsCheckBox);
miscTabLayout->addWidget(EnableXSSAuditingCheckBox);
miscTabLayout->addWidget(EnableAcceleratedCompositingCheckBox);
miscTabLayout->addWidget(EnableSiteSpecificQuirksCheckBox);
miscTabLayout->addStretch();
miscSettingsGroupBox->setLayout(miscTabLayout);
tab2Layout = new QHBoxLayout;
tab2Layout->addWidget(miscSettingsGroupBox);
page2 = new QWidget;
page2->setLayout(tab2Layout);
/* End of Miscallaneous tab */
/* Network Tab */
proxyGroupBox = new QGroupBox(tr("Network proxy configuration"),this);
enableProxyCheckBox = new QCheckBox(tr("Enable Proxy"),this);
proxyHostNameLabel = new QLabel(tr("Proxy host name: "));
proxyHostNameEdit = new QLineEdit;
proxyPasswordLabel = new QLabel(tr("Password: "));
proxyPasswordEdit = new QLineEdit;
portLabel = new QLabel(tr("Port: "));
portSpinBox = new QSpinBox;
portSpinBox->setRange(0,10000);
proxyHostNameLayout = new QHBoxLayout;
proxyHostNameLayout->addWidget(proxyHostNameLabel);
proxyHostNameLayout->addWidget(proxyHostNameEdit);
proxyPasswordLayout = new QHBoxLayout;
proxyPasswordLayout->addWidget(proxyPasswordLabel);
proxyPasswordLayout->addWidget(proxyPasswordEdit);
proxyPortLayout = new QHBoxLayout;
proxyPortLayout->addWidget(portLabel);
proxyPortLayout->addWidget(portSpinBox);
proxyMainLayout = new QVBoxLayout;
proxyMainLayout->addWidget(enableProxyCheckBox);
proxyMainLayout->addLayout(proxyHostNameLayout);
proxyMainLayout->addLayout(proxyPasswordLayout);
proxyMainLayout->addLayout(proxyPortLayout);
proxyMainLayout->addStretch();
proxyGroupBox->setLayout(proxyMainLayout);
page3 = new QWidget;
tab3Layout = new QHBoxLayout;
tab3Layout->addWidget(proxyGroupBox);
page3->setLayout(tab3Layout);
/* End of Network Tab */
/* Setting up tabs */
mainTabWidget = new QTabWidget(this);
mainTabWidget->addTab(page1, tr("Home page"));
mainTabWidget->addTab(page2, tr("Miscallaneous"));
mainTabWidget->addTab(page3, tr("Network"));
/* Tabs set up */
mainLayout = new QVBoxLayout;
buttons = new QHBoxLayout;
applyButton = new QPushButton(tr("Apply"));
closeButton = new QPushButton(tr("Close"));
buttons->addWidget(applyButton);
buttons->addWidget(closeButton);
mainLayout->addWidget(mainTabWidget);
mainLayout->addLayout(buttons);
mainLayout->setContentsMargins(5,25,5,5);
setLayout(mainLayout);
setTitle(tr("WebRender Preferences"));
/* UI setup complete */
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
connect(applyButton,SIGNAL(clicked()), this, SLOT(on_applyButton_clicked()));
initialise();
}
void PreferenceWindow::initialise()
{
if(preferences->getSettingsFor(Preferences::LoadHomePageOnStartUp))
{
showHomePageRadioButton->setChecked(true);
showLastVisitedRadioButton->setChecked(false);
}
else
{
showHomePageRadioButton->setChecked(false);
showLastVisitedRadioButton->setChecked(true);
}
if(preferences->getSettingsFor(Preferences::LoadImages))
autoLoadImagesCheckBox->setCheckState(Qt::Checked);
else
autoLoadImagesCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::DnsPrefetch))
DnsPrefetchCheckBox->setCheckState(Qt::Checked);
else
DnsPrefetchCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::JavaScript))
EnableJavascriptCheckBox->setCheckState(Qt::Checked);
else
EnableJavascriptCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::JSApplet))
EnableJavaAppletsCheckBox->setCheckState(Qt::Checked);
else
EnableJavaAppletsCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::JScanOpenWindows))
JavascriptCanOpenWindowsCheckBox->setCheckState(Qt::Checked);
else
JavascriptCanOpenWindowsCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::JScanAccessclipboard))
JavascriptCanAccessClipboardCheckBox->setCheckState(Qt::Checked);
else
JavascriptCanAccessClipboardCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::SpatialNavigation))
EnableSpatialNavigationCheckBox->setCheckState(Qt::Checked);
else
EnableSpatialNavigationCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::PrintElementBG))
PrintElementBackgroundsCheckBox->setCheckState(Qt::Checked);
else
PrintElementBackgroundsCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::LocalContentAccess))
LocalContentCanAccessFileUrlsCheckBox->setCheckState(Qt::Checked);
else
LocalContentCanAccessFileUrlsCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::XSSAuditing))
EnableXSSAuditingCheckBox->setCheckState(Qt::Checked);
else
EnableXSSAuditingCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::AccleratedCompositing))
EnableAcceleratedCompositingCheckBox->setCheckState(Qt::Checked);
else
EnableAcceleratedCompositingCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::SiteSpecificQuirks))
EnableSiteSpecificQuirksCheckBox->setCheckState(Qt::Checked);
else
EnableSiteSpecificQuirksCheckBox->setCheckState(Qt::Unchecked);
if(preferences->getSettingsFor(Preferences::Proxy))
enableProxyCheckBox->setCheckState(Qt::Checked);
else
enableProxyCheckBox->setCheckState(Qt::Unchecked);
proxyHostNameEdit->setText(preferences->proxyHostName());
proxyPasswordEdit->setText(preferences->password());
portSpinBox->setValue(preferences->proxyPort());
homePageUrlLineEdit->setText(preferences->homePage());
}
void PreferenceWindow::on_applyButton_clicked()
{
preferences->setParameter(Preferences::LoadHomePageOnStartUp, !showLastVisitedRadioButton->isChecked());
preferences->setParameter(Preferences::LoadImages, (autoLoadImagesCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::DnsPrefetch,(DnsPrefetchCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::JavaScript,(EnableJavascriptCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::JSApplet,(EnableJavaAppletsCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::JScanOpenWindows,(JavascriptCanOpenWindowsCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::JScanAccessclipboard,(JavascriptCanAccessClipboardCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::SpatialNavigation,(EnableSpatialNavigationCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::PrintElementBG,(PrintElementBackgroundsCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::LocalContentAccess,(LocalContentCanAccessFileUrlsCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::XSSAuditing,(EnableXSSAuditingCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::AccleratedCompositing,(EnableAcceleratedCompositingCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::SiteSpecificQuirks,(EnableSiteSpecificQuirksCheckBox->checkState() == Qt::Checked));
preferences->setParameter(Preferences::Proxy,(enableProxyCheckBox->checkState() == Qt::Checked));
preferences->setHomePage(homePageUrlLineEdit->text());
preferences->setProxyPort(portSpinBox->value());
preferences->setProxyHostName(proxyHostNameEdit->text());
preferences->setPassword(proxyPasswordEdit->text());
emit settingsChanged();
}