KHtml

khtml_settings.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1999 David Faure <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "khtml_settings.h"
21 #include "khtmldefaults.h"
22 
23 #include <kparts/htmlsettingsinterface.h>
24 #include <kconfig.h>
25 #include <kconfiggroup.h>
26 #include "khtml_debug.h"
27 #include <klocalizedstring.h>
28 #include <kmessagebox.h>
29 #include <khtml_filter_p.h>
30 
31 #include <kjob.h>
32 #include <kio/job.h>
33 
34 #include <QFile>
35 #include <QFileInfo>
36 #include <QFontDatabase>
37 #include <QByteArray>
38 #include <QUrl>
39 #include <qstandardpaths.h>
40 #include <ksharedconfig.h>
41 
42 /**
43  * @internal
44  * Contains all settings which are both available globally and per-domain
45  */
46 struct KPerDomainSettings {
47  bool m_bEnableJava : 1;
48  bool m_bEnableJavaScript : 1;
49  bool m_bEnablePlugins : 1;
50  // don't forget to maintain the bitfields as the enums grow
51  KHTMLSettings::KJSWindowOpenPolicy m_windowOpenPolicy : 2;
52  KHTMLSettings::KJSWindowStatusPolicy m_windowStatusPolicy : 1;
53  KHTMLSettings::KJSWindowFocusPolicy m_windowFocusPolicy : 1;
54  KHTMLSettings::KJSWindowMovePolicy m_windowMovePolicy : 1;
55  KHTMLSettings::KJSWindowResizePolicy m_windowResizePolicy : 1;
56 
57 #ifdef DEBUG_SETTINGS
58  void dump(const QString &infix = QString()) const
59  {
60  // qCDebug(KHTML_LOG) << "KPerDomainSettings " << infix << " @" << this << ":";
61  // qCDebug(KHTML_LOG) << " m_bEnableJava: " << m_bEnableJava;
62  // qCDebug(KHTML_LOG) << " m_bEnableJavaScript: " << m_bEnableJavaScript;
63  // qCDebug(KHTML_LOG) << " m_bEnablePlugins: " << m_bEnablePlugins;
64  // qCDebug(KHTML_LOG) << " m_windowOpenPolicy: " << m_windowOpenPolicy;
65  // qCDebug(KHTML_LOG) << " m_windowStatusPolicy: " << m_windowStatusPolicy;
66  // qCDebug(KHTML_LOG) << " m_windowFocusPolicy: " << m_windowFocusPolicy;
67  // qCDebug(KHTML_LOG) << " m_windowMovePolicy: " << m_windowMovePolicy;
68  // qCDebug(KHTML_LOG) << " m_windowResizePolicy: " << m_windowResizePolicy;
69  }
70 #endif
71 };
72 
73 QString *KHTMLSettings::avFamilies = nullptr;
75 
76 // The "struct" that contains all the data. Must be copiable (no pointers).
77 class KHTMLSettingsData
78 {
79 public:
80  bool m_bChangeCursor : 1;
81  bool m_bOpenMiddleClick : 1;
82  bool m_underlineLink : 1;
83  bool m_hoverLink : 1;
84  bool m_bEnableJavaScriptDebug : 1;
85  bool m_bEnableJavaScriptErrorReporting : 1;
86  bool enforceCharset : 1;
87  bool m_bAutoLoadImages : 1;
88  bool m_bUnfinishedImageFrame : 1;
89  bool m_formCompletionEnabled : 1;
90  bool m_autoDelayedActionsEnabled : 1;
91  bool m_jsErrorsEnabled : 1;
92  bool m_follow_system_colors : 1;
93  bool m_allowTabulation : 1;
94  bool m_autoSpellCheck : 1;
95  bool m_adFilterEnabled : 1;
96  bool m_hideAdsEnabled : 1;
97  bool m_jsPopupBlockerPassivePopup : 1;
98  bool m_accessKeysEnabled : 1;
99 
100  // the virtual global "domain"
101  KPerDomainSettings global;
102 
103  int m_fontSize;
104  int m_minFontSize;
105  int m_maxFormCompletionItems;
106  KHTMLSettings::KAnimationAdvice m_showAnimations;
107  KHTMLSettings::KSmoothScrollingMode m_smoothScrolling;
108  KHTMLSettings::KDNSPrefetch m_dnsPrefetch;
109 
110  QString m_encoding;
111  QString m_userSheet;
112 
113  QColor m_textColor;
114  QColor m_baseColor;
115  QColor m_linkColor;
116  QColor m_vLinkColor;
117 
118  PolicyMap domainPolicy;
119  QStringList fonts;
120  QStringList defaultFonts;
121 
122  khtml::FilterSet adBlackList;
123  khtml::FilterSet adWhiteList;
124  QList< QPair< QString, QChar > > m_fallbackAccessKeysAssignments;
125 };
126 
127 class KHTMLSettingsPrivate : public QObject, public KHTMLSettingsData
128 {
129  Q_OBJECT
130 public:
131 
132  void adblockFilterLoadList(const QString &filename)
133  {
134  // qCDebug(KHTML_LOG) << "Loading filter list from" << filename;
135  /** load list file and process each line */
136  QFile file(filename);
137  if (file.open(QIODevice::ReadOnly)) {
138  QTextStream ts(&file);
139  QString line = ts.readLine();
140 #ifndef NDEBUG /// only count when compiled for debugging
141  int whiteCounter = 0, blackCounter = 0;
142 #endif // NDEBUG
143  while (!line.isEmpty()) {
144  /** white list lines start with "@@" */
145  if (line.startsWith(QLatin1String("@@"))) {
146 #ifndef NDEBUG
147  ++whiteCounter;
148 #endif // NDEBUG
149  adWhiteList.addFilter(line);
150  } else {
151 #ifndef NDEBUG
152  ++blackCounter;
153 #endif // NDEBUG
154  adBlackList.addFilter(line);
155  }
156 
157  line = ts.readLine();
158  }
159  file.close();
160 
161 #ifndef NDEBUG
162  // qCDebug(KHTML_LOG) << "Filter list loaded" << whiteCounter << "white list entries and" << blackCounter << "black list entries";
163 #endif // NDEBUG
164  }
165  }
166 
167 public Q_SLOTS:
168  void adblockFilterResult(KJob *job)
169  {
170  KIO::StoredTransferJob *tJob = qobject_cast<KIO::StoredTransferJob *>(job);
171  Q_ASSERT(tJob);
172 
173  if (tJob->error()) {
174  // qCDebug(KHTML_LOG) << "Failed to download" << tJob->url() << "with message:" << tJob->errorText();
175  } else if (tJob->isErrorPage()) { // 4XX error code
176  // qCDebug(KHTML_LOG) << "Failed to fetch filter list" << tJob->url();
177  } else {
178  const QByteArray byteArray = tJob->data();
179  const QString localFileName = tJob->property("khtmlsettings_adBlock_filename").toString();
180 
181  QFile file(localFileName);
182  if (file.open(QFile::WriteOnly)) {
183  bool success = file.write(byteArray) == byteArray.size();
184  file.close();
185  if (success) {
186  adblockFilterLoadList(localFileName);
187  } else {
188  // qCDebug(KHTML_LOG) << "Could not write" << byteArray.size() << "to file" << localFileName;
189  }
190  } else {
191  // qCDebug(KHTML_LOG) << "Cannot open file" << localFileName << "for filter list";
192  }
193  }
194 
195  }
196 };
197 
198 /** Returns a writeable per-domains settings instance for the given domain
199  * or a deep copy of the global settings if not existent.
200  */
201 static KPerDomainSettings &setup_per_domain_policy(
202  KHTMLSettingsPrivate *const d,
203  const QString &domain)
204 {
205  if (domain.isEmpty()) {
206  qCWarning(KHTML_LOG) << "setup_per_domain_policy: domain is empty";
207  }
208  const QString ldomain = domain.toLower();
209  PolicyMap::iterator it = d->domainPolicy.find(ldomain);
210  if (it == d->domainPolicy.end()) {
211  // simply copy global domain settings (they should have been initialized
212  // by this time)
213  it = d->domainPolicy.insert(ldomain, d->global);
214  }
215  return *it;
216 }
217 
218 KHTMLSettings::KJavaScriptAdvice KHTMLSettings::strToAdvice(const QString &_str)
219 {
220  return static_cast<KJavaScriptAdvice>(KParts::HtmlSettingsInterface::textToJavascriptAdvice(_str));
221 }
222 
223 const char *KHTMLSettings::adviceToStr(KJavaScriptAdvice _advice)
224 {
225  return KParts::HtmlSettingsInterface::javascriptAdviceToText(static_cast<KParts::HtmlSettingsInterface::JavaScriptAdvice>(_advice));
226 }
227 
228 void KHTMLSettings::splitDomainAdvice(const QString &configStr, QString &domain,
229  KJavaScriptAdvice &javaAdvice, KJavaScriptAdvice &javaScriptAdvice)
230 {
232  KParts::HtmlSettingsInterface::splitDomainAdvice(configStr, domain, jAdvice, jsAdvice);
233  javaAdvice = static_cast<KJavaScriptAdvice>(jAdvice);
234  javaScriptAdvice = static_cast<KJavaScriptAdvice>(jsAdvice);
235 }
236 
237 void KHTMLSettings::readDomainSettings(const KConfigGroup &config, bool reset,
238  bool global, KPerDomainSettings &pd_settings)
239 {
240  QString jsPrefix = global ? QString()
241  : QString::fromLatin1("javascript.");
242  QString javaPrefix = global ? QString()
243  : QString::fromLatin1("java.");
244  QString pluginsPrefix = global ? QString()
245  : QString::fromLatin1("plugins.");
246 
247  // The setting for Java
248  QString key = javaPrefix + QLatin1String("EnableJava");
249  if ((global && reset) || config.hasKey(key)) {
250  pd_settings.m_bEnableJava = config.readEntry(key, false);
251  } else if (!global) {
252  pd_settings.m_bEnableJava = d->global.m_bEnableJava;
253  }
254 
255  // The setting for Plugins
256  key = pluginsPrefix + QLatin1String("EnablePlugins");
257  if ((global && reset) || config.hasKey(key)) {
258  pd_settings.m_bEnablePlugins = config.readEntry(key, true);
259  } else if (!global) {
260  pd_settings.m_bEnablePlugins = d->global.m_bEnablePlugins;
261  }
262 
263  // The setting for JavaScript
264  key = jsPrefix + QLatin1String("EnableJavaScript");
265  if ((global && reset) || config.hasKey(key)) {
266  pd_settings.m_bEnableJavaScript = config.readEntry(key, true);
267  } else if (!global) {
268  pd_settings.m_bEnableJavaScript = d->global.m_bEnableJavaScript;
269  }
270 
271  // window property policies
272  key = jsPrefix + QLatin1String("WindowOpenPolicy");
273  if ((global && reset) || config.hasKey(key))
274  pd_settings.m_windowOpenPolicy = (KJSWindowOpenPolicy)
275  config.readEntry(key, uint(KJSWindowOpenSmart));
276  else if (!global) {
277  pd_settings.m_windowOpenPolicy = d->global.m_windowOpenPolicy;
278  }
279 
280  key = jsPrefix + QLatin1String("WindowMovePolicy");
281  if ((global && reset) || config.hasKey(key))
282  pd_settings.m_windowMovePolicy = (KJSWindowMovePolicy)
283  config.readEntry(key, uint(KJSWindowMoveAllow));
284  else if (!global) {
285  pd_settings.m_windowMovePolicy = d->global.m_windowMovePolicy;
286  }
287 
288  key = jsPrefix + QLatin1String("WindowResizePolicy");
289  if ((global && reset) || config.hasKey(key))
290  pd_settings.m_windowResizePolicy = (KJSWindowResizePolicy)
291  config.readEntry(key, uint(KJSWindowResizeAllow));
292  else if (!global) {
293  pd_settings.m_windowResizePolicy = d->global.m_windowResizePolicy;
294  }
295 
296  key = jsPrefix + QLatin1String("WindowStatusPolicy");
297  if ((global && reset) || config.hasKey(key))
298  pd_settings.m_windowStatusPolicy = (KJSWindowStatusPolicy)
299  config.readEntry(key, uint(KJSWindowStatusAllow));
300  else if (!global) {
301  pd_settings.m_windowStatusPolicy = d->global.m_windowStatusPolicy;
302  }
303 
304  key = jsPrefix + QLatin1String("WindowFocusPolicy");
305  if ((global && reset) || config.hasKey(key))
306  pd_settings.m_windowFocusPolicy = (KJSWindowFocusPolicy)
307  config.readEntry(key, uint(KJSWindowFocusAllow));
308  else if (!global) {
309  pd_settings.m_windowFocusPolicy = d->global.m_windowFocusPolicy;
310  }
311 
312 }
313 
315  : d(new KHTMLSettingsPrivate())
316 {
317  init();
318 }
319 
321  : d(new KHTMLSettingsPrivate())
322 {
323  KHTMLSettingsData *data = d;
324  *data = *other.d;
325 }
326 
328 {
329  delete d;
330 }
331 
332 bool KHTMLSettings::changeCursor() const
333 {
334  return d->m_bChangeCursor;
335 }
336 
337 bool KHTMLSettings::underlineLink() const
338 {
339  return d->m_underlineLink;
340 }
341 
342 bool KHTMLSettings::hoverLink() const
343 {
344  return d->m_hoverLink;
345 }
346 
348 {
349  KConfig global("khtmlrc", KConfig::NoGlobals);
350  init(&global, true);
351 
352  KSharedConfig::Ptr local = KSharedConfig::openConfig();
353  if (!local) {
354  return;
355  }
356 
357  init(local.data(), false);
358 }
359 
360 void KHTMLSettings::init(KConfig *config, bool reset)
361 {
362  KConfigGroup cg(config, "MainView Settings");
363  if (reset || cg.exists()) {
364  if (reset || cg.hasKey("OpenMiddleClick")) {
365  d->m_bOpenMiddleClick = cg.readEntry("OpenMiddleClick", true);
366  }
367  }
368 
369  KConfigGroup cgAccess(config, "Access Keys");
370  if (reset || cgAccess.exists()) {
371  d->m_accessKeysEnabled = cgAccess.readEntry("Enabled", true);
372  }
373 
374  KConfigGroup cgFilter(config, "Filter Settings");
375 
376  if (reset || cgFilter.exists()) {
377  d->m_adFilterEnabled = cgFilter.readEntry("Enabled", false);
378  d->m_hideAdsEnabled = cgFilter.readEntry("Shrink", false);
379 
380  d->adBlackList.clear();
381  d->adWhiteList.clear();
382 
383  if (d->m_adFilterEnabled) {
384 
385  /** read maximum age for filter list files, minimum is one day */
386  int htmlFilterListMaxAgeDays = cgFilter.readEntry(QString("HTMLFilterListMaxAgeDays")).toInt();
387  if (htmlFilterListMaxAgeDays < 1) {
388  htmlFilterListMaxAgeDays = 1;
389  }
390 
391  QMap<QString, QString> entryMap = cgFilter.entryMap();
393  for (it = entryMap.constBegin(); it != entryMap.constEnd(); ++it) {
394  int id = -1;
395  QString name = it.key();
396  QString url = it.value();
397 
398  if (name.startsWith("Filter")) {
399  if (url.startsWith(QLatin1String("@@"))) {
400  d->adWhiteList.addFilter(url);
401  } else {
402  d->adBlackList.addFilter(url);
403  }
404  } else if (name.startsWith("HTMLFilterListName-") && (id = name.mid(19).toInt()) > 0) {
405  /** check if entry is enabled */
406  bool filterEnabled = cgFilter.readEntry(QString("HTMLFilterListEnabled-").append(QString::number(id))) != QLatin1String("false");
407 
408  /** get url for HTMLFilterList */
409  QUrl url(cgFilter.readEntry(QString("HTMLFilterListURL-").append(QString::number(id))));
410 
411  if (filterEnabled && url.isValid()) {
412  /** determine where to cache HTMLFilterList file */
413  QString localFile = cgFilter.readEntry(QString("HTMLFilterListLocalFilename-").append(QString::number(id)));
414  localFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "khtml/" + localFile;
415 
416  /** determine existence and age of cache file */
417  QFileInfo fileInfo(localFile);
418 
419  /** load cached file if it exists, irrespective of age */
420  if (fileInfo.exists()) {
421  d->adblockFilterLoadList(localFile);
422  }
423 
424  /** if no cache list file exists or if it is too old ... */
425  if (!fileInfo.exists() || fileInfo.lastModified().daysTo(QDateTime::currentDateTime()) > htmlFilterListMaxAgeDays) {
426  /** ... in this case, refetch list asynchronously */
427  // qCDebug(KHTML_LOG) << "Asynchronously fetching filter list from" << url << "to" << localFile;
428 
429  KIO::StoredTransferJob *job = KIO::storedGet(url, KIO::Reload, KIO::HideProgressInfo);
430  QObject::connect(job, SIGNAL(result(KJob*)), d, SLOT(adblockFilterResult(KJob*)));
431  /** for later reference, store name of cache file */
432  job->setProperty("khtmlsettings_adBlock_filename", localFile);
433  }
434  }
435  }
436  }
437  }
438 
439  }
440 
441  KConfigGroup cgHtml(config, "HTML Settings");
442  if (reset || cgHtml.exists()) {
443  // Fonts and colors
444  if (reset) {
445  d->defaultFonts = QStringList();
446  d->defaultFonts.append(cgHtml.readEntry("StandardFont", QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()));
447  d->defaultFonts.append(cgHtml.readEntry("FixedFont", QFontDatabase::systemFont(QFontDatabase::FixedFont).family()));
448  // Resolve generic font family names
449  const QString serifFont = QFontInfo(QFont(QLatin1String(HTML_DEFAULT_VIEW_SERIF_FONT))).family();
450  const QString sansSerifFont = QFontInfo(QFont(QLatin1String(HTML_DEFAULT_VIEW_SANSSERIF_FONT))).family();
451  const QString cursiveFont = QFontInfo(QFont(QLatin1String(HTML_DEFAULT_VIEW_CURSIVE_FONT))).family();
452  const QString fantasyFont = QFontInfo(QFont(QLatin1String(HTML_DEFAULT_VIEW_FANTASY_FONT))).family();
453  d->defaultFonts.append(cgHtml.readEntry("SerifFont", serifFont));
454  d->defaultFonts.append(cgHtml.readEntry("SansSerifFont", sansSerifFont));
455  d->defaultFonts.append(cgHtml.readEntry("CursiveFont", cursiveFont));
456  d->defaultFonts.append(cgHtml.readEntry("FantasyFont", fantasyFont));
457  d->defaultFonts.append(QString("0")); // font size adjustment
458  }
459 
460  if (reset || cgHtml.hasKey("MinimumFontSize")) {
461  d->m_minFontSize = cgHtml.readEntry("MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE);
462  }
463 
464  if (reset || cgHtml.hasKey("MediumFontSize")) {
465  d->m_fontSize = cgHtml.readEntry("MediumFontSize", 12);
466  }
467 
468  d->fonts = cgHtml.readEntry("Fonts", QStringList());
469  const int fontsListLength = d->fonts.length();
470  // Resolve generic font family names
471  for (int i = 0; i < fontsListLength; ++i) {
472  const QString fontFamily = d->fonts.at(i);
473  if (!fontFamily.isEmpty()) {
474  d->fonts[i] = QFontInfo(QFont(fontFamily)).family();
475  //qCWarning(KHTML_LOG) << "Font family name:" << fontFamily << "resolved to:" << d->fonts.at(i);
476  }
477  }
478 
479  if (reset || cgHtml.hasKey("DefaultEncoding")) {
480  d->m_encoding = cgHtml.readEntry("DefaultEncoding", "");
481  }
482 
483  if (reset || cgHtml.hasKey("EnforceDefaultCharset")) {
484  d->enforceCharset = cgHtml.readEntry("EnforceDefaultCharset", false);
485  }
486 
487  // Behavior
488  if (reset || cgHtml.hasKey("ChangeCursor")) {
489  d->m_bChangeCursor = cgHtml.readEntry("ChangeCursor", true);
490  }
491 
492  if (reset || cgHtml.hasKey("UnderlineLinks")) {
493  d->m_underlineLink = cgHtml.readEntry("UnderlineLinks", true);
494  }
495 
496  if (reset || cgHtml.hasKey("HoverLinks")) {
497  if ((d->m_hoverLink = cgHtml.readEntry("HoverLinks", false))) {
498  d->m_underlineLink = false;
499  }
500  }
501 
502  if (reset || cgHtml.hasKey("AllowTabulation")) {
503  d->m_allowTabulation = cgHtml.readEntry("AllowTabulation", false);
504  }
505 
506  if (reset || cgHtml.hasKey("AutoSpellCheck")) {
507  d->m_autoSpellCheck = cgHtml.readEntry("AutoSpellCheck", true);
508  }
509 
510  // Other
511  if (reset || cgHtml.hasKey("AutoLoadImages")) {
512  d->m_bAutoLoadImages = cgHtml.readEntry("AutoLoadImages", true);
513  }
514 
515  if (reset || cgHtml.hasKey("UnfinishedImageFrame")) {
516  d->m_bUnfinishedImageFrame = cgHtml.readEntry("UnfinishedImageFrame", true);
517  }
518 
519  if (reset || cgHtml.hasKey("ShowAnimations")) {
520  QString value = cgHtml.readEntry("ShowAnimations").toLower();
521  if (value == "disabled") {
522  d->m_showAnimations = KAnimationDisabled;
523  } else if (value == "looponce") {
524  d->m_showAnimations = KAnimationLoopOnce;
525  } else {
526  d->m_showAnimations = KAnimationEnabled;
527  }
528  }
529 
530  if (reset || cgHtml.hasKey("SmoothScrolling")) {
531  QString value = cgHtml.readEntry("SmoothScrolling", "whenefficient").toLower();
532  if (value == "disabled") {
533  d->m_smoothScrolling = KSmoothScrollingDisabled;
534  } else if (value == "whenefficient") {
535  d->m_smoothScrolling = KSmoothScrollingWhenEfficient;
536  } else {
537  d->m_smoothScrolling = KSmoothScrollingEnabled;
538  }
539  }
540 
541  if (reset || cgHtml.hasKey("DNSPrefetch")) {
542  // Enabled, Disabled, OnlyWWWAndSLD
543  QString value = cgHtml.readEntry("DNSPrefetch", "Enabled").toLower();
544  if (value == "enabled") {
545  d->m_dnsPrefetch = KDNSPrefetchEnabled;
546  } else if (value == "onlywwwandsld") {
547  d->m_dnsPrefetch = KDNSPrefetchOnlyWWWAndSLD;
548  } else {
549  d->m_dnsPrefetch = KDNSPrefetchDisabled;
550  }
551  }
552 
553  if (cgHtml.readEntry("UserStyleSheetEnabled", false) == true) {
554  if (reset || cgHtml.hasKey("UserStyleSheet")) {
555  d->m_userSheet = cgHtml.readEntry("UserStyleSheet", "");
556  }
557  }
558 
559  d->m_formCompletionEnabled = cgHtml.readEntry("FormCompletion", true);
560  d->m_maxFormCompletionItems = cgHtml.readEntry("MaxFormCompletionItems", 10);
561  d->m_autoDelayedActionsEnabled = cgHtml.readEntry("AutoDelayedActions", true);
562  d->m_jsErrorsEnabled = cgHtml.readEntry("ReportJSErrors", true);
563  const QStringList accesskeys = cgHtml.readEntry("FallbackAccessKeysAssignments", QStringList());
564  d->m_fallbackAccessKeysAssignments.clear();
565  for (QStringList::ConstIterator it = accesskeys.begin(); it != accesskeys.end(); ++it)
566  if ((*it).length() > 2 && (*it)[ 1 ] == ':') {
567  d->m_fallbackAccessKeysAssignments.append(qMakePair((*it).mid(2), (*it)[ 0 ]));
568  }
569  }
570 
571  // Colors
572  //In which group ?????
573  if (reset || cg.hasKey("FollowSystemColors")) {
574  d->m_follow_system_colors = cg.readEntry("FollowSystemColors", false);
575  }
576 
577  KConfigGroup cgGeneral(config, "General");
578  if (reset || cgGeneral.exists()) {
579  if (reset || cgGeneral.hasKey("foreground")) {
580  QColor def(HTML_DEFAULT_TXT_COLOR);
581  d->m_textColor = cgGeneral.readEntry("foreground", def);
582  }
583 
584  if (reset || cgGeneral.hasKey("linkColor")) {
585  QColor def(HTML_DEFAULT_LNK_COLOR);
586  d->m_linkColor = cgGeneral.readEntry("linkColor", def);
587  }
588 
589  if (reset || cgGeneral.hasKey("visitedLinkColor")) {
590  QColor def(HTML_DEFAULT_VLNK_COLOR);
591  d->m_vLinkColor = cgGeneral.readEntry("visitedLinkColor", def);
592  }
593 
594  if (reset || cgGeneral.hasKey("background")) {
595  QColor def(HTML_DEFAULT_BASE_COLOR);
596  d->m_baseColor = cgGeneral.readEntry("background", def);
597  }
598  }
599 
600  KConfigGroup cgJava(config, "Java/JavaScript Settings");
601  if (reset || cgJava.exists()) {
602  // The global setting for JavaScript debugging
603  // This is currently always enabled by default
604  if (reset || cgJava.hasKey("EnableJavaScriptDebug")) {
605  d->m_bEnableJavaScriptDebug = cgJava.readEntry("EnableJavaScriptDebug", false);
606  }
607 
608  // The global setting for JavaScript error reporting
609  if (reset || cgJava.hasKey("ReportJavaScriptErrors")) {
610  d->m_bEnableJavaScriptErrorReporting = cgJava.readEntry("ReportJavaScriptErrors", false);
611  }
612 
613  // The global setting for popup block passive popup
614  if (reset || cgJava.hasKey("PopupBlockerPassivePopup")) {
615  d->m_jsPopupBlockerPassivePopup = cgJava.readEntry("PopupBlockerPassivePopup", true);
616  }
617 
618  // Read options from the global "domain"
619  readDomainSettings(cgJava, reset, true, d->global);
620 #ifdef DEBUG_SETTINGS
621  d->global.dump("init global");
622 #endif
623 
624  // The domain-specific settings.
625 
626  static const char *const domain_keys[] = { // always keep order of keys
627  "ECMADomains", "JavaDomains", "PluginDomains"
628  };
629  bool check_old_ecma_settings = true;
630  bool check_old_java_settings = true;
631  // merge all domains into one list
632  QMap<QString, int> domainList; // why can't Qt have a QSet?
633  for (unsigned i = 0; i < sizeof domain_keys / sizeof domain_keys[0]; ++i) {
634  if (reset || cgJava.hasKey(domain_keys[i])) {
635  if (i == 0) {
636  check_old_ecma_settings = false;
637  } else if (i == 1) {
638  check_old_java_settings = false;
639  }
640  const QStringList dl = cgJava.readEntry(domain_keys[i], QStringList());
641  const QMap<QString, int>::Iterator notfound = domainList.end();
643  const QStringList::ConstIterator itEnd = dl.end();
644  for (; it != itEnd; ++it) {
645  const QString domain = (*it).toLower();
646  QMap<QString, int>::Iterator pos = domainList.find(domain);
647  if (pos == notfound) {
648  domainList.insert(domain, 0);
649  }
650  }/*next it*/
651  }
652  }/*next i*/
653 
654  if (reset) {
655  d->domainPolicy.clear();
656  }
657 
658  {
660  const QMap<QString, int>::ConstIterator itEnd = domainList.constEnd();
661  for (; it != itEnd; ++it) {
662  const QString domain = it.key();
663  KConfigGroup cg(config, domain);
664  readDomainSettings(cg, reset, false, d->domainPolicy[domain]);
665 #ifdef DEBUG_SETTINGS
666  d->domainPolicy[domain].dump("init " + domain);
667 #endif
668  }
669  }
670 
671  bool check_old_java = true;
672  if ((reset || cgJava.hasKey("JavaDomainSettings"))
673  && check_old_java_settings) {
674  check_old_java = false;
675  const QStringList domainList = cgJava.readEntry("JavaDomainSettings", QStringList());
676  QStringList::ConstIterator it = domainList.constBegin();
677  const QStringList::ConstIterator itEnd = domainList.constEnd();
678  for (; it != itEnd; ++it) {
679  QString domain;
680  KJavaScriptAdvice javaAdvice;
681  KJavaScriptAdvice javaScriptAdvice;
682  splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
683  setup_per_domain_policy(d, domain).m_bEnableJava =
684  javaAdvice == KJavaScriptAccept;
685 #ifdef DEBUG_SETTINGS
686  setup_per_domain_policy(d, domain).dump("JavaDomainSettings 4 " + domain);
687 #endif
688  }
689  }
690 
691  bool check_old_ecma = true;
692  if ((reset || cgJava.hasKey("ECMADomainSettings"))
693  && check_old_ecma_settings) {
694  check_old_ecma = false;
695  const QStringList domainList = cgJava.readEntry("ECMADomainSettings", QStringList());
696  QStringList::ConstIterator it = domainList.constBegin();
697  const QStringList::ConstIterator itEnd = domainList.constEnd();
698  for (; it != itEnd; ++it) {
699  QString domain;
700  KJavaScriptAdvice javaAdvice;
701  KJavaScriptAdvice javaScriptAdvice;
702  splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
703  setup_per_domain_policy(d, domain).m_bEnableJavaScript =
704  javaScriptAdvice == KJavaScriptAccept;
705 #ifdef DEBUG_SETTINGS
706  setup_per_domain_policy(d, domain).dump("ECMADomainSettings 4 " + domain);
707 #endif
708  }
709  }
710 
711  if ((reset || cgJava.hasKey("JavaScriptDomainAdvice"))
712  && (check_old_java || check_old_ecma)
713  && (check_old_ecma_settings || check_old_java_settings)) {
714  const QStringList domainList = cgJava.readEntry("JavaScriptDomainAdvice", QStringList());
715  QStringList::ConstIterator it = domainList.constBegin();
716  const QStringList::ConstIterator itEnd = domainList.constEnd();
717  for (; it != itEnd; ++it) {
718  QString domain;
719  KJavaScriptAdvice javaAdvice;
720  KJavaScriptAdvice javaScriptAdvice;
721  splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
722  if (check_old_java)
723  setup_per_domain_policy(d, domain).m_bEnableJava =
724  javaAdvice == KJavaScriptAccept;
725  if (check_old_ecma)
726  setup_per_domain_policy(d, domain).m_bEnableJavaScript =
727  javaScriptAdvice == KJavaScriptAccept;
728 #ifdef DEBUG_SETTINGS
729  setup_per_domain_policy(d, domain).dump("JavaScriptDomainAdvice 4 " + domain);
730 #endif
731  }
732 
733  //save all the settings into the new keywords if they don't exist
734 #if 0
735  if (check_old_java) {
736  QStringList domainConfig;
738  for (it = d->javaDomainPolicy.begin(); it != d->javaDomainPolicy.end(); ++it) {
739  QByteArray javaPolicy = adviceToStr(it.value());
740  QByteArray javaScriptPolicy = adviceToStr(KJavaScriptDunno);
741  domainConfig.append(QString::fromLatin1("%1:%2:%3").arg(it.key()).arg(javaPolicy).arg(javaScriptPolicy));
742  }
743  cg.writeEntry("JavaDomainSettings", domainConfig);
744  }
745 
746  if (check_old_ecma) {
747  QStringList domainConfig;
749  for (it = d->javaScriptDomainPolicy.begin(); it != d->javaScriptDomainPolicy.end(); ++it) {
750  QByteArray javaPolicy = adviceToStr(KJavaScriptDunno);
751  QByteArray javaScriptPolicy = adviceToStr(it.value());
752  domainConfig.append(QString::fromLatin1("%1:%2:%3").arg(it.key()).arg(javaPolicy).arg(javaScriptPolicy));
753  }
754  cg.writeEntry("ECMADomainSettings", domainConfig);
755  }
756 #endif
757  }
758  }
759 }
760 
761 /** Local helper for retrieving per-domain settings.
762  *
763  * In case of doubt, the global domain is returned.
764  */
765 static const KPerDomainSettings &lookup_hostname_policy(
766  const KHTMLSettingsPrivate *const d,
767  const QString &hostname)
768 {
769 #ifdef DEBUG_SETTINGS
770  // qCDebug(KHTML_LOG) << "lookup_hostname_policy(" << hostname << ")";
771 #endif
772  if (hostname.isEmpty()) {
773 #ifdef DEBUG_SETTINGS
774  d->global.dump("global");
775 #endif
776  return d->global;
777  }
778 
779  const PolicyMap::const_iterator notfound = d->domainPolicy.constEnd();
780 
781  // First check whether there is a perfect match.
782  PolicyMap::const_iterator it = d->domainPolicy.find(hostname);
783  if (it != notfound) {
784 #ifdef DEBUG_SETTINGS
785  // qCDebug(KHTML_LOG) << "perfect match";
786  (*it).dump(hostname);
787 #endif
788  // yes, use it (unless dunno)
789  return *it;
790  }
791 
792  // Now, check for partial match. Chop host from the left until
793  // there's no dots left.
794  QString host_part = hostname;
795  int dot_idx = -1;
796  while ((dot_idx = host_part.indexOf(QChar('.'))) >= 0) {
797  host_part.remove(0, dot_idx);
798  it = d->domainPolicy.find(host_part);
799  Q_ASSERT(notfound == d->domainPolicy.end());
800  if (it != notfound) {
801 #ifdef DEBUG_SETTINGS
802  // qCDebug(KHTML_LOG) << "partial match";
803  (*it).dump(host_part);
804 #endif
805  return *it;
806  }
807  // assert(host_part[0] == QChar('.'));
808  host_part.remove(0, 1); // Chop off the dot.
809  }
810 
811  // No domain-specific entry: use global domain
812 #ifdef DEBUG_SETTINGS
813  // qCDebug(KHTML_LOG) << "no match";
814  d->global.dump("global");
815 #endif
816  return d->global;
817 }
818 
819 bool KHTMLSettings::isOpenMiddleClickEnabled()
820 {
821  return d->m_bOpenMiddleClick;
822 }
823 
825 {
826  return false; // ## the feature moved to konqueror
827 }
828 
829 bool KHTMLSettings::accessKeysEnabled() const
830 {
831  return d->m_accessKeysEnabled;
832 }
833 
834 bool KHTMLSettings::isAdFilterEnabled() const
835 {
836  return d->m_adFilterEnabled;
837 }
838 
839 bool KHTMLSettings::isHideAdsEnabled() const
840 {
841  return d->m_hideAdsEnabled;
842 }
843 
844 bool KHTMLSettings::isAdFiltered(const QString &url) const
845 {
846  if (d->m_adFilterEnabled) {
847  if (!url.startsWith("data:")) {
848  // Check the blacklist, and only if that matches, the whitelist
849  return d->adBlackList.isUrlMatched(url) && !d->adWhiteList.isUrlMatched(url);
850  }
851  }
852  return false;
853 }
854 
855 QString KHTMLSettings::adFilteredBy(const QString &url, bool *isWhiteListed) const
856 {
857  QString m = d->adWhiteList.urlMatchedBy(url);
858  if (!m.isEmpty()) {
859  if (isWhiteListed != nullptr) {
860  *isWhiteListed = true;
861  }
862  return (m);
863  }
864 
865  m = d->adBlackList.urlMatchedBy(url);
866  if (!m.isEmpty()) {
867  if (isWhiteListed != nullptr) {
868  *isWhiteListed = false;
869  }
870  return (m);
871  }
872 
873  return (QString());
874 }
875 
876 void KHTMLSettings::addAdFilter(const QString &url)
877 {
878  KConfigGroup config = KSharedConfig::openConfig("khtmlrc", KConfig::NoGlobals)->group("Filter Settings");
879 
880  QRegExp rx;
881 
882  // Try compiling to avoid invalid stuff. Only support the basic syntax here...
883  // ### refactor somewhat
884  if (url.length() > 2 && url[0] == '/' && url[url.length() - 1] == '/') {
885  QString inside = url.mid(1, url.length() - 2);
886  rx.setPattern(inside);
887  } else {
889  rx.setPattern(url);
890  }
891 
892  if (rx.isValid()) {
893  int last = config.readEntry("Count", 0);
894  QString key = "Filter-" + QString::number(last);
895  config.writeEntry(key, url);
896  config.writeEntry("Count", last + 1);
897  config.sync();
898  if (url.startsWith(QLatin1String("@@"))) {
899  d->adWhiteList.addFilter(url);
900  } else {
901  d->adBlackList.addFilter(url);
902  }
903  } else {
904  KMessageBox::error(nullptr,
905  rx.errorString(),
906  i18n("Filter error"));
907  }
908 }
909 
910 bool KHTMLSettings::isJavaEnabled(const QString &hostname) const
911 {
912  return lookup_hostname_policy(d, hostname.toLower()).m_bEnableJava;
913 }
914 
915 bool KHTMLSettings::isJavaScriptEnabled(const QString &hostname) const
916 {
917  return lookup_hostname_policy(d, hostname.toLower()).m_bEnableJavaScript;
918 }
919 
920 bool KHTMLSettings::isJavaScriptDebugEnabled(const QString & /*hostname*/) const
921 {
922  // debug setting is global for now, but could change in the future
923  return d->m_bEnableJavaScriptDebug;
924 }
925 
926 bool KHTMLSettings::isJavaScriptErrorReportingEnabled(const QString & /*hostname*/) const
927 {
928  // error reporting setting is global for now, but could change in the future
929  return d->m_bEnableJavaScriptErrorReporting;
930 }
931 
932 bool KHTMLSettings::isPluginsEnabled(const QString &hostname) const
933 {
934  return lookup_hostname_policy(d, hostname.toLower()).m_bEnablePlugins;
935 }
936 
937 KHTMLSettings::KJSWindowOpenPolicy KHTMLSettings::windowOpenPolicy(
938  const QString &hostname) const
939 {
940  return lookup_hostname_policy(d, hostname.toLower()).m_windowOpenPolicy;
941 }
942 
943 KHTMLSettings::KJSWindowMovePolicy KHTMLSettings::windowMovePolicy(
944  const QString &hostname) const
945 {
946  return lookup_hostname_policy(d, hostname.toLower()).m_windowMovePolicy;
947 }
948 
949 KHTMLSettings::KJSWindowResizePolicy KHTMLSettings::windowResizePolicy(
950  const QString &hostname) const
951 {
952  return lookup_hostname_policy(d, hostname.toLower()).m_windowResizePolicy;
953 }
954 
955 KHTMLSettings::KJSWindowStatusPolicy KHTMLSettings::windowStatusPolicy(
956  const QString &hostname) const
957 {
958  return lookup_hostname_policy(d, hostname.toLower()).m_windowStatusPolicy;
959 }
960 
961 KHTMLSettings::KJSWindowFocusPolicy KHTMLSettings::windowFocusPolicy(
962  const QString &hostname) const
963 {
964  return lookup_hostname_policy(d, hostname.toLower()).m_windowFocusPolicy;
965 }
966 
967 int KHTMLSettings::mediumFontSize() const
968 {
969  return d->m_fontSize;
970 }
971 
972 int KHTMLSettings::minFontSize() const
973 {
974  return d->m_minFontSize;
975 }
976 
977 QString KHTMLSettings::settingsToCSS() const
978 {
979  // lets start with the link properties
980  QString str = "a:link {\ncolor: ";
981  str += d->m_linkColor.name();
982  str += ';';
983  if (d->m_underlineLink) {
984  str += "\ntext-decoration: underline;";
985  }
986 
987  if (d->m_bChangeCursor) {
988  str += "\ncursor: pointer;";
989  str += "\n}\ninput[type=image] { cursor: pointer;";
990  }
991  str += "\n}\n";
992  str += "a:visited {\ncolor: ";
993  str += d->m_vLinkColor.name();
994  str += ';';
995  if (d->m_underlineLink) {
996  str += "\ntext-decoration: underline;";
997  }
998 
999  if (d->m_bChangeCursor) {
1000  str += "\ncursor: pointer;";
1001  }
1002  str += "\n}\n";
1003 
1004  if (d->m_hoverLink) {
1005  str += "a:link:hover, a:visited:hover { text-decoration: underline; }\n";
1006  }
1007 
1008  return str;
1009 }
1010 
1011 const QString &KHTMLSettings::availableFamilies()
1012 {
1013  if (!avFamilies) {
1014  avFamilies = new QString;
1015  QFontDatabase db;
1016  QStringList families = db.families();
1017  QStringList s;
1018  QRegExp foundryExp(" \\[.+\\]");
1019 
1020  //remove foundry info
1021  QStringList::Iterator f = families.begin();
1022  const QStringList::Iterator fEnd = families.end();
1023 
1024  for (; f != fEnd; ++f) {
1025  (*f).replace(foundryExp, "");
1026  if (!s.contains(*f)) {
1027  s << *f;
1028  }
1029  }
1030  s.sort();
1031 
1032  *avFamilies = ',' + s.join(",") + ',';
1033  }
1034 
1035  return *avFamilies;
1036 }
1037 
1038 QString KHTMLSettings::lookupFont(int i) const
1039 {
1040  QString font;
1041  if (d->fonts.count() > i) {
1042  font = d->fonts[i];
1043  }
1044  if (font.isEmpty()) {
1045  font = d->defaultFonts[i];
1046  }
1047  return font;
1048 }
1049 
1050 QString KHTMLSettings::stdFontName() const
1051 {
1052  return lookupFont(0);
1053 }
1054 
1055 QString KHTMLSettings::fixedFontName() const
1056 {
1057  return lookupFont(1);
1058 }
1059 
1060 QString KHTMLSettings::serifFontName() const
1061 {
1062  return lookupFont(2);
1063 }
1064 
1065 QString KHTMLSettings::sansSerifFontName() const
1066 {
1067  return lookupFont(3);
1068 }
1069 
1070 QString KHTMLSettings::cursiveFontName() const
1071 {
1072  return lookupFont(4);
1073 }
1074 
1075 QString KHTMLSettings::fantasyFontName() const
1076 {
1077  return lookupFont(5);
1078 }
1079 
1080 void KHTMLSettings::setStdFontName(const QString &n)
1081 {
1082  while (d->fonts.count() <= 0) {
1083  d->fonts.append(QString());
1084  }
1085  d->fonts[0] = n;
1086 }
1087 
1088 void KHTMLSettings::setFixedFontName(const QString &n)
1089 {
1090  while (d->fonts.count() <= 1) {
1091  d->fonts.append(QString());
1092  }
1093  d->fonts[1] = n;
1094 }
1095 
1096 QString KHTMLSettings::userStyleSheet() const
1097 {
1098  return d->m_userSheet;
1099 }
1100 
1101 bool KHTMLSettings::isFormCompletionEnabled() const
1102 {
1103  return d->m_formCompletionEnabled;
1104 }
1105 
1106 int KHTMLSettings::maxFormCompletionItems() const
1107 {
1108  return d->m_maxFormCompletionItems;
1109 }
1110 
1111 const QString &KHTMLSettings::encoding() const
1112 {
1113  return d->m_encoding;
1114 }
1115 
1116 bool KHTMLSettings::followSystemColors() const
1117 {
1118  return d->m_follow_system_colors;
1119 }
1120 
1121 const QColor &KHTMLSettings::textColor() const
1122 {
1123  return d->m_textColor;
1124 }
1125 
1126 const QColor &KHTMLSettings::baseColor() const
1127 {
1128  return d->m_baseColor;
1129 }
1130 
1131 const QColor &KHTMLSettings::linkColor() const
1132 {
1133  return d->m_linkColor;
1134 }
1135 
1136 const QColor &KHTMLSettings::vLinkColor() const
1137 {
1138  return d->m_vLinkColor;
1139 }
1140 
1141 bool KHTMLSettings::autoLoadImages() const
1142 {
1143  return d->m_bAutoLoadImages;
1144 }
1145 
1146 bool KHTMLSettings::unfinishedImageFrame() const
1147 {
1148  return d->m_bUnfinishedImageFrame;
1149 }
1150 
1151 KHTMLSettings::KAnimationAdvice KHTMLSettings::showAnimations() const
1152 {
1153  return d->m_showAnimations;
1154 }
1155 
1156 KHTMLSettings::KSmoothScrollingMode KHTMLSettings::smoothScrolling() const
1157 {
1158  return d->m_smoothScrolling;
1159 }
1160 
1161 KHTMLSettings::KDNSPrefetch KHTMLSettings::dnsPrefetch() const
1162 {
1163  return d->m_dnsPrefetch;
1164 }
1165 
1166 bool KHTMLSettings::isAutoDelayedActionsEnabled() const
1167 {
1168  return d->m_autoDelayedActionsEnabled;
1169 }
1170 
1171 bool KHTMLSettings::jsErrorsEnabled() const
1172 {
1173  return d->m_jsErrorsEnabled;
1174 }
1175 
1176 void KHTMLSettings::setJSErrorsEnabled(bool enabled)
1177 {
1178  d->m_jsErrorsEnabled = enabled;
1179  // save it
1180  KConfigGroup cg(KSharedConfig::openConfig(), "HTML Settings");
1181  cg.writeEntry("ReportJSErrors", enabled);
1182  cg.sync();
1183 }
1184 
1185 bool KHTMLSettings::allowTabulation() const
1186 {
1187  return d->m_allowTabulation;
1188 }
1189 
1190 bool KHTMLSettings::autoSpellCheck() const
1191 {
1192  return d->m_autoSpellCheck;
1193 }
1194 
1195 QList< QPair< QString, QChar > > KHTMLSettings::fallbackAccessKeysAssignments() const
1196 {
1197  return d->m_fallbackAccessKeysAssignments;
1198 }
1199 
1200 void KHTMLSettings::setJSPopupBlockerPassivePopup(bool enabled)
1201 {
1202  d->m_jsPopupBlockerPassivePopup = enabled;
1203  // save it
1204  KConfigGroup cg(KSharedConfig::openConfig(), "Java/JavaScript Settings");
1205  cg.writeEntry("PopupBlockerPassivePopup", enabled);
1206  cg.sync();
1207 }
1208 
1209 bool KHTMLSettings::jsPopupBlockerPassivePopup() const
1210 {
1211  return d->m_jsPopupBlockerPassivePopup;
1212 }
1213 
1214 #include "khtml_settings.moc"
Settings for the HTML view.
void setPatternSyntax(QRegExp::PatternSyntax syntax)
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
bool sync() override
QString writableLocation(QStandardPaths::StandardLocation type)
static void splitDomainAdvice(const QString &text, QString &domain, JavaScriptAdvice &javaAdvice, JavaScriptAdvice &javaScriptAdvice)
qint64 daysTo(const QDateTime &other) const const
QMap::const_iterator constBegin() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void readDomainSettings(const KConfigGroup &config, bool reset, bool global, KPerDomainSettings &pd_settings)
reads from config&#39;s current group, forcing initialization if reset is true.
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
QString join(const QString &separator) const const
QString & remove(int position, int n)
virtual ~KHTMLSettings()
Destructor.
QString adFilteredBy(const QString &url, bool *isWhiteListed=nullptr) const
identify the filter which matches url.
KJSWindowMovePolicy
This enum specifies the policy for window.moveBy and .moveTo.
QByteArray data() const
bool isErrorPage() const
void setPattern(const QString &pattern)
bool isBackRightClickEnabled()
QString number(int n, int base)
void append(const T &value)
bool exists() const
int toInt(bool *ok, int base) const const
bool isAdFiltered(const QString &url) const
tests whether url is filtered.
bool isEmpty() const const
QMap::const_iterator constEnd() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
typedef Iterator
QMap::iterator end()
QDateTime lastModified() const const
KJSWindowStatusPolicy
This enum specifies the policy for window.status and .defaultStatus.
QList::iterator end()
QString toLower() const const
QString family() const const
bool exists() const const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
bool hasKey(const QString &key) const
static JavaScriptAdvice textToJavascriptAdvice(const QString &text)
const Key key(const T &value, const Key &defaultKey) const const
QString i18n(const char *text, const TYPE &arg...)
QFont systemFont(QFontDatabase::SystemFont type)
QDateTime currentDateTime()
QString mid(int position, int n) const const
QStringList families(QFontDatabase::WritingSystem writingSystem) const const
QString family() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isValid() const const
typedef ConstIterator
int length() const const
QString errorString() const const
QString fromLatin1(const char *str, int size)
KJSWindowOpenPolicy
This enum specifies the policy for window.open.
void sort(Qt::CaseSensitivity cs)
static const char * javascriptAdviceToText(JavaScriptAdvice advice)
void init()
Called by constructor and reparseConfiguration.
QMap::iterator insert(const Key &key, const T &value)
QList::const_iterator constEnd() const const
QList::const_iterator constBegin() const const
KJavaScriptAdvice
This enum specifies whether Java/JavaScript execution is allowed.
int size() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
T readEntry(const QString &key, const T &aDefault) const
QMap::iterator find(const Key &key)
QList::iterator begin()
KJSWindowResizePolicy
This enum specifies the policy for window.resizeBy and .resizeTo.
QMap< QString, QString > entryMap() const
const T value(const Key &key, const T &defaultValue) const const
KJSWindowFocusPolicy
This enum specifies the policy for window.focus.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.