khtml_settings.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1999 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __konq_htmlsettings_h__ 00021 #define __konq_htmlsettings_h__ 00022 00023 class KConfig; 00024 #include <qcolor.h> 00025 #include <qstring.h> 00026 #include <qstringlist.h> 00027 #include <qfont.h> 00028 #include <qmap.h> 00029 00030 #include <kdelibs_export.h> 00031 00032 struct KPerDomainSettings; 00033 class KHTMLSettingsPrivate; 00034 00038 class KHTML_EXPORT KHTMLSettings 00039 { 00040 public: 00041 00045 enum KJavaScriptAdvice { 00046 KJavaScriptDunno=0, 00047 KJavaScriptAccept, 00048 KJavaScriptReject 00049 }; 00050 00051 enum KAnimationAdvice { 00052 KAnimationDisabled=0, 00053 KAnimationLoopOnce, 00054 KAnimationEnabled 00055 }; 00056 00060 enum KJSWindowOpenPolicy { 00061 KJSWindowOpenAllow=0, 00062 KJSWindowOpenAsk, 00063 KJSWindowOpenDeny, 00064 KJSWindowOpenSmart 00065 }; 00066 00070 enum KJSWindowStatusPolicy { 00071 KJSWindowStatusAllow=0, 00072 KJSWindowStatusIgnore 00073 }; 00074 00078 enum KJSWindowMovePolicy { 00079 KJSWindowMoveAllow=0, 00080 KJSWindowMoveIgnore 00081 }; 00082 00086 enum KJSWindowResizePolicy { 00087 KJSWindowResizeAllow=0, 00088 KJSWindowResizeIgnore 00089 }; 00090 00094 enum KJSWindowFocusPolicy { 00095 KJSWindowFocusAllow=0, 00096 KJSWindowFocusIgnore 00097 }; 00098 00102 KHTMLSettings(); 00103 KHTMLSettings(const KHTMLSettings &other); 00104 00108 void init(); 00109 00115 void init( KConfig * config, bool reset = true ); 00116 00120 virtual ~KHTMLSettings(); 00121 00122 // Behavior settings 00123 bool changeCursor() const; 00124 bool underlineLink() const; 00125 bool hoverLink() const; 00126 bool allowTabulation() const; 00127 bool autoSpellCheck() const; 00128 KAnimationAdvice showAnimations() const; 00129 00130 // Font settings 00131 QString stdFontName() const; 00132 QString fixedFontName() const; 00133 QString serifFontName() const; 00134 QString sansSerifFontName() const; 00135 QString cursiveFontName() const; 00136 QString fantasyFontName() const; 00137 00138 // these two can be set. Mainly for historical reasons (the method in KHTMLPart exists...) 00139 void setStdFontName(const QString &n); 00140 void setFixedFontName(const QString &n); 00141 00142 int minFontSize() const; 00143 int mediumFontSize() const; 00144 00145 bool jsErrorsEnabled() const; 00146 void setJSErrorsEnabled(bool enabled); 00147 00148 const QString &encoding() const; 00149 00150 bool followSystemColors() const; 00151 00152 // Color settings 00153 const QColor& textColor() const; 00154 const QColor& baseColor() const; 00155 const QColor& linkColor() const; 00156 const QColor& vLinkColor() const; 00157 00158 // Autoload images 00159 bool autoLoadImages() const; 00160 bool unfinishedImageFrame() const; 00161 00162 bool isOpenMiddleClickEnabled(); 00163 bool isBackRightClickEnabled(); 00164 00165 // Java and JavaScript 00166 // ### BIC make these const 00167 bool isJavaEnabled( const QString& hostname = QString::null ); 00168 bool isJavaScriptEnabled( const QString& hostname = QString::null ); 00169 bool isJavaScriptDebugEnabled( const QString& hostname = QString::null ); 00170 bool isJavaScriptErrorReportingEnabled( const QString& hostname = QString::null ) const; 00171 bool isPluginsEnabled( const QString& hostname = QString::null ); 00172 00173 // AdBlocK Filtering 00174 bool isAdFiltered( const QString &url ) const; 00175 bool isAdFilterEnabled() const; 00176 bool isHideAdsEnabled() const; 00177 void addAdFilter( const QString &url ); 00178 00179 // Access Keys 00180 bool accessKeysEnabled() const; 00181 00182 KJSWindowOpenPolicy windowOpenPolicy( const QString& hostname = QString::null ) const; 00183 KJSWindowMovePolicy windowMovePolicy( const QString& hostname = QString::null ) const; 00184 KJSWindowResizePolicy windowResizePolicy( const QString& hostname = QString::null ) const; 00185 KJSWindowStatusPolicy windowStatusPolicy( const QString& hostname = QString::null ) const; 00186 KJSWindowFocusPolicy windowFocusPolicy( const QString& hostname = QString::null ) const; 00187 00188 // helpers for parsing domain-specific configuration, used in KControl module as well 00189 static KJavaScriptAdvice strToAdvice(const QString& _str); 00190 static void splitDomainAdvice(const QString& configStr, QString &domain, 00191 KJavaScriptAdvice &javaAdvice, KJavaScriptAdvice& javaScriptAdvice); 00192 static const char* adviceToStr(KJavaScriptAdvice _advice); 00193 00202 void readDomainSettings(KConfig *config, bool reset, 00203 bool global, KPerDomainSettings &pd_settings); 00204 00205 QString settingsToCSS() const; 00206 static const QString &availableFamilies(); 00207 00208 QString userStyleSheet() const; 00209 00210 // Form completion 00211 bool isFormCompletionEnabled() const; 00212 int maxFormCompletionItems() const; 00213 00214 // Meta refresh/redirect (http-equiv) 00215 bool isAutoDelayedActionsEnabled () const; 00216 00217 QValueList< QPair< QString, QChar > > fallbackAccessKeysAssignments() const; 00218 00219 // Whether to show passive popup when windows are blocked 00220 // @since 3.5 00221 void setJSPopupBlockerPassivePopup(bool enabled); 00222 bool jsPopupBlockerPassivePopup() const; 00223 00224 private: 00225 friend class KHTMLFactory; 00226 QString lookupFont(int i) const; 00227 00228 KHTMLSettingsPrivate *d; 00229 static QString *avFamilies; 00230 }; 00231 00232 #endif