1 /* This file is part of the KDE project
2 Copyright (C) 1999 David Faure <faure@kde.org>
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.
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.
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.
20 #ifndef KHTML_SETTINGS_H
21 #define KHTML_SETTINGS_H
26 #include <khtml_export.h>
28 #include <QtGui/QColor>
29 #include <QtGui/QFont> // ### KDE 5: remove
30 #include <QtCore/QMap> // ### KDE 5: remove
31 #include <QtCore/QStringList>
32 #include <QtCore/QPair>
34 struct KPerDomainSettings
;
35 class KHTMLSettingsPrivate
;
38 * Settings for the HTML view.
40 class KHTML_EXPORT KHTMLSettings
45 * This enum specifies whether Java/JavaScript execution is allowed.
47 enum KJavaScriptAdvice
{
53 enum KAnimationAdvice
{
59 enum KSmoothScrollingMode
{
60 KSmoothScrollingDisabled
=0,
61 KSmoothScrollingWhenEfficient
,
62 KSmoothScrollingEnabled
66 KDNSPrefetchDisabled
=0,
67 KDNSPrefetchOnlyWWWAndSLD
,
72 * This enum specifies the policy for window.open
74 enum KJSWindowOpenPolicy
{
82 * This enum specifies the policy for window.status and .defaultStatus
84 enum KJSWindowStatusPolicy
{
85 KJSWindowStatusAllow
=0,
90 * This enum specifies the policy for window.moveBy and .moveTo
92 enum KJSWindowMovePolicy
{
98 * This enum specifies the policy for window.resizeBy and .resizeTo
100 enum KJSWindowResizePolicy
{
101 KJSWindowResizeAllow
=0,
102 KJSWindowResizeIgnore
106 * This enum specifies the policy for window.focus
108 enum KJSWindowFocusPolicy
{
109 KJSWindowFocusAllow
=0,
114 * @internal Constructor
117 KHTMLSettings(const KHTMLSettings
&other
);
120 * Called by constructor and reparseConfiguration
124 /** Read settings from @p config.
125 * @param config is a pointer to KConfig object.
126 * @param reset if true, settings are always set; if false,
127 * settings are only set if the config file has a corresponding key.
129 void init( KConfig
* config
, bool reset
= true );
132 * Destructor. Don't delete any instance by yourself.
134 virtual ~KHTMLSettings();
137 bool changeCursor() const;
138 bool underlineLink() const;
139 bool hoverLink() const;
140 bool allowTabulation() const;
141 bool autoSpellCheck() const;
142 KAnimationAdvice
showAnimations() const;
143 KSmoothScrollingMode
smoothScrolling() const;
144 KDNSPrefetch
dnsPrefetch() const;
147 QString
stdFontName() const;
148 QString
fixedFontName() const;
149 QString
serifFontName() const;
150 QString
sansSerifFontName() const;
151 QString
cursiveFontName() const;
152 QString
fantasyFontName() const;
154 // these two can be set. Mainly for historical reasons (the method in KHTMLPart exists...)
155 void setStdFontName(const QString
&n
);
156 void setFixedFontName(const QString
&n
);
158 int minFontSize() const;
159 int mediumFontSize() const;
161 bool jsErrorsEnabled() const;
162 void setJSErrorsEnabled(bool enabled
);
164 const QString
&encoding() const;
166 bool followSystemColors() const;
169 const QColor
& textColor() const;
170 const QColor
& baseColor() const;
171 const QColor
& linkColor() const;
172 const QColor
& vLinkColor() const;
175 bool autoLoadImages() const;
176 bool unfinishedImageFrame() const;
178 bool isOpenMiddleClickEnabled();
179 bool isBackRightClickEnabled();
181 // Java and JavaScript
182 bool isJavaEnabled( const QString
& hostname
= QString() ) const;
183 bool isJavaScriptEnabled( const QString
& hostname
= QString() ) const;
184 bool isJavaScriptDebugEnabled( const QString
& hostname
= QString() ) const;
185 bool isJavaScriptErrorReportingEnabled( const QString
& hostname
= QString() ) const;
186 bool isPluginsEnabled( const QString
& hostname
= QString() ) const;
189 bool isAdFiltered( const QString
&url
) const;
190 bool isAdFilterEnabled() const;
191 bool isHideAdsEnabled() const;
192 void addAdFilter( const QString
&url
);
195 bool accessKeysEnabled() const;
197 KJSWindowOpenPolicy
windowOpenPolicy( const QString
& hostname
= QString() ) const;
198 KJSWindowMovePolicy
windowMovePolicy( const QString
& hostname
= QString() ) const;
199 KJSWindowResizePolicy
windowResizePolicy( const QString
& hostname
= QString() ) const;
200 KJSWindowStatusPolicy
windowStatusPolicy( const QString
& hostname
= QString() ) const;
201 KJSWindowFocusPolicy
windowFocusPolicy( const QString
& hostname
= QString() ) const;
203 // helpers for parsing domain-specific configuration, used in KControl module as well
204 static KJavaScriptAdvice
strToAdvice(const QString
& _str
);
205 static void splitDomainAdvice(const QString
& configStr
, QString
&domain
,
206 KJavaScriptAdvice
&javaAdvice
, KJavaScriptAdvice
& javaScriptAdvice
);
207 static const char* adviceToStr(KJavaScriptAdvice _advice
);
209 /** reads from @p config's current group, forcing initialization
210 * if @p reset is true.
211 * @param config is a pointer to KConfig object.
212 * @param reset true if initialization is to be forced.
213 * @param global true if the global domain is to be read.
214 * @param pd_settings will be initialised with the computed (inherited)
217 void readDomainSettings(const KConfigGroup
&config
, bool reset
,
218 bool global
, KPerDomainSettings
&pd_settings
);
220 QString
settingsToCSS() const;
221 static const QString
&availableFamilies();
223 QString
userStyleSheet() const;
226 bool isFormCompletionEnabled() const;
227 int maxFormCompletionItems() const;
229 // Meta refresh/redirect (http-equiv)
230 bool isAutoDelayedActionsEnabled () const;
232 QList
< QPair
< QString
, QChar
> > fallbackAccessKeysAssignments() const;
234 // Whether to show passive popup when windows are blocked
235 void setJSPopupBlockerPassivePopup(bool enabled
);
236 bool jsPopupBlockerPassivePopup() const;
239 friend class KHTMLGlobal
;
240 QString
lookupFont(int i
) const;
242 KHTMLSettingsPrivate
* const d
;
243 static QString
*avFamilies
;