File indexing completed on 2024-04-28 04:42:45
0001 /* 0002 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef WEBKITSETTINGS_H 0008 #define WEBKITSETTINGS_H 0009 0010 class KConfig; 0011 class KConfigGroup; 0012 0013 #include <QColor> 0014 #include <QStringList> 0015 #include <QPair> 0016 0017 #include <KParts/HtmlExtension> 0018 #include <KParts/HtmlSettingsInterface> 0019 0020 struct KPerDomainSettings; 0021 class WebKitSettingsPrivate; 0022 0023 /** 0024 * Settings for the HTML view. 0025 */ 0026 class WebKitSettings 0027 { 0028 public: 0029 0030 enum KAnimationAdvice { 0031 KAnimationDisabled=0, 0032 KAnimationLoopOnce, 0033 KAnimationEnabled 0034 }; 0035 0036 enum KSmoothScrollingMode { 0037 KSmoothScrollingDisabled=0, 0038 KSmoothScrollingWhenEfficient, 0039 KSmoothScrollingEnabled 0040 }; 0041 0042 /** 0043 * @internal Constructor 0044 */ 0045 WebKitSettings(); 0046 0047 /** 0048 * Called by constructor and reparseConfiguration 0049 */ 0050 void init(); 0051 0052 /** 0053 * Destructor. Don't delete any instance by yourself. 0054 */ 0055 virtual ~WebKitSettings(); 0056 0057 void computeFontSizes(int logicalDpi); 0058 bool zoomToDPI() const; 0059 void setZoomToDPI(bool b); 0060 0061 // Automatic page reload/refresh... 0062 bool autoPageRefresh() const; 0063 0064 bool isOpenMiddleClickEnabled(); 0065 0066 // Java and JavaScript 0067 bool isJavaEnabled( const QString& hostname = QString() ) const; 0068 bool isJavaScriptEnabled( const QString& hostname = QString() ) const; 0069 bool isJavaScriptDebugEnabled( const QString& hostname = QString() ) const; 0070 bool isJavaScriptErrorReportingEnabled( const QString& hostname = QString() ) const; 0071 bool isPluginsEnabled( const QString& hostname = QString() ) const; 0072 bool isLoadPluginsOnDemandEnabled() const; 0073 bool isInternalPluginHandlingDisabled() const; 0074 0075 // AdBlocK Filtering 0076 bool isAdFiltered( const QString &url ) const; 0077 bool isAdFilterEnabled() const; 0078 bool isHideAdsEnabled() const; 0079 void addAdFilter( const QString &url ); 0080 QString adFilteredBy( const QString &url, bool *isWhiteListed = nullptr ) const; 0081 0082 // Access Keys 0083 bool accessKeysEnabled() const; 0084 0085 // Favicons 0086 bool favIconsEnabled() const; 0087 0088 KParts::HtmlSettingsInterface::JSWindowOpenPolicy windowOpenPolicy( const QString& hostname = QString() ) const; 0089 KParts::HtmlSettingsInterface::JSWindowMovePolicy windowMovePolicy( const QString& hostname = QString() ) const; 0090 KParts::HtmlSettingsInterface::JSWindowResizePolicy windowResizePolicy( const QString& hostname = QString() ) const; 0091 KParts::HtmlSettingsInterface::JSWindowStatusPolicy windowStatusPolicy( const QString& hostname = QString() ) const; 0092 KParts::HtmlSettingsInterface::JSWindowFocusPolicy windowFocusPolicy( const QString& hostname = QString() ) const; 0093 0094 QString settingsToCSS() const; 0095 QString userStyleSheet() const; 0096 0097 // Form completion 0098 bool isFormCompletionEnabled() const; 0099 int maxFormCompletionItems() const; 0100 0101 // Meta refresh/redirect (http-equiv) 0102 bool isAutoDelayedActionsEnabled () const; 0103 0104 // CookieJar... 0105 bool isCookieJarEnabled() const; 0106 0107 // Password storage... 0108 bool isNonPasswordStorableSite(const QString &host) const; 0109 void addNonPasswordStorableSite(const QString &host); 0110 void removeNonPasswordStorableSite(const QString &host); 0111 bool askToSaveSitePassword() const; 0112 0113 // Mixed content 0114 bool alowActiveMixedContent() const; 0115 bool allowMixedContentDisplay() const; 0116 0117 // Global config object stuff. 0118 static WebKitSettings* self(); 0119 0120 private: 0121 /** 0122 * Read settings from @p config. 0123 * @param config is a pointer to KConfig object. 0124 * @param reset if true, settings are always set; if false, 0125 * settings are only set if the config file has a corresponding key. 0126 */ 0127 void init( KConfig * config, bool reset = true ); 0128 0129 // Behavior settings 0130 bool changeCursor() const; 0131 bool underlineLink() const; 0132 bool hoverLink() const; 0133 bool allowTabulation() const; 0134 bool autoSpellCheck() const; 0135 KAnimationAdvice showAnimations() const; 0136 KSmoothScrollingMode smoothScrolling() const; 0137 bool zoomTextOnly() const; 0138 0139 // Font settings 0140 QString stdFontName() const; 0141 QString fixedFontName() const; 0142 QString serifFontName() const; 0143 QString sansSerifFontName() const; 0144 QString cursiveFontName() const; 0145 QString fantasyFontName() const; 0146 0147 // these two can be set. Mainly for historical reasons (the method in KHTMLPart exists...) 0148 void setStdFontName(const QString &n); 0149 void setFixedFontName(const QString &n); 0150 0151 int minFontSize() const; 0152 int mediumFontSize() const; 0153 0154 bool jsErrorsEnabled() const; 0155 void setJSErrorsEnabled(bool enabled); 0156 0157 const QString &encoding() const; 0158 0159 bool followSystemColors() const; 0160 0161 // Color settings 0162 const QColor& textColor() const; 0163 const QColor& baseColor() const; 0164 const QColor& linkColor() const; 0165 const QColor& vLinkColor() const; 0166 0167 // Autoload images 0168 bool autoLoadImages() const; 0169 bool unfinishedImageFrame() const; 0170 0171 /** 0172 * reads from @p config's current group, forcing initialization 0173 * if @p reset is true. 0174 * @param config is a pointer to KConfig object. 0175 * @param reset true if initialization is to be forced. 0176 * @param global true if the global domain is to be read. 0177 * @param pd_settings will be initialised with the computed (inherited) 0178 * settings. 0179 */ 0180 void readDomainSettings(const KConfigGroup &config, bool reset, 0181 bool global, KPerDomainSettings &pd_settings); 0182 0183 0184 QList< QPair< QString, QChar > > fallbackAccessKeysAssignments() const; 0185 0186 // Whether to show passive popup when windows are blocked 0187 void setJSPopupBlockerPassivePopup(bool enabled); 0188 bool jsPopupBlockerPassivePopup() const; 0189 0190 0191 QString lookupFont(int i) const; 0192 0193 void initWebKitSettings(); 0194 void initCookieJarSettings(); 0195 void initNSPluginSettings(); 0196 0197 WebKitSettingsPrivate* const d; 0198 }; 0199 0200 #endif