fix logic
[personal-kdelibs.git] / khtml / khtml_settings.h
blobbb38ad189a928178d4bc582d37cba50b8eb26222
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 enum KDNSPrefetch {
66 KDNSPrefetchDisabled=0,
67 KDNSPrefetchOnlyWWWAndSLD,
68 KDNSPrefetchEnabled
71 /**
72 * This enum specifies the policy for window.open
74 enum KJSWindowOpenPolicy {
75 KJSWindowOpenAllow=0,
76 KJSWindowOpenAsk,
77 KJSWindowOpenDeny,
78 KJSWindowOpenSmart
81 /**
82 * This enum specifies the policy for window.status and .defaultStatus
84 enum KJSWindowStatusPolicy {
85 KJSWindowStatusAllow=0,
86 KJSWindowStatusIgnore
89 /**
90 * This enum specifies the policy for window.moveBy and .moveTo
92 enum KJSWindowMovePolicy {
93 KJSWindowMoveAllow=0,
94 KJSWindowMoveIgnore
97 /**
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,
110 KJSWindowFocusIgnore
114 * @internal Constructor
116 KHTMLSettings();
117 KHTMLSettings(const KHTMLSettings &other);
120 * Called by constructor and reparseConfiguration
122 void init();
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();
136 // Behavior settings
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;
146 // Font settings
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;
168 // Color settings
169 const QColor& textColor() const;
170 const QColor& baseColor() const;
171 const QColor& linkColor() const;
172 const QColor& vLinkColor() const;
174 // Autoload images
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;
188 // AdBlocK Filtering
189 bool isAdFiltered( const QString &url ) const;
190 bool isAdFilterEnabled() const;
191 bool isHideAdsEnabled() const;
192 void addAdFilter( const QString &url );
194 // Access Keys
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)
215 * settings.
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;
225 // Form completion
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;
238 private:
239 friend class KHTMLGlobal;
240 QString lookupFont(int i) const;
242 KHTMLSettingsPrivate* const d;
243 static QString *avFamilies;
246 #endif