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 #ifndef GNASH_KDE4GUI_H
20 #define GNASH_KDE4GUI_H
23 #include "gnashconfig.h"
30 #include <QX11EmbedWidget>
34 #include "Qt4GlueAgg.h"
38 #include "Qt4GlueCairo.h"
41 #ifdef RENDERER_OPENGL
42 #include "Qt4GlueOgl.h"
65 class EmbedWidget
: public QX11EmbedWidget
70 EmbedWidget(Qt4Gui
& gui
);
73 DrawingWidget
* drawingWidget() { return _drawingWidget
; }
76 void hidePlayButton();
77 void showPlayButton();
80 QPushButton
* _playButton
;
81 DrawingWidget
* _drawingWidget
;
85 class DSOEXPORT Qt4Gui
: public Gui
88 Qt4Gui(unsigned long xid
, float scale
, bool loop
, RunResources
& r
);
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
);
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
);
108 void setInvalidatedRegions(const InvalidatedRanges
& ranges
);
109 void resize(int width
, int height
);
110 void showProperties();
111 void showPreferences();
114 bool want_multiple_regions() { return true; }
116 void renderWidget(const QRect
& updateRect
);
118 void popupMenu(const QPoint
& point
);
121 typedef std::vector
<geometry::Range2d
<int> > DrawBounds
;
122 typedef std::map
<int, gnash::key::code
> KeyMap
;
126 void createMainMenu();
128 /// Set up the map of Qt to Gnash keys.
131 /// Called when the movie is stopped. Also called at startup if
132 /// start stopped is configured.
135 /// Called when the movie is played.
138 DrawBounds _drawbounds
;
140 /// argc provided to QApplication.
143 /// The main application, which should destroy everything
145 std::unique_ptr
<QApplication
> _application
;
147 /// The widget that is used for embedding between processes.
148 EmbedWidget
* _embedWidget
;
150 /// The widget for rendering and handling user events.
152 /// Ownership is transferred to the main window, which
153 /// takes care of deletion.
154 DrawingWidget
* _drawingWidget
;
156 /// Takes care of painting onto the widget.
157 std::unique_ptr
<Qt4Glue
> _glue
;
159 /// The main application window.
160 std::unique_ptr
<QMainWindow
> _window
;
162 /// A map for Qt::Key values that don't easily
163 /// map onto Gnash ones.
166 /// Methods for mapping key press events from qt codes to gnash ones
167 gnash::key::code
qtToGnashKey(QKeyEvent
*event
);
168 int qtToGnashModifier(const Qt::KeyboardModifiers modifiers
);
174 /// QActions and QMenus should be attached to the
175 /// QMainWindow so that they are destroyed with it.
176 /// Actions may be shared between menus and/or
181 QAction
* propertiesAction
;
186 QAction
* preferencesAction
;
188 // Movie Control Menu;
189 QMenu
* movieControlMenu
;
191 QAction
* pauseAction
;
193 QAction
* restartAction
;
197 QAction
* refreshAction
;
198 QAction
* fullscreenAction
;
201 namespace Qt4GuiPrefs
204 class PreferencesDialog
: public QDialog
209 PreferencesDialog(QWidget
* parent
);
212 void savePreferences();
215 PreferencesDialog(const PreferencesDialog
&);
217 // Logging tab widgets
218 QSlider
* _verbositySlider
;
219 QCheckBox
* _logToFileToggle
;
220 QLineEdit
* _logFileName
;
221 QCheckBox
* _parserDumpToggle
;
222 QCheckBox
* _actionDumpToggle
;
223 QCheckBox
* _malformedSWFToggle
;
224 QCheckBox
* _ASCodingErrorToggle
;
226 // Security tab widgets
227 QCheckBox
* _localHostToggle
;
228 QCheckBox
* _localDomainToggle
;
229 QCheckBox
* _insecureSSLToggle
;
230 QLineEdit
* _solSandboxDir
;
231 QCheckBox
* _solReadOnlyToggle
;
232 QCheckBox
* _solLocalDomainToggle
;
233 QCheckBox
* _localConnectionToggle
;
235 // Network tab widgets
236 QSpinBox
* _streamsTimeoutScale
;
239 QCheckBox
* _soundToggle
;
240 QCheckBox
* _saveStreamingMediaToggle
;
241 QCheckBox
* _saveLoadedMediaToggle
;
242 QLineEdit
* _mediaDir
;
244 // Player tab widgets
245 QLineEdit
* _versionText
;
247 QLineEdit
* _urlOpenerText
;
248 QSpinBox
* _librarySize
;
249 QCheckBox
* _startStoppedToggle
;
251 // The config storage.