Gnash  0.8.10
Qt4Gui.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
00003 //   2011 Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_KDE4GUI_H
00020 #define GNASH_KDE4GUI_H
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #include "gui.h"
00027 #include "rc.h"
00028 
00029 #include <vector>
00030 #include <QX11EmbedWidget>
00031 #include <QDialog>
00032 
00033 #ifdef RENDERER_AGG
00034 #include "Qt4GlueAgg.h"
00035 #endif
00036 
00037 #ifdef RENDERER_CAIRO
00038 #include "Qt4GlueCairo.h"
00039 #endif
00040 
00041 #ifdef RENDERER_OPENGL
00042 #include "Qt4GlueOgl.h"
00043 class QGLWidget;
00044 #endif
00045 
00046 
00047 class QMainWindow;
00048 class QMenuBar;
00049 class QMenu;
00050 class QRect;
00051 class QCheckBox;
00052 class QSlider;
00053 class QLineEdit;
00054 class QSpinBox;
00055 class QStackedWidget;
00056 
00057 namespace gnash {
00058     class Qt4Gui;
00059     class DrawingWidget;
00060 }
00061 
00062 namespace gnash
00063 {
00064 
00065 class EmbedWidget : public QX11EmbedWidget
00066 {
00067     Q_OBJECT
00068 
00069 public:
00070     EmbedWidget(Qt4Gui& gui);
00071     ~EmbedWidget() {};
00072 
00073     DrawingWidget* drawingWidget() { return _drawingWidget; }
00074 
00075 public slots:
00076     void hidePlayButton();
00077     void showPlayButton();
00078 
00079 private:
00080     QPushButton* _playButton;
00081     DrawingWidget* _drawingWidget;
00082 };
00083 
00084 
00085 class DSOEXPORT Qt4Gui :  public Gui
00086 {
00087 public:
00088     Qt4Gui(unsigned long xid, float scale, bool loop, RunResources& r);
00089     virtual ~Qt4Gui();
00090     virtual bool init(int argc, char **argv[]);
00091     virtual bool createWindow(const char* windowtitle, int width, int height,
00092                               int xPosition = 0, int yPosition = 0);
00093     virtual void resizeWindow(int width, int height);
00094     virtual bool run();
00095     virtual void renderBuffer();
00096     virtual void setInterval(unsigned int interval);
00097     virtual void setTimeout(unsigned int timeout);
00098     virtual void handleKeyEvent(QKeyEvent *event, bool down);
00099     virtual void setCursor(gnash_cursor_type newcursor);
00100     virtual void setFullscreen();
00101     virtual bool showMouse(bool show);
00102     virtual void unsetFullscreen();
00103     virtual void setClipboard(const std::string& copy);
00104     virtual std::pair<int, int> screenResolution() const;
00105     virtual double getScreenDPI() const;
00106     virtual bool yesno(const std::string& question);
00107 
00108     void setInvalidatedRegions(const InvalidatedRanges& ranges);
00109     void resize(int width, int height);
00110     void showProperties();
00111     void showPreferences();
00112     void quitUI();
00113 
00114     bool want_multiple_regions() { return true; }
00115 
00116     void renderWidget(const QRect& updateRect);
00117 
00118     void popupMenu(const QPoint& point);
00119 
00120 private:
00121     typedef std::vector<geometry::Range2d<int> > DrawBounds; 
00122     typedef std::map<int, gnash::key::code> KeyMap;
00123 
00124     void setupActions();
00125     void setupMenus();
00126     void createMainMenu();
00127 
00129     void setupKeyMap();
00130 
00133     void stopHook();
00134 
00136     void playHook();
00137 
00138     DrawBounds _drawbounds;
00139  
00142     std::auto_ptr<QApplication>  _application;
00143     
00145     EmbedWidget* _embedWidget;
00146 
00148     //
00151     DrawingWidget* _drawingWidget;
00152     
00154     std::auto_ptr<Qt4Glue> _glue;
00155     
00157     std::auto_ptr<QMainWindow> _window;
00158 
00161     KeyMap _keyMap;
00162 
00164     gnash::key::code qtToGnashKey(QKeyEvent *event);
00165     int qtToGnashModifier(const Qt::KeyboardModifiers modifiers);
00166 
00167     int _interval;
00168 
00169     int _advanceTimer;
00170 
00175 
00176     // File Menu
00177     QMenu* fileMenu;
00178     QAction* propertiesAction;
00179     QAction* quitAction;
00180     
00181     // Edit Menu
00182     QMenu* editMenu;
00183     QAction* preferencesAction;
00184 
00185     // Movie Control Menu;
00186     QMenu* movieControlMenu;
00187     QAction* playAction;
00188     QAction* pauseAction;
00189     QAction* stopAction;
00190     QAction* restartAction;
00191     
00192     // View Menu
00193     QMenu* viewMenu;
00194     QAction* refreshAction;
00195     QAction* fullscreenAction;
00196 };
00197 
00198 namespace Qt4GuiPrefs
00199 {
00200 
00201 class PreferencesDialog : public QDialog
00202 {
00203 Q_OBJECT
00204 
00205 public:
00206     PreferencesDialog(QWidget* parent);
00207 
00208 private slots:
00209     void savePreferences();
00210 
00211 private:
00212     PreferencesDialog(const PreferencesDialog&);
00213 
00214     // Logging tab widgets
00215     QSlider* _verbositySlider;
00216     QCheckBox* _logToFileToggle;
00217     QLineEdit* _logFileName;
00218     QCheckBox* _parserDumpToggle;
00219     QCheckBox* _actionDumpToggle;
00220     QCheckBox* _malformedSWFToggle;
00221     QCheckBox* _ASCodingErrorToggle;
00222     QCheckBox* _lcTraceToggle;
00223 
00224     // Security tab widgets
00225     QCheckBox* _localHostToggle;
00226     QCheckBox* _localDomainToggle;
00227     QCheckBox* _insecureSSLToggle;
00228     QLineEdit* _solSandboxDir;
00229     QCheckBox* _solReadOnlyToggle;
00230     QCheckBox* _solLocalDomainToggle;
00231     QCheckBox* _localConnectionToggle;
00232 
00233     // Network tab widgets
00234     QSpinBox* _streamsTimeoutScale;
00235 
00236     // Media tab widgets
00237     QCheckBox* _soundToggle;
00238     QCheckBox* _saveStreamingMediaToggle;
00239     QCheckBox* _saveLoadedMediaToggle;
00240     QLineEdit* _mediaDir;
00241 
00242     // Player tab widgets
00243     QLineEdit* _versionText;
00244     QLineEdit* _osText;
00245     QLineEdit* _urlOpenerText;
00246     QSpinBox* _librarySize;
00247     QCheckBox* _startStoppedToggle;
00248 
00249     // The config storage.
00250     RcInitFile& _rcfile;
00251 };
00252 
00253 }
00254 
00255 }
00256 
00257 #endif