2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 // Written by Koos Vriezen <koos ! vriezen ? xs4all ! nl>
24 #include <QX11EmbedWidget>
26 #include <kparts/browserextension.h>
29 #define KLASH_NO_EXPORT __attribute__ ((visibility("hidden")))
31 #define KLASH_NO_EXPORT
33 #define KDE_NO_CDTOR_EXPORT KLASH_NO_EXPORT
35 #define KDE_NO_EXPORT KLASH_NO_EXPORT
46 * Part notifications to hosting application
48 class KLASH_NO_EXPORT KlashBrowserExtension
: public KParts::BrowserExtension
{
51 KlashBrowserExtension(KlashPart
*parent
);
52 KDE_NO_CDTOR_EXPORT
~KlashBrowserExtension () {}
53 void urlChanged (const QString
& url
);
54 void setLoadingProgress (int percentage
);
56 void saveState (QDataStream
& stream
);
57 void restoreState (QDataStream
& stream
);
58 void requestOpenUrl (const KUrl
& url
, const QString
& target
, const QString
& service
);
62 * Part javascript support
64 class KLASH_NO_EXPORT KlashLiveConnectExtension
: public KParts::LiveConnectExtension
{
67 KlashLiveConnectExtension (KlashPart
* parent
);
68 ~KlashLiveConnectExtension ();
70 // LiveConnect interface
71 bool get (const unsigned long, const QString
&,
72 KParts::LiveConnectExtension::Type
&, unsigned long &, QString
&);
73 bool put (const unsigned long, const QString
&, const QString
&);
74 bool call (const unsigned long, const QString
&,
75 const QStringList
&, KParts::LiveConnectExtension::Type
&,
76 unsigned long &, QString
&);
77 void unregister (const unsigned long);
78 void sendEvent(const unsigned long objid
, const QString
& event
, const KParts::LiveConnectExtension::ArgList
& args
) {
79 emit
partEvent(objid
, event
, args
);
82 void enableFinishEvent (bool b
= true) { m_enablefinish
= b
; }
84 void partEvent (const unsigned long, const QString
&,
85 const KParts::LiveConnectExtension::ArgList
&);
87 void setSize (int w
, int h
);
92 const JSCommandEntry
* lastJSCommandEntry
;
94 bool m_enablefinish
: 1;
97 class KLASH_NO_EXPORT KlashEmbed
: public QX11EmbedWidget
{
100 KlashEmbed (KlashView
* parent
);
104 class KLASH_NO_EXPORT KlashView
: public QWidget
{
105 KlashEmbed
* m_embed
;
107 KlashView (QWidget
* parent
);
111 void resizeEvent (QResizeEvent
*);
115 * Part that gets created when used a KPart
117 class KLASH_NO_EXPORT KlashPart
: public KParts::ReadOnlyPart
{
119 friend struct GroupPredicate
;
121 KlashPart (QWidget
* wparent
, QObject
* parent
, const QStringList
&args
);
124 KDE_NO_EXPORT KlashBrowserExtension
* browserextension() const
125 { return m_browserextension
; }
126 KlashLiveConnectExtension
* liveconnectextension () const
127 { return m_liveconnectextension
; }
128 bool allowRedir (const KUrl
& url
) const;
130 void setLoaded (int percentage
);
131 const QString
& source () const { return m_src_url
; }
133 virtual bool openUrl (const KUrl
& url
);
134 virtual bool closeUrl ();
138 int width () const {return m_width
; }
139 int height () const {return m_height
; }
141 void playingStarted ();
142 void playingStopped ();
143 void processStopped (int, QProcess::ExitStatus
);
145 virtual bool openFile();
148 KlashBrowserExtension
* m_browserextension
;
149 KlashLiveConnectExtension
* m_liveconnectextension
;
150 KProcess
* m_process
;
156 //bool m_noresize : 1;
157 bool m_autostart
: 1;
158 bool m_fullscreen
: 1;
159 bool m_started_emited
: 1;