SVN_SILENT: oops, forgot to commit the xml tokenizer bit. Thanks Sebastian.
[kdelibs.git] / khtml / khtml_settings.h
blob7e22ecc3fbeb278ade12ca29c3e37b16860d72fd
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
23 class KConfig;
24 class KConfigGroup;
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;
37 /**
38 * Settings for the HTML view.
40 class KHTML_EXPORT KHTMLSettings
42 public:
44 /**
45 * This enum specifies whether Java/JavaScript execution is allowed.
47 enum KJavaScriptAdvice {
48 KJavaScriptDunno=0,
49 KJavaScriptAccept,
50 KJavaScriptReject
53 enum KAnimationAdvice {
54 KAnimationDisabled=0,
55 KAnimationLoopOnce,
56 KAnimationEnabled
59 enum KSmoothScrollingMode {
60 KSmoothScrollingDisabled=0,
61 KSmoothScrollingWhenEfficient,
62 KSmoothScrollingEnabled
65 /**
66 * This enum specifies the policy for window.open
68 enum KJSWindowOpenPolicy {
69 KJSWindowOpenAllow=0,
70 KJSWindowOpenAsk,
71 KJSWindowOpenDeny,
72 KJSWindowOpenSmart
75 /**
76 * This enum specifies the policy for window.status and .defaultStatus
78 enum KJSWindowStatusPolicy {
79 KJSWindowStatusAllow=0,
80 KJSWindowStatusIgnore
83 /**
84 * This enum specifies the policy for window.moveBy and .moveTo
86 enum KJSWindowMovePolicy {
87 KJSWindowMoveAllow=0,
88 KJSWindowMoveIgnore
91 /**
92 * This enum specifies the policy for window.resizeBy and .resizeTo
94 enum KJSWindowResizePolicy {
95 KJSWindowResizeAllow=0,
96 KJSWindowResizeIgnore
99 /**
100 * This enum specifies the policy for window.focus
102 enum KJSWindowFocusPolicy {
103 KJSWindowFocusAllow=0,
104 KJSWindowFocusIgnore
108 * @internal Constructor
110 KHTMLSettings();
111 KHTMLSettings(const KHTMLSettings &other);
114 * Called by constructor and reparseConfiguration
116 void init();
118 /** Read settings from @p config.
119 * @param config is a pointer to KConfig object.
120 * @param reset if true, settings are always set; if false,
121 * settings are only set if the config file has a corresponding key.
123 void init( KConfig * config, bool reset = true );
126 * Destructor. Don't delete any instance by yourself.
128 virtual ~KHTMLSettings();
130 // Behavior settings
131 bool changeCursor() const;
132 bool underlineLink() const;
133 bool hoverLink() const;
134 bool allowTabulation() const;
135 bool autoSpellCheck() const;
136 KAnimationAdvice showAnimations() const;
137 KSmoothScrollingMode smoothScrolling() const;
139 // Font settings
140 QString stdFontName() const;
141 QString fixedFontName() const;
142 QString serifFontName() const;
143 QString sansSerifFontName() const;
144 QString cursiveFontName() const;
145 QString fantasyFontName() const;
147 // these two can be set. Mainly for historical reasons (the method in KHTMLPart exists...)
148 void setStdFontName(const QString &n);
149 void setFixedFontName(const QString &n);
151 int minFontSize() const;
152 int mediumFontSize() const;
154 bool jsErrorsEnabled() const;
155 void setJSErrorsEnabled(bool enabled);
157 const QString &encoding() const;
159 bool followSystemColors() const;
161 // Color settings
162 const QColor& textColor() const;
163 const QColor& baseColor() const;
164 const QColor& linkColor() const;
165 const QColor& vLinkColor() const;
167 // Autoload images
168 bool autoLoadImages() const;
169 bool unfinishedImageFrame() const;
171 bool isOpenMiddleClickEnabled();
172 bool isBackRightClickEnabled();
174 // Java and JavaScript
175 bool isJavaEnabled( const QString& hostname = QString() ) const;
176 bool isJavaScriptEnabled( const QString& hostname = QString() ) const;
177 bool isJavaScriptDebugEnabled( const QString& hostname = QString() ) const;
178 bool isJavaScriptErrorReportingEnabled( const QString& hostname = QString() ) const;
179 bool isPluginsEnabled( const QString& hostname = QString() ) const;
181 // AdBlocK Filtering
182 bool isAdFiltered( const QString &url ) const;
183 bool isAdFilterEnabled() const;
184 bool isHideAdsEnabled() const;
185 void addAdFilter( const QString &url );
187 // Access Keys
188 bool accessKeysEnabled() const;
190 KJSWindowOpenPolicy windowOpenPolicy( const QString& hostname = QString() ) const;
191 KJSWindowMovePolicy windowMovePolicy( const QString& hostname = QString() ) const;
192 KJSWindowResizePolicy windowResizePolicy( const QString& hostname = QString() ) const;
193 KJSWindowStatusPolicy windowStatusPolicy( const QString& hostname = QString() ) const;
194 KJSWindowFocusPolicy windowFocusPolicy( const QString& hostname = QString() ) const;
196 // helpers for parsing domain-specific configuration, used in KControl module as well
197 static KJavaScriptAdvice strToAdvice(const QString& _str);
198 static void splitDomainAdvice(const QString& configStr, QString &domain,
199 KJavaScriptAdvice &javaAdvice, KJavaScriptAdvice& javaScriptAdvice);
200 static const char* adviceToStr(KJavaScriptAdvice _advice);
202 /** reads from @p config's current group, forcing initialization
203 * if @p reset is true.
204 * @param config is a pointer to KConfig object.
205 * @param reset true if initialization is to be forced.
206 * @param global true if the global domain is to be read.
207 * @param pd_settings will be initialised with the computed (inherited)
208 * settings.
210 void readDomainSettings(const KConfigGroup &config, bool reset,
211 bool global, KPerDomainSettings &pd_settings);
213 QString settingsToCSS() const;
214 static const QString &availableFamilies();
216 QString userStyleSheet() const;
218 // Form completion
219 bool isFormCompletionEnabled() const;
220 int maxFormCompletionItems() const;
222 // Meta refresh/redirect (http-equiv)
223 bool isAutoDelayedActionsEnabled () const;
225 QList< QPair< QString, QChar > > fallbackAccessKeysAssignments() const;
227 // Whether to show passive popup when windows are blocked
228 void setJSPopupBlockerPassivePopup(bool enabled);
229 bool jsPopupBlockerPassivePopup() const;
231 private:
232 friend class KHTMLGlobal;
233 QString lookupFont(int i) const;
235 KHTMLSettingsPrivate* const d;
236 static QString *avFamilies;
239 #endif