2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
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 #ifndef GNASH_KDE4GUI_H
20 #define GNASH_KDE4GUI_H
23 #include "gnashconfig.h"
30 #include <QX11EmbedWidget>
34 #include "Kde4GlueAgg.h"
38 #include "Kde4GlueCairo.h"
41 #ifdef RENDERER_OPENGL
42 #include "Kde4GlueOgl.h"
65 class EmbedWidget
: public QX11EmbedWidget
70 EmbedWidget(Kde4Gui
& gui
);
73 DrawingWidget
* drawingWidget() { return _drawingWidget
; }
76 void hidePlayButton();
77 void showPlayButton();
80 QPushButton
* _playButton
;
81 DrawingWidget
* _drawingWidget
;
85 class FDMonitor
: public QObject
89 FDMonitor(Kde4Gui
& gui
);
92 // Add a file descriptor for monitoring.
96 void dataReceived(int fd
);
103 class DSOEXPORT Kde4Gui
: public Gui
106 Kde4Gui(unsigned long xid
, float scale
, bool loop
, RunResources
& r
);
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
);
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();
128 bool want_multiple_regions() { return true; }
130 void renderWidget(const QRect
& updateRect
);
132 void popupMenu(const QPoint
& point
);
135 typedef std::vector
<geometry::Range2d
<int> > DrawBounds
;
136 typedef std::map
<int, gnash::key::code
> KeyMap
;
140 void createMainMenu();
142 /// Set up the map of Qt to Gnash keys.
145 /// Called when the movie is stopped. Also called at startup if
146 /// start stopped is configured.
149 /// Called when the movie is played.
152 /// Object that allows the mainloop to read file descriptors.
153 FDMonitor _fdMonitor
;
155 DrawBounds _drawbounds
;
157 /// The main application, which should destroy everything
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.
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
191 QAction
* propertiesAction
;
196 QAction
* preferencesAction
;
198 // Movie Control Menu;
199 QMenu
* movieControlMenu
;
201 QAction
* pauseAction
;
203 QAction
* restartAction
;
207 QAction
* refreshAction
;
208 QAction
* fullscreenAction
;
211 namespace Kde4GuiPrefs
214 class PreferencesDialog
: public QDialog
219 PreferencesDialog(QWidget
* parent
);
222 void savePreferences();
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
;
250 QCheckBox
* _soundToggle
;
251 QCheckBox
* _saveStreamingMediaToggle
;
252 QCheckBox
* _saveLoadedMediaToggle
;
253 QLineEdit
* _mediaDir
;
255 // Player tab widgets
256 QLineEdit
* _versionText
;
258 QLineEdit
* _urlOpenerText
;
259 QSpinBox
* _librarySize
;
260 QCheckBox
* _startStoppedToggle
;
262 // The config storage.