Gnash  0.8.11dev
Qt4Gui.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 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 #ifndef GNASH_KDE4GUI_H
20 #define GNASH_KDE4GUI_H
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #include "gui.h"
27 #include "rc.h"
28 
29 #include <vector>
30 #include <QX11EmbedWidget>
31 #include <QDialog>
32 
33 #ifdef RENDERER_AGG
34 #include "Qt4GlueAgg.h"
35 #endif
36 
37 #ifdef RENDERER_CAIRO
38 #include "Qt4GlueCairo.h"
39 #endif
40 
41 #ifdef RENDERER_OPENGL
42 #include "Qt4GlueOgl.h"
43 class QGLWidget;
44 #endif
45 
46 
47 class QMainWindow;
48 class QMenuBar;
49 class QMenu;
50 class QRect;
51 class QCheckBox;
52 class QSlider;
53 class QLineEdit;
54 class QSpinBox;
55 class QStackedWidget;
56 
57 namespace gnash {
58  class Qt4Gui;
59  class DrawingWidget;
60 }
61 
62 namespace gnash
63 {
64 
65 class EmbedWidget : public QX11EmbedWidget
66 {
67  Q_OBJECT
68 
69 public:
70  EmbedWidget(Qt4Gui& gui);
72 
73  DrawingWidget* drawingWidget() { return _drawingWidget; }
74 
75 public slots:
76  void hidePlayButton();
77  void showPlayButton();
78 
79 private:
80  QPushButton* _playButton;
81  DrawingWidget* _drawingWidget;
82 };
83 
84 
85 class DSOEXPORT Qt4Gui : public Gui
86 {
87 public:
88  Qt4Gui(unsigned long xid, float scale, bool loop, RunResources& r);
89  virtual ~Qt4Gui();
90  virtual bool init(int argc, char **argv[]);
91  virtual bool createWindow(const char* windowtitle, int width, int height,
92  int xPosition = 0, int yPosition = 0);
93  virtual void resizeWindow(int width, int height);
94  virtual bool run();
95  virtual void renderBuffer();
96  virtual void setInterval(unsigned int interval);
97  virtual void setTimeout(unsigned int timeout);
98  virtual void handleKeyEvent(QKeyEvent *event, bool down);
99  virtual void setCursor(gnash_cursor_type newcursor);
100  virtual void setFullscreen();
101  virtual bool showMouse(bool show);
102  virtual void unsetFullscreen();
103  virtual void setClipboard(const std::string& copy);
104  virtual std::pair<int, int> screenResolution() const;
105  virtual double getScreenDPI() const;
106  virtual bool yesno(const std::string& question);
107 
108  void setInvalidatedRegions(const InvalidatedRanges& ranges);
109  void resize(int width, int height);
110  void showProperties();
111  void showPreferences();
112  void quitUI();
113 
114  bool want_multiple_regions() { return true; }
115 
116  void renderWidget(const QRect& updateRect);
117 
118  void popupMenu(const QPoint& point);
119 
120 private:
121  typedef std::vector<geometry::Range2d<int> > DrawBounds;
122  typedef std::map<int, gnash::key::code> KeyMap;
123 
124  void setupActions();
125  void setupMenus();
126  void createMainMenu();
127 
129  void setupKeyMap();
130 
133  void stopHook();
134 
136  void playHook();
137 
138  DrawBounds _drawbounds;
139 
142  std::auto_ptr<QApplication> _application;
143 
145  EmbedWidget* _embedWidget;
146 
148  //
151  DrawingWidget* _drawingWidget;
152 
154  std::auto_ptr<Qt4Glue> _glue;
155 
157  std::auto_ptr<QMainWindow> _window;
158 
161  KeyMap _keyMap;
162 
164  gnash::key::code qtToGnashKey(QKeyEvent *event);
165  int qtToGnashModifier(const Qt::KeyboardModifiers modifiers);
166 
167  int _interval;
168 
169  int _advanceTimer;
170 
175 
176  // File Menu
177  QMenu* fileMenu;
178  QAction* propertiesAction;
179  QAction* quitAction;
180 
181  // Edit Menu
182  QMenu* editMenu;
183  QAction* preferencesAction;
184 
185  // Movie Control Menu;
186  QMenu* movieControlMenu;
187  QAction* playAction;
188  QAction* pauseAction;
189  QAction* stopAction;
190  QAction* restartAction;
191 
192  // View Menu
193  QMenu* viewMenu;
194  QAction* refreshAction;
195  QAction* fullscreenAction;
196 };
197 
198 namespace Qt4GuiPrefs
199 {
200 
201 class PreferencesDialog : public QDialog
202 {
203 Q_OBJECT
204 
205 public:
206  PreferencesDialog(QWidget* parent);
207 
208 private slots:
209  void savePreferences();
210 
211 private:
213 
214  // Logging tab widgets
215  QSlider* _verbositySlider;
216  QCheckBox* _logToFileToggle;
217  QLineEdit* _logFileName;
218  QCheckBox* _parserDumpToggle;
219  QCheckBox* _actionDumpToggle;
220  QCheckBox* _malformedSWFToggle;
221  QCheckBox* _ASCodingErrorToggle;
222  QCheckBox* _lcTraceToggle;
223 
224  // Security tab widgets
225  QCheckBox* _localHostToggle;
226  QCheckBox* _localDomainToggle;
227  QCheckBox* _insecureSSLToggle;
228  QLineEdit* _solSandboxDir;
229  QCheckBox* _solReadOnlyToggle;
230  QCheckBox* _solLocalDomainToggle;
231  QCheckBox* _localConnectionToggle;
232 
233  // Network tab widgets
234  QSpinBox* _streamsTimeoutScale;
235 
236  // Media tab widgets
237  QCheckBox* _soundToggle;
238  QCheckBox* _saveStreamingMediaToggle;
239  QCheckBox* _saveLoadedMediaToggle;
240  QLineEdit* _mediaDir;
241 
242  // Player tab widgets
243  QLineEdit* _versionText;
244  QLineEdit* _osText;
245  QLineEdit* _urlOpenerText;
246  QSpinBox* _librarySize;
247  QCheckBox* _startStoppedToggle;
248 
249  // The config storage.
250  RcInitFile& _rcfile;
251 };
252 
253 }
254 
255 }
256 
257 #endif