tools/qml/qmlruntime.h
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the tools applications of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QDECLARATIVEVIEWER_H
       
    43 #define QDECLARATIVEVIEWER_H
       
    44 
       
    45 #include <QMainWindow>
       
    46 #include <QMenuBar>
       
    47 #include <private/qdeclarativetimer_p.h>
       
    48 #include <QTime>
       
    49 #include <QList>
       
    50 
       
    51 #include "loggerwidget.h"
       
    52 
       
    53 QT_BEGIN_NAMESPACE
       
    54 
       
    55 class QDeclarativeView;
       
    56 class PreviewDeviceSkin;
       
    57 class QDeclarativeTestEngine;
       
    58 class QProcess;
       
    59 class RecordingDialog;
       
    60 class QDeclarativeTester;
       
    61 class QNetworkReply;
       
    62 class QNetworkCookieJar;
       
    63 class NetworkAccessManagerFactory;
       
    64 class QTranslator;
       
    65 
       
    66 class QDeclarativeViewer
       
    67 #if defined(Q_OS_SYMBIAN)
       
    68     : public QMainWindow
       
    69 #else
       
    70     : public QWidget
       
    71 #endif
       
    72 {
       
    73 Q_OBJECT
       
    74 public:
       
    75     QDeclarativeViewer(QWidget *parent=0, Qt::WindowFlags flags=0);
       
    76     ~QDeclarativeViewer();
       
    77 
       
    78     static void registerTypes();
       
    79 
       
    80     enum ScriptOption {
       
    81         Play = 0x00000001,
       
    82         Record = 0x00000002,
       
    83         TestImages = 0x00000004,
       
    84         TestErrorProperty = 0x00000008,
       
    85         SaveOnExit = 0x00000010,
       
    86         ExitOnComplete = 0x00000020,
       
    87         ExitOnFailure = 0x00000040,
       
    88         Snapshot = 0x00000080
       
    89     };
       
    90     Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
       
    91     void setScript(const QString &s) { m_script = s; }
       
    92     void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
       
    93     void setRecordDither(const QString& s) { record_dither = s; }
       
    94     void setRecordRate(int fps);
       
    95     void setRecordFile(const QString&);
       
    96     void setRecordArgs(const QStringList&);
       
    97     void setRecording(bool on);
       
    98     bool isRecording() const { return recordTimer.isRunning(); }
       
    99     void setAutoRecord(int from, int to);
       
   100     void setDeviceKeys(bool);
       
   101     void setNetworkCacheSize(int size);
       
   102     void addLibraryPath(const QString& lib);
       
   103     void addPluginPath(const QString& plugin);
       
   104     void setUseGL(bool use);
       
   105     void setUseNativeFileBrowser(bool);
       
   106     void updateSizeHints();
       
   107     void setSizeToView(bool sizeToView);
       
   108 
       
   109     QMenuBar *menuBar() const;
       
   110 
       
   111     QDeclarativeView *view() const;
       
   112     LoggerWidget *warningsWidget() const;
       
   113 
       
   114     void enableExperimentalGestures();
       
   115 
       
   116 public slots:
       
   117     void sceneResized(QSize size);
       
   118     bool open(const QString&);
       
   119     void openFile();
       
   120     void reload();
       
   121     void takeSnapShot();
       
   122     void toggleRecording();
       
   123     void toggleRecordingWithSelection();
       
   124     void ffmpegFinished(int code);
       
   125     void showProxySettings ();
       
   126     void proxySettingsChanged ();
       
   127     void toggleOrientation();
       
   128     void statusChanged();
       
   129     void setSlowMode(bool);
       
   130     void launch(const QString &);
       
   131 
       
   132 protected:
       
   133     virtual void keyPressEvent(QKeyEvent *);
       
   134     virtual bool event(QEvent *);
       
   135     void createMenu(QMenuBar *menu, QMenu *flatmenu);
       
   136 
       
   137 private slots:
       
   138     void autoStartRecording();
       
   139     void autoStopRecording();
       
   140     void recordFrame();
       
   141     void chooseRecordingOptions();
       
   142     void pickRecordingFile();
       
   143     void setPortrait();
       
   144     void setLandscape();
       
   145     void startNetwork();
       
   146     void toggleFullScreen();
       
   147     void orientationChanged();
       
   148 
       
   149     void showWarnings(bool show);
       
   150     void warningsWidgetOpened();
       
   151     void warningsWidgetClosed();
       
   152 
       
   153 private:
       
   154     QString getVideoFileName();
       
   155     int menuBarHeight() const;
       
   156 
       
   157     LoggerWidget *loggerWindow;
       
   158     QDeclarativeView *canvas;
       
   159     QSize initialSize;
       
   160     QString currentFileOrUrl;
       
   161     QDeclarativeTimer recordTimer;
       
   162     QString frame_fmt;
       
   163     QImage frame;
       
   164     QList<QImage*> frames;
       
   165     QProcess* frame_stream;
       
   166     QDeclarativeTimer autoStartTimer;
       
   167     QDeclarativeTimer autoStopTimer;
       
   168     QString record_dither;
       
   169     QString record_file;
       
   170     QSize record_outsize;
       
   171     QStringList record_args;
       
   172     int record_rate;
       
   173     int record_autotime;
       
   174     bool devicemode;
       
   175     QAction *recordAction;
       
   176     QString currentSkin;
       
   177     bool scaleSkin;
       
   178     mutable QMenuBar *mb;
       
   179     RecordingDialog *recdlg;
       
   180 
       
   181     void senseImageMagick();
       
   182     void senseFfmpeg();
       
   183     QWidget *ffmpegHelpWindow;
       
   184     bool ffmpegAvailable;
       
   185     bool convertAvailable;
       
   186 
       
   187     QAction *portraitOrientation;
       
   188     QAction *landscapeOrientation;
       
   189 
       
   190     QAction *showWarningsWindow;
       
   191 
       
   192     QString m_script;
       
   193     ScriptOptions m_scriptOptions;
       
   194     QDeclarativeTester *tester;
       
   195 
       
   196     QNetworkReply *wgtreply;
       
   197     QString wgtdir;
       
   198     NetworkAccessManagerFactory *namFactory;
       
   199 
       
   200     bool useQmlFileBrowser;
       
   201 
       
   202     QTranslator *translator;
       
   203     void loadTranslationFile(const QString& directory);
       
   204 
       
   205     void loadDummyDataFiles(const QString& directory);
       
   206 };
       
   207 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
       
   208 
       
   209 QT_END_NAMESPACE
       
   210 
       
   211 #endif