Gnash  0.8.11dev
/klash_part.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
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.
9 //
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.
14 //
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
18 
19 // Written by Koos Vriezen <koos ! vriezen ? xs4all ! nl>
20 
21 #ifndef KLASH_PART_H
22 #define KLASH_PART_H
23 
24 #include <QX11EmbedWidget>
25 #include <kprocess.h>
26 #include <kparts/browserextension.h>
27 
28 #if __GNUC__ - 0 > 3
29 #define KLASH_NO_EXPORT __attribute__ ((visibility("hidden")))
30 #else
31 #define KLASH_NO_EXPORT
32 #endif
33 #define KDE_NO_CDTOR_EXPORT KLASH_NO_EXPORT
34 #ifndef KDE_NO_EXPORT
35 #define KDE_NO_EXPORT KLASH_NO_EXPORT
36 #endif
37 
38 class KAboutData;
39 class KlashPart;
40 class KInstance;
41 class KProcess;
42 struct JSCommandEntry;
43 class KlashView;
44 
45 /*
46  * Part notifications to hosting application
47  */
48 class KLASH_NO_EXPORT KlashBrowserExtension : public KParts::BrowserExtension {
49  Q_OBJECT
50 public:
53  void urlChanged (const QString & url);
54  void setLoadingProgress (int percentage);
55 
56  void saveState (QDataStream & stream);
57  void restoreState (QDataStream & stream);
58  void requestOpenUrl (const KUrl & url, const QString & target, const QString & service);
59 };
60 
61 /*
62  * Part javascript support
63  */
64 class KLASH_NO_EXPORT KlashLiveConnectExtension : public KParts::LiveConnectExtension {
65  Q_OBJECT
66 public:
67  KlashLiveConnectExtension (KlashPart * parent);
68  ~KlashLiveConnectExtension ();
69 
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);
80  }
81 
82  void enableFinishEvent (bool b = true) { m_enablefinish = b; }
83 signals:
84  void partEvent (const unsigned long, const QString &,
85  const KParts::LiveConnectExtension::ArgList &);
86 public slots:
87  void setSize (int w, int h);
88  void started ();
89  void finished ();
90 private:
91  KlashPart * player;
92  const JSCommandEntry * lastJSCommandEntry;
93  bool m_started : 1;
94  bool m_enablefinish : 1;
95 };
96 
97 class KLASH_NO_EXPORT KlashEmbed : public QX11EmbedWidget {
98  KlashView * m_view;
99 public:
100  KlashEmbed (KlashView * parent);
101  ~KlashEmbed ();
102 };
103 
104 class KLASH_NO_EXPORT KlashView : public QWidget {
105  KlashEmbed * m_embed;
106 public:
107  KlashView (QWidget * parent);
108  ~KlashView ();
109  WId embedId ();
110 protected:
111  void resizeEvent (QResizeEvent *);
112 };
113 
114 /*
115  * Part that gets created when used a KPart
116  */
117 class KLASH_NO_EXPORT KlashPart : public KParts::ReadOnlyPart {
118  Q_OBJECT
119  friend struct GroupPredicate;
120 public:
121  KlashPart (QWidget * wparent, QObject * parent, const QStringList &args);
122  ~KlashPart ();
123 
125  { return m_browserextension; }
126  KlashLiveConnectExtension * liveconnectextension () const
127  { return m_liveconnectextension; }
128  bool allowRedir (const KUrl & url) const;
129  void fullScreen ();
130  void setLoaded (int percentage);
131  const QString & source () const { return m_src_url; }
132 public slots:
133  virtual bool openUrl (const KUrl & url);
134  virtual bool closeUrl ();
135  void play ();
136  void stop ();
137  void pause ();
138  int width () const {return m_width; }
139  int height () const {return m_height; }
140 protected slots:
141  void playingStarted ();
142  void playingStopped ();
143  void processStopped (int, QProcess::ExitStatus);
144 protected:
145  virtual bool openFile();
146 private:
147  QStringList m_args;
148  KlashBrowserExtension * m_browserextension;
149  KlashLiveConnectExtension * m_liveconnectextension;
150  KProcess * m_process;
151  KUrl m_docbase;
152  QString m_src_url;
153  QString m_file_name;
154  int m_width;
155  int m_height;
156  //bool m_noresize : 1;
157  bool m_autostart : 1;
158  bool m_fullscreen : 1;
159  bool m_started_emited : 1;
160 };
161 
162 
163 #endif
#define KLASH_NO_EXPORT
Definition: /klash_part.h:31
int width() const
Definition: /klash_part.h:138
#define KDE_NO_CDTOR_EXPORT
Definition: /klash_part.h:33
Definition: klash_part.h:117
KDE_NO_EXPORT KlashBrowserExtension * browserextension() const
Definition: /klash_part.h:124
void sendEvent(const unsigned long objid, const QString &event, const KParts::LiveConnectExtension::ArgList &args)
Definition: /klash_part.h:78
Type
Definition: AMF.h:45
Definition: klash_part.h:48
Definition: klash_part.cpp:330
KlashLiveConnectExtension * liveconnectextension() const
Definition: /klash_part.h:126
int height() const
Definition: /klash_part.h:139
#define KDE_NO_EXPORT
Definition: /klash_part.h:35
Definition: klash_part.h:104
Definition: GnashKey.h:148
const QString & source() const
Definition: /klash_part.h:131
Definition: GnashKey.h:154
w
Definition: test.py:8
std::string url
Definition: gnash.cpp:59
Definition: klash_part.cpp:330
KDE_NO_CDTOR_EXPORT ~KlashBrowserExtension()
Definition: /klash_part.h:52
void enableFinishEvent(bool b=true)
Definition: /klash_part.h:82