20 #include <tqfontdatabase.h>
22 #include "tdehtml_settings.h"
23 #include "tdehtmldefaults.h"
24 #include <tdeglobalsettings.h>
25 #include <tdeconfig.h>
26 #include <tdeglobal.h>
30 #include <tqvaluevector.h>
31 #include <tdemessagebox.h>
37 struct KPerDomainSettings {
38 bool m_bEnableJava : 1;
39 bool m_bEnableJavaScript : 1;
40 bool m_bEnablePlugins : 1;
49 void dump(
const TQString &infix = TQString::null)
const {
50 kdDebug() <<
"KPerDomainSettings " << infix <<
" @" <<
this <<
":" <<
endl;
51 kdDebug() <<
" m_bEnableJava: " << m_bEnableJava <<
endl;
52 kdDebug() <<
" m_bEnableJavaScript: " << m_bEnableJavaScript <<
endl;
53 kdDebug() <<
" m_bEnablePlugins: " << m_bEnablePlugins <<
endl;
54 kdDebug() <<
" m_windowOpenPolicy: " << m_windowOpenPolicy <<
endl;
55 kdDebug() <<
" m_windowStatusPolicy: " << m_windowStatusPolicy <<
endl;
56 kdDebug() <<
" m_windowFocusPolicy: " << m_windowFocusPolicy <<
endl;
57 kdDebug() <<
" m_windowMovePolicy: " << m_windowMovePolicy <<
endl;
58 kdDebug() <<
" m_windowResizePolicy: " << m_windowResizePolicy <<
endl;
63 typedef TQMap<TQString,KPerDomainSettings> PolicyMap;
65 class TDEHTMLSettingsPrivate
68 bool m_bChangeCursor : 1;
69 bool m_bOpenMiddleClick : 1;
70 bool m_bBackRightClick : 1;
71 bool m_underlineLink : 1;
73 bool m_bEnableJavaScriptDebug : 1;
74 bool m_bEnableJavaScriptErrorReporting : 1;
75 bool enforceCharset : 1;
76 bool m_bAutoLoadImages : 1;
77 bool m_bUnfinishedImageFrame : 1;
78 bool m_formCompletionEnabled : 1;
79 bool m_autoDelayedActionsEnabled : 1;
80 bool m_jsErrorsEnabled : 1;
81 bool m_follow_system_colors : 1;
82 bool m_allowTabulation : 1;
83 bool m_autoSpellCheck : 1;
84 bool m_adFilterEnabled : 1;
85 bool m_hideAdsEnabled : 1;
86 bool m_jsPopupBlockerPassivePopup : 1;
87 bool m_accessKeysEnabled : 1;
90 KPerDomainSettings global;
94 int m_maxFormCompletionItems;
95 TDEHTMLSettings::KAnimationAdvice m_showAnimations;
103 TQColor m_vLinkColor;
105 PolicyMap domainPolicy;
107 TQStringList defaultFonts;
109 TQValueVector<TQRegExp> adFilters;
110 TQValueList< TQPair< TQString, TQChar > > m_fallbackAccessKeysAssignments;
117 static KPerDomainSettings &setup_per_domain_policy(
118 TDEHTMLSettingsPrivate *d,
119 const TQString &domain) {
120 if (domain.isEmpty()) {
121 kdWarning() <<
"setup_per_domain_policy: domain is empty" <<
endl;
123 const TQString ldomain = domain.lower();
124 PolicyMap::iterator it = d->domainPolicy.find(ldomain);
125 if (it == d->domainPolicy.end()) {
128 it = d->domainPolicy.insert(ldomain,d->global);
139 ret = KJavaScriptDunno;
141 if (_str.lower() == TQString::fromLatin1(
"accept"))
142 ret = KJavaScriptAccept;
143 else if (_str.lower() == TQString::fromLatin1(
"reject"))
144 ret = KJavaScriptReject;
149 const char* TDEHTMLSettings::adviceToStr(KJavaScriptAdvice _advice)
152 case KJavaScriptAccept:
return I18N_NOOP(
"Accept");
153 case KJavaScriptReject:
return I18N_NOOP(
"Reject");
160 void TDEHTMLSettings::splitDomainAdvice(
const TQString& configStr, TQString &domain,
161 KJavaScriptAdvice &javaAdvice, KJavaScriptAdvice& javaScriptAdvice)
163 TQString tmp(configStr);
164 int splitIndex = tmp.find(
':');
165 if ( splitIndex == -1)
167 domain = configStr.lower();
168 javaAdvice = KJavaScriptDunno;
169 javaScriptAdvice = KJavaScriptDunno;
173 domain = tmp.left(splitIndex).lower();
174 TQString adviceString = tmp.mid( splitIndex+1, tmp.length() );
175 int splitIndex2 = adviceString.find(
':' );
176 if( splitIndex2 == -1 ) {
178 javaAdvice = strToAdvice( adviceString );
179 javaScriptAdvice = KJavaScriptDunno;
182 javaAdvice = strToAdvice( adviceString.left( splitIndex2 ) );
183 javaScriptAdvice = strToAdvice( adviceString.mid( splitIndex2+1,
184 adviceString.length() ) );
190 bool global, KPerDomainSettings &pd_settings) {
191 TQString jsPrefix = global ? TQString::null
192 : TQString::fromLatin1(
"javascript.");
193 TQString javaPrefix = global ? TQString::null
194 : TQString::fromLatin1(
"java.");
195 TQString pluginsPrefix = global ? TQString::null
196 : TQString::fromLatin1(
"plugins.");
199 TQString key = javaPrefix + TQString::fromLatin1(
"EnableJava");
200 if ( (global && reset) || config->
hasKey( key ) )
201 pd_settings.m_bEnableJava = config->
readBoolEntry( key,
false );
203 pd_settings.m_bEnableJava = d->global.m_bEnableJava;
206 key = pluginsPrefix + TQString::fromLatin1(
"EnablePlugins");
207 if ( (global && reset) || config->
hasKey( key ) )
208 pd_settings.m_bEnablePlugins = config->
readBoolEntry( key,
true );
210 pd_settings.m_bEnablePlugins = d->global.m_bEnablePlugins;
213 key = jsPrefix + TQString::fromLatin1(
"EnableJavaScript");
214 if ( (global && reset) || config->
hasKey( key ) )
215 pd_settings.m_bEnableJavaScript = config->
readBoolEntry( key,
true );
217 pd_settings.m_bEnableJavaScript = d->global.m_bEnableJavaScript;
220 key = jsPrefix + TQString::fromLatin1(
"WindowOpenPolicy");
221 if ( (global && reset) || config->
hasKey( key ) )
225 pd_settings.m_windowOpenPolicy = d->global.m_windowOpenPolicy;
227 key = jsPrefix + TQString::fromLatin1(
"WindowMovePolicy");
228 if ( (global && reset) || config->
hasKey( key ) )
232 pd_settings.m_windowMovePolicy = d->global.m_windowMovePolicy;
234 key = jsPrefix + TQString::fromLatin1(
"WindowResizePolicy");
235 if ( (global && reset) || config->
hasKey( key ) )
239 pd_settings.m_windowResizePolicy = d->global.m_windowResizePolicy;
241 key = jsPrefix + TQString::fromLatin1(
"WindowStatusPolicy");
242 if ( (global && reset) || config->
hasKey( key ) )
246 pd_settings.m_windowStatusPolicy = d->global.m_windowStatusPolicy;
248 key = jsPrefix + TQString::fromLatin1(
"WindowFocusPolicy");
249 if ( (global && reset) || config->
hasKey( key ) )
253 pd_settings.m_windowFocusPolicy = d->global.m_windowFocusPolicy;
258 TDEHTMLSettings::TDEHTMLSettings()
260 d =
new TDEHTMLSettingsPrivate();
266 d =
new TDEHTMLSettingsPrivate();
275 bool TDEHTMLSettings::changeCursor()
const
277 return d->m_bChangeCursor;
280 bool TDEHTMLSettings::underlineLink()
const
282 return d->m_underlineLink;
285 bool TDEHTMLSettings::hoverLink()
const
287 return d->m_hoverLink;
292 TDEConfig global(
"tdehtmlrc",
true,
false );
293 init( &global,
true );
299 init( local,
false );
304 TQString group_save = config->
group();
305 if (reset || config->
hasGroup(
"MainView Settings"))
307 config->
setGroup(
"MainView Settings" );
309 if ( reset || config->
hasKey(
"OpenMiddleClick" ) )
310 d->m_bOpenMiddleClick = config->
readBoolEntry(
"OpenMiddleClick",
true );
312 if ( reset || config->
hasKey(
"BackRightClick" ) )
313 d->m_bBackRightClick = config->
readBoolEntry(
"BackRightClick",
false );
316 if (reset || config->
hasGroup(
"Access Keys")) {
318 d->m_accessKeysEnabled = config->
readBoolEntry(
"Enabled",
true );
321 if (reset || config->
hasGroup(
"Filter Settings"))
323 config->
setGroup(
"Filter Settings" );
324 d->m_adFilterEnabled = config->
readBoolEntry(
"Enabled",
false);
325 d->m_hideAdsEnabled = config->
readBoolEntry(
"Shrink",
false);
327 d->adFilters.clear();
329 TQMap<TQString,TQString> entryMap = config->
entryMap(
"Filter Settings");
330 TQMap<TQString,TQString>::ConstIterator it;
331 d->adFilters.reserve(entryMap.count());
332 for( it = entryMap.constBegin(); it != entryMap.constEnd(); ++it )
334 TQString name = it.key();
335 TQString url = it.data();
337 if (url.startsWith(
"!"))
340 if (name.startsWith(
"Filter"))
342 if (url.length()>2 && url[0]==
'/' && url[url.length()-1] ==
'/')
344 TQString inside = url.mid(1, url.length()-2);
346 d->adFilters.append(rx);
353 for (right=url.length(); right>0 && url[right-1]==
'*' ; --right);
354 for (left=0; left<right && url[left]==
'*' ; ++left);
356 rx.setWildcard(
true);
357 rx.setPattern(url.mid(left,right-left));
359 d->adFilters.append(rx);
366 if (reset || config->
hasGroup(
"HTML Settings"))
368 config->
setGroup(
"HTML Settings" );
371 d->defaultFonts = TQStringList();
374 d->defaultFonts.append( config->
readEntry(
"SerifFont", HTML_DEFAULT_VIEW_SERIF_FONT ) );
375 d->defaultFonts.append( config->
readEntry(
"SansSerifFont", HTML_DEFAULT_VIEW_SANSSERIF_FONT ) );
376 d->defaultFonts.append( config->
readEntry(
"CursiveFont", HTML_DEFAULT_VIEW_CURSIVE_FONT ) );
377 d->defaultFonts.append( config->
readEntry(
"FantasyFont", HTML_DEFAULT_VIEW_FANTASY_FONT ) );
378 d->defaultFonts.append( TQString(
"0" ) );
381 if ( reset || config->
hasKey(
"MinimumFontSize" ) )
382 d->m_minFontSize = config->
readNumEntry(
"MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE );
384 if ( reset || config->
hasKey(
"MediumFontSize" ) )
385 d->m_fontSize = config->
readNumEntry(
"MediumFontSize", 12 );
389 if ( reset || config->
hasKey(
"DefaultEncoding" ) )
390 d->m_encoding = config->
readEntry(
"DefaultEncoding",
"" );
392 if ( reset || config->
hasKey(
"EnforceDefaultCharset" ) )
393 d->enforceCharset = config->
readBoolEntry(
"EnforceDefaultCharset",
false );
396 if ( reset || config->
hasKey(
"ChangeCursor" ) )
397 d->m_bChangeCursor = config->
readBoolEntry(
"ChangeCursor", KDE_DEFAULT_CHANGECURSOR );
399 if ( reset || config->
hasKey(
"UnderlineLinks") )
400 d->m_underlineLink = config->
readBoolEntry(
"UnderlineLinks",
true );
402 if ( reset || config->
hasKey(
"HoverLinks" ) )
404 if ( ( d->m_hoverLink = config->
readBoolEntry(
"HoverLinks",
false ) ) )
405 d->m_underlineLink =
false;
408 if ( reset || config->
hasKey(
"AllowTabulation" ) )
409 d->m_allowTabulation = config->
readBoolEntry(
"AllowTabulation",
false );
411 if ( reset || config->
hasKey(
"AutoSpellCheck" ) )
412 d->m_autoSpellCheck = config->
readBoolEntry(
"AutoSpellCheck",
true );
415 if ( reset || config->
hasKey(
"AutoLoadImages" ) )
416 d->m_bAutoLoadImages = config->
readBoolEntry(
"AutoLoadImages",
true );
418 if ( reset || config->
hasKey(
"UnfinishedImageFrame" ) )
419 d->m_bUnfinishedImageFrame = config->
readBoolEntry(
"UnfinishedImageFrame",
true );
421 if ( reset || config->
hasKey(
"ShowAnimations" ) )
423 TQString value = config->
readEntry(
"ShowAnimations").lower();
424 if (value ==
"disabled")
425 d->m_showAnimations = KAnimationDisabled;
426 else if (value ==
"looponce")
427 d->m_showAnimations = KAnimationLoopOnce;
429 d->m_showAnimations = KAnimationEnabled;
432 if ( config->
readBoolEntry(
"UserStyleSheetEnabled",
false ) ==
true ) {
433 if ( reset || config->
hasKey(
"UserStyleSheet" ) )
434 d->m_userSheet = config->
readEntry(
"UserStyleSheet",
"" );
437 d->m_formCompletionEnabled = config->
readBoolEntry(
"FormCompletion",
true);
438 d->m_maxFormCompletionItems = config->
readNumEntry(
"MaxFormCompletionItems", 10);
439 d->m_autoDelayedActionsEnabled = config->
readBoolEntry (
"AutoDelayedActions",
true);
440 d->m_jsErrorsEnabled = config->
readBoolEntry(
"ReportJSErrors",
true);
441 TQStringList accesskeys = config->
readListEntry(
"FallbackAccessKeysAssignments");
442 d->m_fallbackAccessKeysAssignments.clear();
443 for( TQStringList::ConstIterator it = accesskeys.begin(); it != accesskeys.end(); ++it )
444 if( (*it).length() > 2 && (*it)[ 1 ] ==
':' )
445 d->m_fallbackAccessKeysAssignments.append( qMakePair( (*it).mid( 2 ), (*it)[ 0 ] ));
450 if ( reset || config->
hasKey(
"FollowSystemColors" ) )
451 d->m_follow_system_colors = config->
readBoolEntry(
"FollowSystemColors",
false );
453 if ( reset || config->
hasGroup(
"General" ) )
456 if ( reset || config->
hasKey(
"foreground" ) )
457 d->m_textColor = config->
readColorEntry(
"foreground", &HTML_DEFAULT_TXT_COLOR );
459 if ( reset || config->
hasKey(
"linkColor" ) )
460 d->m_linkColor = config->
readColorEntry(
"linkColor", &HTML_DEFAULT_LNK_COLOR );
462 if ( reset || config->
hasKey(
"visitedLinkColor" ) )
463 d->m_vLinkColor = config->
readColorEntry(
"visitedLinkColor", &HTML_DEFAULT_VLNK_COLOR);
465 if ( reset || config->
hasKey(
"background" ) )
466 d->m_baseColor = config->
readColorEntry(
"background", &HTML_DEFAULT_BASE_COLOR);
469 if( reset || config->
hasGroup(
"Java/JavaScript Settings" ) )
471 config->
setGroup(
"Java/JavaScript Settings" );
475 if ( reset || config->
hasKey(
"EnableJavaScriptDebug" ) )
476 d->m_bEnableJavaScriptDebug = config->
readBoolEntry(
"EnableJavaScriptDebug",
false );
479 if ( reset || config->
hasKey(
"ReportJavaScriptErrors" ) )
480 d->m_bEnableJavaScriptErrorReporting = config->
readBoolEntry(
"ReportJavaScriptErrors",
false );
483 if ( reset || config->
hasKey(
"PopupBlockerPassivePopup" ) )
484 d->m_jsPopupBlockerPassivePopup = config->
readBoolEntry(
"PopupBlockerPassivePopup",
true);
488 #ifdef DEBUG_SETTINGS
489 d->global.dump(
"init global");
494 static const char *
const domain_keys[] = {
495 "ECMADomains",
"JavaDomains",
"PluginDomains"
497 bool check_old_ecma_settings =
true;
498 bool check_old_java_settings =
true;
500 TQMap<TQString,int> domainList;
501 for (
unsigned i = 0; i <
sizeof domain_keys/
sizeof domain_keys[0]; ++i) {
502 if ( reset || config->
hasKey(domain_keys[i]) ) {
503 if (i == 0) check_old_ecma_settings =
false;
504 else if (i == 1) check_old_java_settings =
false;
505 const TQStringList dl = config->
readListEntry( domain_keys[i] );
506 const TQMap<TQString,int>::Iterator notfound = domainList.end();
507 TQStringList::ConstIterator it = dl.begin();
508 const TQStringList::ConstIterator itEnd = dl.end();
509 for (; it != itEnd; ++it) {
510 const TQString domain = (*it).lower();
511 TQMap<TQString,int>::Iterator pos = domainList.find(domain);
512 if (pos == notfound) domainList.insert(domain,0);
518 d->domainPolicy.clear();
520 TQString js_group_save = config->
group();
522 TQMap<TQString,int>::ConstIterator it = domainList.begin();
523 const TQMap<TQString,int>::ConstIterator itEnd = domainList.end();
524 for ( ; it != itEnd; ++it)
526 const TQString domain = it.key();
529 #ifdef DEBUG_SETTINGS
530 d->domainPolicy[domain].dump(
"init "+domain);
536 bool check_old_java =
true;
537 if( ( reset || config->
hasKey(
"JavaDomainSettings" ) )
538 && check_old_java_settings )
540 check_old_java =
false;
541 const TQStringList domainList = config->
readListEntry(
"JavaDomainSettings" );
542 TQStringList::ConstIterator it = domainList.begin();
543 const TQStringList::ConstIterator itEnd = domainList.end();
544 for ( ; it != itEnd; ++it)
549 splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
550 setup_per_domain_policy(d,domain).m_bEnableJava =
551 javaAdvice == KJavaScriptAccept;
552 #ifdef DEBUG_SETTINGS
553 setup_per_domain_policy(d,domain).dump(
"JavaDomainSettings 4 "+domain);
558 bool check_old_ecma =
true;
559 if( ( reset || config->
hasKey(
"ECMADomainSettings" ) )
560 && check_old_ecma_settings )
562 check_old_ecma =
false;
563 const TQStringList domainList = config->
readListEntry(
"ECMADomainSettings" );
564 TQStringList::ConstIterator it = domainList.begin();
565 const TQStringList::ConstIterator itEnd = domainList.end();
566 for ( ; it != itEnd; ++it)
571 splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
572 setup_per_domain_policy(d,domain).m_bEnableJavaScript =
573 javaScriptAdvice == KJavaScriptAccept;
574 #ifdef DEBUG_SETTINGS
575 setup_per_domain_policy(d,domain).dump(
"ECMADomainSettings 4 "+domain);
580 if( ( reset || config->
hasKey(
"JavaScriptDomainAdvice" ) )
581 && ( check_old_java || check_old_ecma )
582 && ( check_old_ecma_settings || check_old_java_settings ) )
584 const TQStringList domainList = config->
readListEntry(
"JavaScriptDomainAdvice" );
585 TQStringList::ConstIterator it = domainList.begin();
586 const TQStringList::ConstIterator itEnd = domainList.end();
587 for ( ; it != itEnd; ++it)
592 splitDomainAdvice(*it, domain, javaAdvice, javaScriptAdvice);
594 setup_per_domain_policy(d,domain).m_bEnableJava =
595 javaAdvice == KJavaScriptAccept;
597 setup_per_domain_policy(d,domain).m_bEnableJavaScript =
598 javaScriptAdvice == KJavaScriptAccept;
599 #ifdef DEBUG_SETTINGS
600 setup_per_domain_policy(d,domain).dump(
"JavaScriptDomainAdvice 4 "+domain);
608 TQStringList domainConfig;
609 PolicyMap::Iterator it;
610 for( it = d->javaDomainPolicy.begin(); it != d->javaDomainPolicy.end(); ++it )
612 TQCString javaPolicy = adviceToStr( it.data() );
613 TQCString javaScriptPolicy = adviceToStr( KJavaScriptDunno );
614 domainConfig.append(TQString::fromLatin1(
"%1:%2:%3").arg(it.key()).arg(javaPolicy).arg(javaScriptPolicy));
616 config->
writeEntry(
"JavaDomainSettings", domainConfig );
621 TQStringList domainConfig;
622 PolicyMap::Iterator it;
623 for( it = d->javaScriptDomainPolicy.begin(); it != d->javaScriptDomainPolicy.end(); ++it )
625 TQCString javaPolicy = adviceToStr( KJavaScriptDunno );
626 TQCString javaScriptPolicy = adviceToStr( it.data() );
627 domainConfig.append(TQString::fromLatin1(
"%1:%2:%3").arg(it.key()).arg(javaPolicy).arg(javaScriptPolicy));
629 config->
writeEntry(
"ECMADomainSettings", domainConfig );
642 static const KPerDomainSettings &lookup_hostname_policy(
643 const TDEHTMLSettingsPrivate *d,
644 const TQString& hostname)
646 #ifdef DEBUG_SETTINGS
647 kdDebug() <<
"lookup_hostname_policy(" << hostname <<
")" <<
endl;
649 if (hostname.isEmpty()) {
650 #ifdef DEBUG_SETTINGS
651 d->global.dump(
"global");
656 const PolicyMap::const_iterator notfound = d->domainPolicy.end();
659 PolicyMap::const_iterator it = d->domainPolicy.find(hostname);
660 if( it != notfound ) {
661 #ifdef DEBUG_SETTINGS
663 (*it).dump(hostname);
671 TQString host_part = hostname;
673 while( (dot_idx = host_part.find(TQChar(
'.'))) >= 0 ) {
674 host_part.remove(0,dot_idx);
675 it = d->domainPolicy.find(host_part);
676 Q_ASSERT(notfound == d->domainPolicy.end());
677 if( it != notfound ) {
678 #ifdef DEBUG_SETTINGS
680 (*it).dump(host_part);
685 host_part.remove(0,1);
689 #ifdef DEBUG_SETTINGS
691 d->global.dump(
"global");
696 bool TDEHTMLSettings::isOpenMiddleClickEnabled()
698 return d->m_bOpenMiddleClick;
701 bool TDEHTMLSettings::isBackRightClickEnabled()
703 return d->m_bBackRightClick;
706 bool TDEHTMLSettings::accessKeysEnabled()
const
708 return d->m_accessKeysEnabled;
711 bool TDEHTMLSettings::isAdFilterEnabled()
const
713 return d->m_adFilterEnabled;
716 bool TDEHTMLSettings::isHideAdsEnabled()
const
718 return d->m_hideAdsEnabled;
721 bool TDEHTMLSettings::isAdFiltered(
const TQString &url )
const
723 if (d->m_adFilterEnabled)
725 if (!url.startsWith(
"data:"))
727 TQValueVector<TQRegExp>::const_iterator it(d->adFilters.constBegin());
728 TQValueVector<TQRegExp>::const_iterator
end(d->adFilters.constEnd());
729 for (; it !=
end; ++it)
731 if ((*it).search(url) != -1)
742 void TDEHTMLSettings::addAdFilter(
const TQString &url )
744 TDEConfig config(
"tdehtmlrc",
false,
false );
745 config.setGroup(
"Filter Settings" );
748 if (url.length()>2 && url[0]==
'/' && url[url.length()-1] ==
'/')
750 TQString inside = url.mid(1, url.length()-2);
751 rx.setWildcard(
false);
752 rx.setPattern(inside);
758 rx.setWildcard(
true);
759 for (right=url.length(); right>0 && url[right-1]==
'*' ; --right);
760 for (left=0; left<right && url[left]==
'*' ; ++left);
762 rx.setPattern(url.mid(left,right-left));
767 int last=config.readNumEntry(
"Count",0);
768 TQString
key =
"Filter-" + TQString::number(last);
769 config.writeEntry(key, url);
770 config.writeEntry(
"Count",last+1);
773 d->adFilters.append(rx);
779 i18n(
"Filter error"));
783 bool TDEHTMLSettings::isJavaEnabled(
const TQString& hostname )
785 return lookup_hostname_policy(d,hostname.lower()).m_bEnableJava;
788 bool TDEHTMLSettings::isJavaScriptEnabled(
const TQString& hostname )
790 return lookup_hostname_policy(d,hostname.lower()).m_bEnableJavaScript;
793 bool TDEHTMLSettings::isJavaScriptDebugEnabled(
const TQString& )
796 return d->m_bEnableJavaScriptDebug;
799 bool TDEHTMLSettings::isJavaScriptErrorReportingEnabled(
const TQString& )
const
802 return d->m_bEnableJavaScriptErrorReporting;
805 bool TDEHTMLSettings::isPluginsEnabled(
const TQString& hostname )
807 return lookup_hostname_policy(d,hostname.lower()).m_bEnablePlugins;
811 const TQString& hostname)
const {
812 return lookup_hostname_policy(d,hostname.lower()).m_windowOpenPolicy;
816 const TQString& hostname)
const {
817 return lookup_hostname_policy(d,hostname.lower()).m_windowMovePolicy;
821 const TQString& hostname)
const {
822 return lookup_hostname_policy(d,hostname.lower()).m_windowResizePolicy;
826 const TQString& hostname)
const {
827 return lookup_hostname_policy(d,hostname.lower()).m_windowStatusPolicy;
831 const TQString& hostname)
const {
832 return lookup_hostname_policy(d,hostname.lower()).m_windowFocusPolicy;
835 int TDEHTMLSettings::mediumFontSize()
const
837 return d->m_fontSize;
840 int TDEHTMLSettings::minFontSize()
const
842 return d->m_minFontSize;
845 TQString TDEHTMLSettings::settingsToCSS()
const
848 TQString str =
"a:link {\ncolor: ";
849 str += d->m_linkColor.name();
851 if(d->m_underlineLink)
852 str +=
"\ntext-decoration: underline;";
854 if( d->m_bChangeCursor )
856 str +=
"\ncursor: pointer;";
857 str +=
"\n}\ninput[type=image] { cursor: pointer;";
860 str +=
"a:visited {\ncolor: ";
861 str += d->m_vLinkColor.name();
863 if(d->m_underlineLink)
864 str +=
"\ntext-decoration: underline;";
866 if( d->m_bChangeCursor )
867 str +=
"\ncursor: pointer;";
871 str +=
"a:link:hover, a:visited:hover { text-decoration: underline; }\n";
876 const TQString &TDEHTMLSettings::availableFamilies()
879 avFamilies =
new TQString;
881 TQStringList families = db.families();
883 TQRegExp foundryExp(
" \\[.+\\]");
886 TQStringList::Iterator f = families.begin();
887 const TQStringList::Iterator fEnd = families.end();
889 for ( ; f != fEnd; ++f ) {
890 (*f).replace( foundryExp,
"");
896 *avFamilies =
',' + s.join(
",") +
',';
902 TQString TDEHTMLSettings::lookupFont(
int i)
const
905 if (d->fonts.count() > (uint) i)
908 font = d->defaultFonts[i];
912 TQString TDEHTMLSettings::stdFontName()
const
914 return lookupFont(0);
917 TQString TDEHTMLSettings::fixedFontName()
const
919 return lookupFont(1);
922 TQString TDEHTMLSettings::serifFontName()
const
924 return lookupFont(2);
927 TQString TDEHTMLSettings::sansSerifFontName()
const
929 return lookupFont(3);
932 TQString TDEHTMLSettings::cursiveFontName()
const
934 return lookupFont(4);
937 TQString TDEHTMLSettings::fantasyFontName()
const
939 return lookupFont(5);
942 void TDEHTMLSettings::setStdFontName(
const TQString &n)
944 while(d->fonts.count() <= 0)
945 d->fonts.append(TQString::null);
949 void TDEHTMLSettings::setFixedFontName(
const TQString &n)
951 while(d->fonts.count() <= 1)
952 d->fonts.append(TQString::null);
956 TQString TDEHTMLSettings::userStyleSheet()
const
958 return d->m_userSheet;
961 bool TDEHTMLSettings::isFormCompletionEnabled()
const
963 return d->m_formCompletionEnabled;
966 int TDEHTMLSettings::maxFormCompletionItems()
const
968 return d->m_maxFormCompletionItems;
971 const TQString &TDEHTMLSettings::encoding()
const
973 return d->m_encoding;
976 bool TDEHTMLSettings::followSystemColors()
const
978 return d->m_follow_system_colors;
981 const TQColor& TDEHTMLSettings::textColor()
const
983 return d->m_textColor;
986 const TQColor& TDEHTMLSettings::baseColor()
const
988 return d->m_baseColor;
991 const TQColor& TDEHTMLSettings::linkColor()
const
993 return d->m_linkColor;
996 const TQColor& TDEHTMLSettings::vLinkColor()
const
998 return d->m_vLinkColor;
1001 bool TDEHTMLSettings::autoLoadImages()
const
1003 return d->m_bAutoLoadImages;
1006 bool TDEHTMLSettings::unfinishedImageFrame()
const
1008 return d->m_bUnfinishedImageFrame;
1011 TDEHTMLSettings::KAnimationAdvice TDEHTMLSettings::showAnimations()
const
1013 return d->m_showAnimations;
1016 bool TDEHTMLSettings::isAutoDelayedActionsEnabled()
const
1018 return d->m_autoDelayedActionsEnabled;
1021 bool TDEHTMLSettings::jsErrorsEnabled()
const
1023 return d->m_jsErrorsEnabled;
1026 void TDEHTMLSettings::setJSErrorsEnabled(
bool enabled)
1028 d->m_jsErrorsEnabled = enabled;
1032 config->
writeEntry(
"ReportJSErrors", enabled);
1036 bool TDEHTMLSettings::allowTabulation()
const
1038 return d->m_allowTabulation;
1041 bool TDEHTMLSettings::autoSpellCheck()
const
1043 return d->m_autoSpellCheck;
1046 TQValueList< TQPair< TQString, TQChar > > TDEHTMLSettings::fallbackAccessKeysAssignments()
const
1048 return d->m_fallbackAccessKeysAssignments;
1051 void TDEHTMLSettings::setJSPopupBlockerPassivePopup(
bool enabled)
1053 d->m_jsPopupBlockerPassivePopup = enabled;
1056 config->
setGroup(
"Java/JavaScript Settings");
1057 config->
writeEntry(
"PopupBlockerPassivePopup", enabled);
1061 bool TDEHTMLSettings::jsPopupBlockerPassivePopup()
const
1063 return d->m_jsPopupBlockerPassivePopup;
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
int readNumEntry(const TQString &pKey, int nDefault=0) const
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
bool hasGroup(const TQString &group) const
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
bool hasKey(const TQString &key) const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
void setGroup(const TQString &group)
virtual TQMap< TQString, TQString > entryMap(const TQString &pGroup) const
static TQFont generalFont()
static TQFont fixedFont()
static TDEConfig * config()
Settings for the HTML view.
KJavaScriptAdvice
This enum specifies whether Java/JavaScript execution is allowed.
virtual ~TDEHTMLSettings()
Destructor.
void readDomainSettings(TDEConfig *config, bool reset, bool global, KPerDomainSettings &pd_settings)
reads from config's current group, forcing initialization if reset is true.
void init()
Called by constructor and reparseConfiguration.
KJSWindowMovePolicy
This enum specifies the policy for window.moveBy and .moveTo.
KJSWindowResizePolicy
This enum specifies the policy for window.resizeBy and .resizeTo.
KJSWindowOpenPolicy
This enum specifies the policy for window.open.
KJSWindowStatusPolicy
This enum specifies the policy for window.status and .defaultStatus.
KJSWindowFocusPolicy
This enum specifies the policy for window.focus.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdWarning(int area=0)
kdbgstream kdDebug(int area=0)
const TDEShortcut & end()