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 
141  int _numArgs;
142 
145  std::unique_ptr<QApplication> _application;
146 
148  EmbedWidget* _embedWidget;
149 
151  //
154  DrawingWidget* _drawingWidget;
155 
157  std::unique_ptr<Qt4Glue> _glue;
158 
160  std::unique_ptr<QMainWindow> _window;
161 
164  KeyMap _keyMap;
165 
167  gnash::key::code qtToGnashKey(QKeyEvent *event);
168  int qtToGnashModifier(const Qt::KeyboardModifiers modifiers);
169 
170  int _interval;
171 
172  int _advanceTimer;
173 
178 
179  // File Menu
180  QMenu* fileMenu;
181  QAction* propertiesAction;
182  QAction* quitAction;
183 
184  // Edit Menu
185  QMenu* editMenu;
186  QAction* preferencesAction;
187 
188  // Movie Control Menu;
189  QMenu* movieControlMenu;
190  QAction* playAction;
191  QAction* pauseAction;
192  QAction* stopAction;
193  QAction* restartAction;
194 
195  // View Menu
196  QMenu* viewMenu;
197  QAction* refreshAction;
198  QAction* fullscreenAction;
199 };
200 
201 namespace Qt4GuiPrefs
202 {
203 
204 class PreferencesDialog : public QDialog
205 {
206 Q_OBJECT
207 
208 public:
209  PreferencesDialog(QWidget* parent);
210 
211 private slots:
212  void savePreferences();
213 
214 private:
216 
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;
225 
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;
234 
235  // Network tab widgets
236  QSpinBox* _streamsTimeoutScale;
237 
238  // Media tab widgets
239  QCheckBox* _soundToggle;
240  QCheckBox* _saveStreamingMediaToggle;
241  QCheckBox* _saveLoadedMediaToggle;
242  QLineEdit* _mediaDir;
243 
244  // Player tab widgets
245  QLineEdit* _versionText;
246  QLineEdit* _osText;
247  QLineEdit* _urlOpenerText;
248  QSpinBox* _librarySize;
249  QCheckBox* _startStoppedToggle;
250 
251  // The config storage.
252  RcInitFile& _rcfile;
253 };
254 
255 }
256 
257 }
258 
259 #endif
gnash::geometry::SnappingRanges2d< std::int32_t >
Qt4GlueCairo.h
gnash::RcInitFile::verbosityLevel
int verbosityLevel() const
Definition: rc.h:112
gnash::EmbedWidget::EmbedWidget
EmbedWidget(Qt4Gui &gui)
EmbedWidget implementation.
Definition: Qt4Gui.cpp:749
gnash::EmbedWidget::showPlayButton
void showPlayButton()
Definition: Qt4Gui.cpp:773
gnash::gnash_cursor_type
gnash_cursor_type
Enumerates mouse cursor types.
Definition: gui.h:81
gnash::Qt4Gui::getScreenDPI
virtual double getScreenDPI() const
Definition: Qt4Gui.cpp:379
gnash::key::GNASH_MOD_CONTROL
@ GNASH_MOD_CONTROL
Definition: GnashKey.h:37
gnash::RcInitFile::useActionDump
bool useActionDump() const
Definition: rc.h:74
gnash::geometry::Range2d< int >
gnash::key::RIGHT_BRACKET
@ RIGHT_BRACKET
Definition: GnashKey.h:142
gnash::key::DOWN
@ DOWN
Definition: GnashKey.h:207
gnash::EmbedWidget::~EmbedWidget
~EmbedWidget()
Definition: Qt4Gui.h:71
gnash::Gui::_renderer
std::shared_ptr< Renderer > _renderer
The handler which is called to update the client area of our window.
Definition: gui.h:506
gnash::Qt4GuiPrefs::PreferencesDialog::PreferencesDialog
PreferencesDialog(QWidget *parent)
Definition: Qt4Gui.cpp:780
gnash::key::BACKSPACE
@ BACKSPACE
Definition: GnashKey.h:53
gnash::CURSOR_INPUT
@ CURSOR_INPUT
Definition: gui.h:84
gnash::Qt4Gui::setInterval
virtual void setInterval(unsigned int interval)
Set main loop delay in milliseconds.
Definition: Qt4Gui.cpp:314
height
@ height
Definition: klash_part.cpp:329
gnash::key::d
@ d
Definition: GnashKey.h:150
gnash::GnashException
Top-level gnash exception.
Definition: GnashException.h:31
gnash::RcInitFile::updateFile
bool updateFile(const std::string &filespec)
Writes a valid gnashrc file. If the file already exists, is is overwritten.
Definition: rc.cpp:730
gnash::RcInitFile::setStreamsTimeout
void setStreamsTimeout(const double &x)
Set seconds of inactivity before timing out streams downloads.
Definition: rc.h:232
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
gnash::RcInitFile::setFlashSystemOS
void setFlashSystemOS(const std::string &value)
Definition: rc.h:208
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::RcInitFile::setSOLReadOnly
void setSOLReadOnly(bool x)
Definition: rc.h:279
gnash::RunResources::getRenderBackend
std::string & getRenderBackend()
Definition: RunResources.h:136
gnash::RcInitFile::setLocalConnection
void setLocalConnection(bool x)
Definition: rc.h:283
rc.h
gnash::Qt4Gui
Definition: Qt4Gui.h:86
_
#define _(String)
Definition: log.h:44
Renderer.h
gnash::Qt4OglGlue
Definition: Qt4GlueOgl.h:38
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::Gui
Parent class from which all GUI implementations will depend.
Definition: gui.h:88
gnash::Qt4Gui::renderBuffer
virtual void renderBuffer()
Definition: Qt4Gui.cpp:255
gnash::key::DELETEKEY
@ DELETEKEY
Definition: GnashKey.h:177
gnash::key::CONTROL
@ CONTROL
Definition: GnashKey.h:62
gnash::key::LEFT_BRACKET
@ LEFT_BRACKET
Definition: GnashKey.h:140
gnash::key::CAPSLOCK
@ CAPSLOCK
Definition: GnashKey.h:65
gnash::Qt4Gui::resize
void resize(int width, int height)
Definition: Qt4Gui.cpp:472
gnash::key::F1
@ F1
Definition: GnashKey.h:190
gnash::RcInitFile::setMovieLibraryLimit
void setMovieLibraryLimit(int value)
Definition: rc.h:96
gnash::Qt4Gui::setClipboard
virtual void setClipboard(const std::string &copy)
Definition: Qt4Gui.cpp:111
gnash::RcInitFile::getMovieLibraryLimit
int getMovieLibraryLimit() const
Definition: rc.h:95
gnash::key::GNASH_MOD_NONE
@ GNASH_MOD_NONE
Definition: GnashKey.h:35
gnash::RcInitFile::showMalformedSWFErrors
bool showMalformedSWFErrors() const
Definition: rc.h:89
gnash::Qt4Gui::setCursor
virtual void setCursor(gnash_cursor_type newcursor)
Sets the current mouse cursor for the Gui window.
Definition: Qt4Gui.cpp:321
gnash::RcInitFile::getDebugLog
const std::string & getDebugLog() const
Definition: rc.h:116
gnash::EmbedWidget::hidePlayButton
void hidePlayButton()
Definition: Qt4Gui.cpp:767
gnash::Gui::pause
void pause()
Toggle between "stop" and "play" mode.
Definition: gui.cpp:875
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::geometry::Range2d::isNull
bool isNull() const
Returns true if this is the NULL Range2d.
Definition: Range2d.h:181
gnash::key::PGUP
@ PGUP
Definition: GnashKey.h:213
gnash::Gui::_runResources
RunResources & _runResources
Per-run resources.
Definition: gui.h:500
gnash::Qt4Gui::setFullscreen
virtual void setFullscreen()
Definition: Qt4Gui.cpp:354
gnash::RunResources::setRenderer
void setRenderer(std::shared_ptr< Renderer > r)
Definition: RunResources.h:108
gnash::key::LEFT
@ LEFT
Definition: GnashKey.h:209
gnash::RcInitFile::saveLoadedMedia
void saveLoadedMedia(bool value)
Definition: rc.h:302
gnash::Gui::_fullscreen
bool _fullscreen
Definition: gui.h:513
gnash::key::RIGHT
@ RIGHT
Definition: GnashKey.h:208
gnash::RcInitFile::getSOLLocalDomain
bool getSOLLocalDomain() const
Definition: rc.h:273
gnash::geometry::Intersection
Range2d< T > Intersection(const Range2d< T > &r1, const Range2d< T > &r2)
Return a rectangle being the intersetion of the two rectangles.
Definition: Range2d.h:762
gnash::geometry::Range2d::isFinite
bool isFinite() const
Returns true if this is a finite Range2d.
Definition: Range2d.h:210
gnash::Qt4Gui::Qt4Gui
Qt4Gui(unsigned long xid, float scale, bool loop, RunResources &r)
Definition: Qt4Gui.cpp:81
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::RcInitFile::getLocalConnection
bool getLocalConnection() const
Definition: rc.h:281
gnash::RcInitFile::useLocalDomain
bool useLocalDomain() const
Definition: rc.h:135
gnash::key::GNASH_MOD_SHIFT
@ GNASH_MOD_SHIFT
Definition: GnashKey.h:36
gnash::Qt4Gui::yesno
virtual bool yesno(const std::string &question)
Prompt user with a question she can answer with yes/no.
Definition: Qt4Gui.cpp:575
gnash::key::INSERT
@ INSERT
Definition: GnashKey.h:210
gnash::RcInitFile::getSOLReadOnly
bool getSOLReadOnly() const
Definition: rc.h:277
gnash::key::ALT
@ ALT
Definition: GnashKey.h:63
gnash::key::PGDN
@ PGDN
Definition: GnashKey.h:214
gnash::key::END
@ END
Definition: GnashKey.h:212
gnash::Qt4Gui::init
virtual bool init(int argc, char **argv[])
/ Initialise the gui and the associated renderer.
Definition: Qt4Gui.cpp:119
gnash::key::code
code
Definition: GnashKey.h:44
gnash::key::_0
@ _0
Definition: GnashKey.h:94
gnash::key::ENTER
@ ENTER
Definition: GnashKey.h:58
gnash::Qt4CairoGlue
Definition: Qt4GlueCairo.h:42
play
@ play
Definition: klash_part.cpp:330
gnash::RcInitFile::useSound
bool useSound() const
Definition: rc.h:124
gnash::Gui::_width
int _width
Desired window width.
Definition: gui.h:494
gnash::key::TAB
@ TAB
Definition: GnashKey.h:54
gnash::key::CLEAR
@ CLEAR
Definition: GnashKey.h:57
gnash::key::INVALID
@ INVALID
Definition: GnashKey.h:45
gnash::key::DOUBLE_QUOTE
@ DOUBLE_QUOTE
Definition: GnashKey.h:79
gnash::RcInitFile::getURLOpenerFormat
const std::string & getURLOpenerFormat() const
Get the URL opener command format.
Definition: rc.h:239
gnash::key::p
@ p
Definition: GnashKey.h:162
gnash::key::SHIFT
@ SHIFT
Definition: GnashKey.h:61
gnash::RcInitFile::useLocalHost
bool useLocalHost() const
Whether to restrict access to the local host
Definition: rc.h:139
gnash::RcInitFile::saveStreamingMedia
void saveStreamingMedia(bool value)
Definition: rc.h:298
gnash::key::UP
@ UP
Definition: GnashKey.h:206
gnash::Qt4Gui::resizeWindow
virtual void resizeWindow(int width, int height)
Definition: Qt4Gui.cpp:234
gnash::Qt4Gui::setTimeout
virtual void setTimeout(unsigned int timeout)
Set the time in milliseconds after which the programme should exit.
Definition: Qt4Gui.cpp:306
gnash::key::HOME
@ HOME
Definition: GnashKey.h:211
gnash::RcInitFile::getMediaDir
const std::string & getMediaDir() const
Definition: rc.h:308
gnash::Qt4GuiPrefs::PreferencesDialog
Definition: Qt4Gui.h:205
gnash::Gui::resize_view
void resize_view(int width, int height)
Resize the client area view and the window accordingly.
Definition: gui.cpp:429
gnash::EmbedWidget::drawingWidget
DrawingWidget * drawingWidget()
Definition: Qt4Gui.h:73
gnash::Qt4Gui::createWindow
virtual bool createWindow(const char *windowtitle, int width, int height, int xPosition=0, int yPosition=0)
Create and display our window.
Definition: Qt4Gui.cpp:182
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
Qt4GlueOgl.h
gnash::RcInitFile::useParserDump
bool useParserDump() const
Definition: rc.h:77
gnash::Gui::_mouseShown
bool _mouseShown
Definition: gui.h:516
gnash::geometry::Point2d
2D Point class
Definition: Point2d.h:39
Qt4Gui.h
gnash::geometry::SnappingRanges2d::size
size_type size() const
Returns the number of ranges in the list.
Definition: snappingrange.h:320
gnash::Qt4Gui::handleKeyEvent
virtual void handleKeyEvent(QKeyEvent *event, bool down)
Definition: Qt4Gui.cpp:464
gnash::Gui::play
void play()
Put the application in "play" mode.
Definition: gui.cpp:830
gnash::Gui::quit
void quit()
Always called on exit.
Definition: gui.cpp:215
gnash::Qt4Gui::want_multiple_regions
bool want_multiple_regions()
Definition: Qt4Gui.h:114
gnash::CURSOR_HAND
@ CURSOR_HAND
Definition: gui.h:82
gnash::key::j
@ j
Definition: GnashKey.h:156
gnash::Qt4Gui::showMouse
virtual bool showMouse(bool show)
Sets whether the gui should show the system mouse pointer.
Definition: Qt4Gui.cpp:338
log.h
gnash::Gui::restart
void restart()
Definition: gui.cpp:269
gnash::Qt4Gui::run
virtual bool run()
Start main rendering loop.
Definition: Qt4Gui.cpp:176
gnash::Qt4AggGlue
Definition: Qt4GlueAgg.h:40
gnash::RcInitFile::setSOLSafeDir
void setSOLSafeDir(const std::string &x)
Definition: rc.h:271
gnash::key::ESCAPE
@ ESCAPE
Definition: GnashKey.h:72
gnashconfig.h
RunResources.h
gnash::Gui::_xid
unsigned long _xid
The X Window ID to attach to. If zero, we create a new window.
Definition: gui.h:486
gnash::key::MINUS
@ MINUS
Definition: GnashKey.h:90
gnash::Qt4Gui::~Qt4Gui
virtual ~Qt4Gui()
Definition: Qt4Gui.cpp:106
gnash::key::c
@ c
Definition: GnashKey.h:149
gnash::Qt4Gui::showProperties
void showProperties()
Definition: Qt4Gui.cpp:479
gnash::key::EQUALS
@ EQUALS
Definition: GnashKey.h:108
gnash::key::BACKSLASH
@ BACKSLASH
Definition: GnashKey.h:141
gnash::Qt4Gui::showPreferences
void showPreferences()
Definition: Qt4Gui.cpp:564
gnash::EmbedWidget
Definition: Qt4Gui.h:66
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::geometry::Range2d::setTo
Range2d< T > & setTo(T x, T y)
Set ourself to bound the given point.
Definition: Range2d.h:339
gnash::Gui::_validbounds
geometry::Range2d< int > _validbounds
Definition: gui.h:491
movie_definition.h
gnash::RcInitFile::getFlashVersionString
const std::string & getFlashVersionString() const
Definition: rc.h:196
gnash::RcInitFile::startStopped
bool startStopped() const
Return true if user is willing to start the gui in "stop" mode.
Definition: rc.h:103
gnash::Qt4Gui::renderWidget
void renderWidget(const QRect &updateRect)
Definition: Qt4Gui.cpp:274
gui.h
gnash::key::GNASH_MOD_ALT
@ GNASH_MOD_ALT
Definition: GnashKey.h:38
gnash::key::NOBREAKSPACE
@ NOBREAKSPACE
Definition: GnashKey.h:227
gnash::RcInitFile::getSOLSafeDir
const std::string & getSOLSafeDir() const
Definition: rc.h:268
gnash::key::SLASH
@ SLASH
Definition: GnashKey.h:92
gnash::Qt4Gui::popupMenu
void popupMenu(const QPoint &point)
Definition: Qt4Gui.cpp:243
_q
#define _q(Str)
Definition: Qt4Gui.cpp:72
gnash::RcInitFile::insecureSSL
bool insecureSSL() const
Definition: rc.h:106
gnash::RcInitFile::setURLOpenerFormat
void setURLOpenerFormat(const std::string &value)
Definition: rc.h:244
gnash::key::SPACE
@ SPACE
Definition: GnashKey.h:77
gnash::RcInitFile::setDebugLog
void setDebugLog(const std::string &x)
Definition: rc.h:115
gnash::RcInitFile::setFlashVersionString
void setFlashVersionString(const std::string &value)
Definition: rc.h:200
gnash::Gui::notify_key_event
void notify_key_event(gnash::key::code k, int modifier, bool pressed)
Key event notification to be called when a key is pressed or depressed.
Definition: gui.cpp:560
gnash::geometry::SnappingRanges2d::getRange
const RangeType & getRange(size_type index) const
Returns the range at the specified index.
Definition: snappingrange.h:326
width
@ width
Definition: klash_part.cpp:329
gnash::key::HELP
@ HELP
Definition: GnashKey.h:325
gnash::RcInitFile::getStreamsTimeout
double getStreamsTimeout() const
The number of seconds of inactivity before timing out streams downloads.
Definition: rc.h:229
gnash::Qt4Gui::quitUI
void quitUI()
End main rendering loop calling GUI-specific exit functions.
Definition: Qt4Gui.cpp:593
gnash::key::SEMICOLON
@ SEMICOLON
Definition: GnashKey.h:106
gnash::RcInitFile::useWriteLog
bool useWriteLog() const
Definition: rc.h:80
GnashException.h
gnash::RcInitFile::showASCodingErrors
bool showASCodingErrors() const
Definition: rc.h:86
gnash::Qt4Gui::screenResolution
virtual std::pair< int, int > screenResolution() const
Definition: Qt4Gui.cpp:387
Qt4GlueAgg.h
gnash::DrawingWidget
Definition: Qt4Glue.h:42
gnash::Qt4Gui::setInvalidatedRegions
void setInvalidatedRegions(const InvalidatedRanges &ranges)
Definition: Qt4Gui.cpp:282
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::RcInitFile::setMediaDir
void setMediaDir(const std::string &value)
Definition: rc.h:306
gnash::Gui::_height
int _height
Desired window height.
Definition: gui.h:497
Range2d.h
gnash::Qt4Gui::unsetFullscreen
virtual void unsetFullscreen()
Definition: Qt4Gui.cpp:364
gnash::RcInitFile
Definition: rc.h:44
gnash::RcInitFile::getFlashSystemOS
const std::string & getFlashSystemOS() const
Definition: rc.h:204
gnash::RcInitFile::setSOLLocalDomain
void setSOLLocalDomain(bool x)
Definition: rc.h:275
gnash::Gui::stop
void stop()
Put the application in "stop" mode.
Definition: gui.cpp:853
gnash::key::NUM_LOCK
@ NUM_LOCK
Definition: GnashKey.h:223