1/* This file is part of the KDE project
2 * Copyright (C) 2002 Stephan Kulow <coolo@kde.org>
3 *
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.
8 *
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.
13 *
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.
18*/
19
20#ifndef __khtml_Iface_h__
21#define __khtml_Iface_h__
22
23#include <kurl.h>
24#include <khtml_part.h>
25#include <QtDBus/QtDBus>
26
27class KHTMLPart;
28
29/**
30 * D-BUS interface for KHTML
31 */
32class KHTMLPartIface : public QDBusAbstractAdaptor
33{
34 Q_OBJECT
35 Q_CLASSINFO("D-Bus Interface", "org.kde.KHTMLPart")
36 Q_PROPERTY(bool autoloadImages READ autoloadImages WRITE setAutoloadImages)
37 Q_PROPERTY(bool dndEnabled READ dndEnabled WRITE setDndEnabled)
38 Q_PROPERTY(QString encoding READ encoding WRITE setEncoding)
39 Q_PROPERTY(bool jScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled)
40 Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled)
41 Q_PROPERTY(QString lastModified READ lastModified)
42 Q_PROPERTY(bool metaRefreshEnabled READ metaRefreshEnabled WRITE setMetaRefreshEnabled)
43 Q_PROPERTY(bool onlyLocalReferences READ onlyLocalReferences WRITE setOnlyLocalReferences)
44 Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
45 Q_PROPERTY(QString url READ url)
46
47public:
48
49 KHTMLPartIface( KHTMLPart * );
50 virtual ~KHTMLPartIface();
51
52public Q_SLOTS:
53 /**
54 * @return the current URL
55 */
56 QString url() const;
57
58 bool closeUrl();
59
60 /**
61 * Enable/disable Javascript support. Note that this will
62 * in either case permanently override the default usersetting.
63 * If you want to have the default UserSettings, don't call this
64 * method.
65 */
66 void setJScriptEnabled( bool enable );
67
68 /**
69 * Returns @p true if Javascript support is enabled or @p false
70 * otherwise.
71 */
72 bool jScriptEnabled() const;
73
74 /**
75 * Enable/disable the automatic forwarding by <meta http-equiv="refresh" ....>
76 */
77 void setMetaRefreshEnabled( bool enable );
78
79 /**
80 * Returns @p true if automtaic forwarding is enabled.
81 */
82 bool metaRefreshEnabled() const;
83
84 /**
85 * Enables or disables Drag'n'Drop support. A drag operation is started if
86 * the users drags a link.
87 */
88 void setDndEnabled( bool b );
89
90 /**
91 * Returns whether Dragn'n'Drop support is enabled or not.
92 */
93 bool dndEnabled() const;
94
95 /**
96 * Enables/disables Java applet support. Note that calling this function
97 * will permanently override the User settings about Java applet support.
98 * Not calling this function is the only way to let the default settings
99 * apply.
100 */
101 void setJavaEnabled( bool enable );
102
103 /**
104 * Return if Java applet support is enabled/disabled.
105 */
106 bool javaEnabled() const;
107
108
109 /**
110 * Enables or disables plugins via, default is enabled
111 */
112 void setPluginsEnabled( bool enable );
113
114 /**
115 * Returns trie if plugins are enabled/disabled.
116 */
117 bool pluginsEnabled() const;
118
119 /**
120 * Specifies whether images contained in the document should be loaded
121 * automatically or not.
122 *
123 * @note Request will be ignored if called before begin().
124 */
125 void setAutoloadImages( bool enable );
126
127 /**
128 * Returns whether images contained in the document are loaded automatically
129 * or not.
130 * @note that the returned information is unrelieable as long as no begin()
131 * was called.
132 */
133 bool autoloadImages() const;
134
135 /**
136 * Security option.
137 *
138 * Specify whether only local references ( stylesheets, images, scripts, subdocuments )
139 * should be loaded. ( default false - everything is loaded, if the more specific
140 * options allow )
141 */
142 void setOnlyLocalReferences(bool enable);
143
144 /**
145 * Returns whether references should be loaded ( default false )
146 **/
147 bool onlyLocalReferences() const;
148
149 /**
150 * Sets the encoding the page uses.
151 *
152 * This can be different from the charset. The widget will try to reload
153 * the current page in the new encoding, if url() is not empty.
154 */
155 bool setEncoding( const QString &name );
156
157 /**
158 * Returns the encoding the page currently uses.
159 *
160 * Note that the encoding might be different from the charset.
161 */
162 QString encoding() const;
163
164 /**
165 * Sets a user defined style sheet to be used on top of the HTML 4
166 * default style sheet.
167 *
168 * This gives a wide range of possibilities to
169 * change the layout of the page.
170 */
171 void setUserStyleSheet(const QString &styleSheet);
172
173 /**
174 * Sets the fixed font style.
175 *
176 * @param name The font name to use for fixed text, e.g.
177 * the <tt>&lt;pre&gt;</tt> tag.
178 */
179 void setFixedFont( const QString &name );
180
181 /**
182 * Finds the anchor named @p name.
183 *
184 * If the anchor is found, the widget
185 * scrolls to the closest position. Returns @p true if the anchor has
186 * been found.
187 */
188 bool gotoAnchor( const QString &name );
189
190 /**
191 * Go to next Anchor.
192 *
193 * This is useful to navigate from outside of the navigator.
194 */
195 bool nextAnchor();
196
197 /**
198 * Go to previous Anchor.
199 */
200 bool prevAnchor();
201
202 /**
203 * Activate the node that currently has the focus
204 * (emulates pressing Return)
205 */
206 void activateNode();
207
208 /**
209 * Returns the text the user has marked.
210 */
211 QString selectedText() const;
212
213 /**
214 * Marks all text in the document as selected.
215 */
216 void selectAll();
217
218 /**
219 * Last-modified date (in raw string format), if received in the [HTTP] headers.
220 */
221 QString lastModified() const;
222
223 /**
224 * Print the contents of the current html view.
225 * @param quick if true, fully automated printing, without the print dialog.
226 */
227 Q_NOREPLY void print( bool quick );
228
229 void debugRenderTree();
230 void debugDOMTree();
231 void viewDocumentSource();
232 void viewFrameSource();
233 void saveBackground(const QString &url);
234 void saveDocument(const QString &url);
235
236 /**
237 * Evaluate a given piece of Javascript code
238 */
239 QString evalJS(const QString &script);
240
241 /**
242 * Stops display of animated images
243 */
244 void stopAnimations();
245
246Q_SIGNALS:
247 void configurationChanged();
248
249private:
250 KHTMLPart *part;
251};
252
253#endif
254
255