Plug more leaks (in the test, not the core)
[gnash.git] / gui / kde / Kde4Gui.h
blob19eb70e7ae0668419844cc511149ec029a685feb
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // 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
19 #ifndef GNASH_KDE4GUI_H
20 #define GNASH_KDE4GUI_H
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
26 #include "gui.h"
27 #include "rc.h"
29 #include <vector>
30 #include <QX11EmbedWidget>
31 #include <QDialog>
33 #ifdef RENDERER_AGG
34 #include "Kde4GlueAgg.h"
35 #endif
37 #ifdef RENDERER_CAIRO
38 #include "Kde4GlueCairo.h"
39 #endif
41 #ifdef RENDERER_OPENGL
42 #include "Kde4GlueOgl.h"
43 class QGLWidget;
44 #endif
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;
57 namespace gnash {
58 class Kde4Gui;
59 class DrawingWidget;
62 namespace gnash
65 class EmbedWidget : public QX11EmbedWidget
67 Q_OBJECT
69 public:
70 EmbedWidget(Kde4Gui& gui);
71 ~EmbedWidget() {};
73 DrawingWidget* drawingWidget() { return _drawingWidget; }
75 public slots:
76 void hidePlayButton();
77 void showPlayButton();
79 private:
80 QPushButton* _playButton;
81 DrawingWidget* _drawingWidget;
85 class FDMonitor : public QObject
87 Q_OBJECT
88 public:
89 FDMonitor(Kde4Gui& gui);
90 ~FDMonitor();
92 // Add a file descriptor for monitoring.
93 void addFD(int fd);
95 public slots:
96 void dataReceived(int fd);
98 private:
99 Kde4Gui& _gui;
103 class DSOEXPORT Kde4Gui : public Gui
105 public:
106 Kde4Gui(unsigned long xid, float scale, bool loop, RunResources& r);
107 virtual ~Kde4Gui();
108 virtual bool init(int argc, char **argv[]);
109 virtual bool createWindow(const char* windowtitle, int width, int height,
110 int xPosition = 0, int yPosition = 0);
111 virtual void resizeWindow(int width, int height);
112 virtual bool run();
113 virtual bool watchFD(int fd);
114 virtual void renderBuffer();
115 virtual void setInterval(unsigned int interval);
116 virtual void setTimeout(unsigned int timeout);
117 virtual void handleKeyEvent(QKeyEvent *event, bool down);
118 virtual void setCursor(gnash_cursor_type newcursor);
119 virtual void setFullscreen();
120 virtual bool showMouse(bool show);
121 virtual void unsetFullscreen();
122 void setInvalidatedRegions(const InvalidatedRanges& ranges);
123 void resize(int width, int height);
124 void showProperties();
125 void showPreferences();
126 void quitUI();
128 bool want_multiple_regions() { return true; }
130 void renderWidget(const QRect& updateRect);
132 void popupMenu(const QPoint& point);
134 private:
135 typedef std::vector<geometry::Range2d<int> > DrawBounds;
136 typedef std::map<int, gnash::key::code> KeyMap;
138 void setupActions();
139 void setupMenus();
140 void createMainMenu();
142 /// Set up the map of Qt to Gnash keys.
143 void setupKeyMap();
145 /// Called when the movie is stopped. Also called at startup if
146 /// start stopped is configured.
147 void stopHook();
149 /// Called when the movie is played.
150 void playHook();
152 /// Object that allows the mainloop to read file descriptors.
153 FDMonitor _fdMonitor;
155 DrawBounds _drawbounds;
157 /// The main application, which should destroy everything
158 /// left on closing.
159 std::auto_ptr<QApplication> _application;
161 /// The widget that is used for embedding between processes.
162 EmbedWidget* _embedWidget;
164 /// The widget for rendering and handling user events.
166 /// Ownership is transferred to the main window, which
167 /// takes care of deletion.
168 DrawingWidget* _drawingWidget;
170 /// Takes care of painting onto the widget.
171 std::auto_ptr<Kde4Glue> _glue;
173 /// The main application window.
174 std::auto_ptr<QMainWindow> _window;
176 /// A map for Qt::Key values that don't easily
177 /// map onto Gnash ones.
178 KeyMap _keyMap;
180 /// Methods for mapping key press events from qt codes to gnash ones
181 gnash::key::code qtToGnashKey(QKeyEvent *event);
182 int qtToGnashModifier(const Qt::KeyboardModifiers modifiers);
184 /// QActions and QMenus should be attached to the
185 /// QMainWindow so that they are destroyed with it.
186 /// Actions may be shared between menus and/or
187 /// other uses.
189 // File Menu
190 QMenu* fileMenu;
191 QAction* propertiesAction;
192 QAction* quitAction;
194 // Edit Menu
195 QMenu* editMenu;
196 QAction* preferencesAction;
198 // Movie Control Menu;
199 QMenu* movieControlMenu;
200 QAction* playAction;
201 QAction* pauseAction;
202 QAction* stopAction;
203 QAction* restartAction;
205 // View Menu
206 QMenu* viewMenu;
207 QAction* refreshAction;
208 QAction* fullscreenAction;
211 namespace Kde4GuiPrefs
214 class PreferencesDialog : public QDialog
216 Q_OBJECT
218 public:
219 PreferencesDialog(QWidget* parent);
221 private slots:
222 void savePreferences();
224 private:
225 PreferencesDialog(const PreferencesDialog&);
227 // Logging tab widgets
228 QSlider* _verbositySlider;
229 QCheckBox* _logToFileToggle;
230 QLineEdit* _logFileName;
231 QCheckBox* _parserDumpToggle;
232 QCheckBox* _actionDumpToggle;
233 QCheckBox* _malformedSWFToggle;
234 QCheckBox* _ASCodingErrorToggle;
235 QCheckBox* _lcTraceToggle;
237 // Security tab widgets
238 QCheckBox* _localHostToggle;
239 QCheckBox* _localDomainToggle;
240 QCheckBox* _insecureSSLToggle;
241 QLineEdit* _solSandboxDir;
242 QCheckBox* _solReadOnlyToggle;
243 QCheckBox* _solLocalDomainToggle;
244 QCheckBox* _localConnectionToggle;
246 // Network tab widgets
247 QSpinBox* _streamsTimeoutScale;
249 // Media tab widgets
250 QCheckBox* _soundToggle;
251 QCheckBox* _saveStreamingMediaToggle;
252 QCheckBox* _saveLoadedMediaToggle;
253 QLineEdit* _mediaDir;
255 // Player tab widgets
256 QLineEdit* _versionText;
257 QLineEdit* _osText;
258 QLineEdit* _urlOpenerText;
259 QSpinBox* _librarySize;
260 QCheckBox* _startStoppedToggle;
262 // The config storage.
263 RcInitFile& _rcfile;
270 #endif