Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tools / qmlviewer / qmlruntime.cpp
index c8af32f..76b1328 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the tools applications of the Qt Toolkit.
 **
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 
-#include <qdeclarativeview.h>
+#include <QtQuick1/qdeclarativeview.h>
 
 #ifdef hz
 #undef hz
 #endif
-#ifdef Q_WS_MAEMO_5
-#  include <QMaemo5ValueButton>
-#  include <QMaemo5ListPickSelector>
-#  include <QWidgetAction>
-#  include <QStringListModel>
-#  include "ui_recopts_maemo5.h"
-#else
 #  include "ui_recopts.h"
-#endif
 
 #include "qmlruntime.h"
 #include <qdeclarativecontext.h>
 #include <private/qabstractanimation_p.h>
 
 #include <QSettings>
+#include <QMimeData>
 #include <QXmlStreamReader>
 #include <QBuffer>
 #include <QNetworkReply>
+#include <QNetworkCookie>
 #include <QNetworkCookieJar>
 #include <QNetworkDiskCache>
 #include <QNetworkAccessManager>
 #include <QGraphicsObject>
 #include <QNetworkProxyFactory>
 #include <QKeyEvent>
+#include <QMimeData>
 #include <QMutex>
 #include <QMutexLocker>
 #include "proxysettings.h"
 #include "deviceorientation.h"
+#include <qdeclarativetester.h>
 
 #ifdef GL_SUPPORTED
 #include <QGLWidget>
 #endif
 
-#if defined(Q_WS_S60)
-#include <aknappui.h> // For locking app orientation
-#endif
-
-#include <qdeclarativetester.h>
-
 QT_BEGIN_NAMESPACE
 
 class DragAndDropView : public QDeclarativeView
@@ -191,60 +181,6 @@ private:
     bool activeWindow;
 };
 
-
-
-#if defined(Q_WS_MAEMO_5)
-
-class Maemo5PickerAction : public QWidgetAction {
-    Q_OBJECT
-public:
-    Maemo5PickerAction(const QString &text, QActionGroup *actions, QObject *parent)
-        : QWidgetAction(parent), m_text(text), m_actions(actions)
-    { }
-
-    QWidget *createWidget(QWidget *parent)
-    {
-       QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent);
-       button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered);
-        QMaemo5ListPickSelector *pick = new QMaemo5ListPickSelector(button);
-       button->setPickSelector(pick);
-       if (m_actions) {
-           QStringList sl;
-           int curIdx = -1, idx = 0;
-           foreach (QAction *a, m_actions->actions()) {
-               sl << a->text();
-               if (a->isChecked())
-                   curIdx = idx;
-               idx++;
-            }
-           pick->setModel(new QStringListModel(sl));
-           pick->setCurrentIndex(curIdx);
-       } else {
-           button->setEnabled(false);
-       }
-       connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered()));
-       return button;
-    }
-
-private slots:
-    void emitTriggered()
-    {
-       QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender());
-       if (!pick)
-           return;
-       int idx = pick->currentIndex();
-
-       if (m_actions && idx >= 0 && idx < m_actions->actions().count())
-           m_actions->actions().at(idx)->trigger();
-    }
-
-private:
-    QString m_text;
-    QPointer<QActionGroup> m_actions;
-};
-
-#endif // Q_WS_MAEMO_5
-
 static struct { const char *name, *args; } ffmpegprofiles[] = {
     {"Maximum Quality", "-sameq"},
     {"High Quality", "-qmax 2"},
@@ -261,11 +197,9 @@ public:
     RecordingDialog(QWidget *parent) : QDialog(parent)
     {
         setupUi(this);
-#ifndef Q_WS_MAEMO_5
         hz->setValidator(new QDoubleValidator(hz));
-#endif
         for (int i=0; ffmpegprofiles[i].name; ++i) {
-            profile->addItem(ffmpegprofiles[i].name);
+            profile->addItem(QString::fromAscii(ffmpegprofiles[i].name));
         }
     }
 
@@ -273,9 +207,9 @@ public:
     {
         int i;
         for (i=0; ffmpegprofiles[i].args[0]; ++i) {
-            if (ffmpegprofiles[i].args == a) {
+            if (QString::fromAscii(ffmpegprofiles[i].args) == a) {
                 profile->setCurrentIndex(i);
-                args->setText(QLatin1String(ffmpegprofiles[i].args));
+                args->setText(QString::fromAscii(ffmpegprofiles[i].args));
                 return;
             }
         }
@@ -294,59 +228,25 @@ public:
     {
         QString str = tr("Original (%1x%2)").arg(s.width()).arg(s.height());
 
-#ifdef Q_WS_MAEMO_5
-        sizeCombo->setItemText(0, str);
-#else
         sizeOriginal->setText(str);
         if (sizeWidth->value()<=1) {
             sizeWidth->setValue(s.width());
             sizeHeight->setValue(s.height());
         }
-#endif
     }
 
     void showffmpegOptions(bool b)
     {
-#ifdef Q_WS_MAEMO_5
-        profileLabel->setVisible(b);
-        profile->setVisible(b);
-        ffmpegHelp->setVisible(b);
-        args->setVisible(b);
-#else
         ffmpegOptions->setVisible(b);
-#endif
     }
 
     void showRateOptions(bool b)
     {
-#ifdef Q_WS_MAEMO_5
-        rateLabel->setVisible(b);
-        rateCombo->setVisible(b);
-#else
         rateOptions->setVisible(b);
-#endif
     }
 
     void setVideoRate(int rate)
     {
-#ifdef Q_WS_MAEMO_5
-        int idx;
-        if (rate >= 60)
-            idx = 0;
-        else if (rate >= 50)
-            idx = 2;
-        else if (rate >= 25)
-            idx = 3;
-        else if (rate >= 24)
-            idx = 4;
-        else if (rate >= 20)
-            idx = 5;
-        else if (rate >= 15)
-            idx = 6;
-        else
-            idx = 7;
-        rateCombo->setCurrentIndex(idx);
-#else
         if (rate == 24)
             hz24->setChecked(true);
         else if (rate == 25)
@@ -359,23 +259,10 @@ public:
             hzCustom->setChecked(true);
             hz->setText(QString::number(rate));
         }
-#endif
     }
 
     int videoRate() const
     {
-#ifdef Q_WS_MAEMO_5
-        switch (rateCombo->currentIndex()) {
-            case 0: return 60;
-            case 1: return 50;
-            case 2: return 25;
-            case 3: return 24;
-            case 4: return 20;
-            case 5: return 15;
-            case 7: return 10;
-            default: return 60;
-        }
-#else
         if (hz24->isChecked())
             return 24;
         else if (hz25->isChecked())
@@ -387,20 +274,10 @@ public:
         else {
             return hz->text().toInt();
         }
-#endif
     }
 
     QSize videoSize() const
     {
-#ifdef Q_WS_MAEMO_5
-        switch (sizeCombo->currentIndex()) {
-            case 0: return QSize();
-            case 1: return QSize(640,480);
-            case 2: return QSize(320,240);
-            case 3: return QSize(1280,720);
-            default: return QSize();
-        }
-#else
         if (sizeOriginal->isChecked())
             return QSize();
         else if (size720p->isChecked())
@@ -411,7 +288,6 @@ public:
             return QSize(320,240);
         else
             return QSize(sizeWidth->value(), sizeHeight->value());
-#endif
     }
 
 
@@ -465,14 +341,14 @@ private:
             }
         }
         QSettings settings;
-        settings.setValue("Cookies",data);
+        settings.setValue(QLatin1String("Cookies"), data);
     }
 
     void load()
     {
         QMutexLocker lock(&mutex);
         QSettings settings;
-        QByteArray data = settings.value("Cookies").toByteArray();
+        QByteArray data = settings.value(QLatin1String("Cookies")).toByteArray();
         setAllCookies(QNetworkCookie::parseCookies(data));
     }
 
@@ -490,7 +366,7 @@ public:
         if (proxyDirty)
             setupProxy();
         QString protocolTag = query.protocolTag();
-        if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
+        if (httpProxyInUse && (protocolTag == QLatin1String("http") || protocolTag == QLatin1String("https"))) {
             QList<QNetworkProxy> ret;
             ret << httpProxy;
             return ret;
@@ -597,7 +473,7 @@ QString QDeclarativeViewer::getVideoFileName()
     if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)");
     types += tr("Individual PNG frames")+QLatin1String(" (*.png)");
     if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)");
-    return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
+    return QFileDialog::getSaveFileName(this, title, QString(), types.join(QLatin1String(";; ")));
 }
 
 QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
@@ -614,11 +490,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
 {
     QDeclarativeViewer::registerTypes();
     setWindowTitle(tr("Qt QML Viewer"));
-#ifdef Q_WS_MAEMO_5
-    setAttribute(Qt::WA_Maemo5StackedWindow);
-//    setPalette(QApplication::palette("QLabel"));
-#endif
-
     devicemode = false;
     canvas = 0;
     record_autotime = 0;
@@ -651,7 +522,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
 
     canvas->setFocus();
 
-    QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
+    QObject::connect(canvas, SIGNAL(initialSizeChanged(QSize)), this, SLOT(initialSizeChanged(QSize)));
     QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
     QObject::connect(canvas->engine(), SIGNAL(quit()), this, SLOT(close()));
 
@@ -725,26 +596,24 @@ void QDeclarativeViewer::createMenu()
     connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
 
     QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this);
-    snapshotAction->setShortcut(QKeySequence("F3"));
+    snapshotAction->setShortcut(QKeySequence(tr("F3")));
     connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
 
     recordAction = new QAction(tr("Start Recording &Video"), this);
-    recordAction->setShortcut(QKeySequence("F9"));
+    recordAction->setShortcut(QKeySequence(tr("F9")));
     connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
 
     QAction *recordOptions = new QAction(tr("Video &Options..."), this);
     connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
 
     QAction *slowAction = new QAction(tr("&Slow Down Animations"), this);
-    slowAction->setShortcut(QKeySequence("Ctrl+."));
+    slowAction->setShortcut(QKeySequence(tr("Ctrl+.")));
     slowAction->setCheckable(true);
     connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
 
     showWarningsWindow = new QAction(tr("Show Warnings"), this);
-#if !defined(Q_OS_SYMBIAN)
     showWarningsWindow->setCheckable((true));
     showWarningsWindow->setChecked(loggerWindow->isVisible());
-#endif
     connect(showWarningsWindow, SIGNAL(triggered(bool)), this, SLOT(showWarnings(bool)));
 
     QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this);
@@ -755,37 +624,29 @@ void QDeclarativeViewer::createMenu()
     connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
 
     rotateAction = new QAction(tr("Rotate orientation"), this);
-    rotateAction->setShortcut(QKeySequence("Ctrl+T"));
+    rotateAction->setShortcut(QKeySequence(tr("Ctrl+T")));
     connect(rotateAction, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
 
     orientation = new QActionGroup(this);
     orientation->setExclusive(true);
     connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*)));
 
-#if defined(Q_OS_SYMBIAN)
-    QAction *autoOrientationAction = new QAction(tr("Auto-orientation"), this);
-    autoOrientationAction->setCheckable(true);
-#endif
     QAction *portraitAction = new QAction(tr("Portrait"), this);
     portraitAction->setCheckable(true);
     QAction *landscapeAction = new QAction(tr("Landscape"), this);
     landscapeAction->setCheckable(true);
-#if !defined(Q_OS_SYMBIAN)
     QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this);
     portraitInvAction->setCheckable(true);
     QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this);
     landscapeInvAction->setCheckable(true);
-#endif
 
     QAction *aboutAction = new QAction(tr("&About Qt..."), this);
     aboutAction->setMenuRole(QAction::AboutQtRole);
     connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
 
-#if !defined(Q_OS_SYMBIAN)
     QAction *closeAction = new QAction(tr("&Close"), this);
     closeAction->setShortcuts(QKeySequence::Close);
     connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
-#endif
 
     QAction *quitAction = new QAction(tr("&Quit"), this);
     quitAction->setMenuRole(QAction::QuitRole);
@@ -794,34 +655,12 @@ void QDeclarativeViewer::createMenu()
 
     QMenuBar *menu = menuBar();
     if (!menu)
-       return;
-
-#if defined(Q_WS_MAEMO_5)
-    menu->addAction(openAction);
-    menu->addAction(openUrlAction);
-    menu->addAction(reloadAction);
-
-    menu->addAction(snapshotAction);
-    menu->addAction(recordAction);
-
-    menu->addAction(recordOptions);
-    menu->addAction(proxyAction);
-
-    menu->addAction(slowAction);
-    menu->addAction(showWarningsWindow);
-
-    orientation->addAction(landscapeAction);
-    orientation->addAction(portraitAction);
-    menu->addAction(new Maemo5PickerAction(tr("Set orientation"), orientation, this));
-    menu->addAction(fullscreenAction);
-    return;
-#endif // Q_WS_MAEMO_5
+        return;
 
     QMenu *fileMenu = menu->addMenu(tr("&File"));
     fileMenu->addAction(openAction);
     fileMenu->addAction(openUrlAction);
     fileMenu->addAction(reloadAction);
-#if !defined(Q_OS_SYMBIAN)
     fileMenu->addSeparator();
     fileMenu->addAction(closeAction);
     fileMenu->addAction(quitAction);
@@ -829,7 +668,6 @@ void QDeclarativeViewer::createMenu()
     QMenu *recordMenu = menu->addMenu(tr("&Recording"));
     recordMenu->addAction(snapshotAction);
     recordMenu->addAction(recordAction);
-#endif // ! Q_OS_SYMBIAN
 
     QMenu *debugMenu = menu->addMenu(tr("&Debugging"));
     debugMenu->addAction(slowAction);
@@ -837,25 +675,16 @@ void QDeclarativeViewer::createMenu()
 
     QMenu *settingsMenu = menu->addMenu(tr("&Settings"));
     settingsMenu->addAction(proxyAction);
-#if defined(Q_OS_SYMBIAN)
-    settingsMenu->addAction(fullscreenAction);
-#else
     settingsMenu->addAction(recordOptions);
     settingsMenu->addMenu(loggerWindow->preferencesMenu());
-#endif // !Q_OS_SYMBIAN
     settingsMenu->addAction(rotateAction);
 
     QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
 
-#if defined(Q_OS_SYMBIAN)
-    orientation->addAction(autoOrientationAction);
-#endif
     orientation->addAction(portraitAction);
     orientation->addAction(landscapeAction);
-#if !defined(Q_OS_SYMBIAN)
     orientation->addAction(portraitInvAction);
     orientation->addAction(landscapeInvAction);
-#endif
     propertiesMenu->addActions(orientation->actions());
 
     QMenu *helpMenu = menu->addMenu(tr("&Help"));
@@ -879,23 +708,6 @@ void QDeclarativeViewer::proxySettingsChanged()
 
 void QDeclarativeViewer::rotateOrientation()
 {
-#if defined(Q_WS_S60)
-    CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
-    if (appUi) {
-        CAknAppUi::TAppUiOrientation oldOrientation = appUi->Orientation();
-        QString newOrientation;
-        if (oldOrientation == CAknAppUi::EAppUiOrientationPortrait) {
-            newOrientation = QLatin1String("Landscape");
-        } else {
-            newOrientation = QLatin1String("Portrait");
-        }
-        foreach (QAction *action, orientation->actions()) {
-            if (action->text() == newOrientation) {
-                changeOrientation(action);
-            }
-        }
-    }
-#else
     QAction *current = orientation->checkedAction();
     QList<QAction *> actions = orientation->actions();
     int index = actions.indexOf(current);
@@ -904,7 +716,6 @@ void QDeclarativeViewer::rotateOrientation()
 
     QAction *newOrientation = actions[(index + 1) % actions.count()];
     changeOrientation(newOrientation);
-#endif
 }
 
 void QDeclarativeViewer::toggleFullScreen()
@@ -917,11 +728,7 @@ void QDeclarativeViewer::toggleFullScreen()
 
 void QDeclarativeViewer::showWarnings(bool show)
 {
-#if defined(Q_OS_SYMBIAN)
-    loggerWindow->showMaximized();
-#else
     loggerWindow->setVisible(show);
-#endif
 }
 
 void QDeclarativeViewer::warningsWidgetOpened()
@@ -963,7 +770,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
 
 
     // Profile
-    recdlg->setArguments(record_args.join(" "));
+    recdlg->setArguments(record_args.join(QLatin1String(" ")));
     if (recdlg->exec()) {
         // File
         record_file = recdlg->file->text();
@@ -972,7 +779,7 @@ void QDeclarativeViewer::chooseRecordingOptions()
         // Rate
         record_rate = recdlg->videoRate();
         // Profile
-        record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
+        record_args = recdlg->arguments().split(QLatin1Char(' '),QString::SkipEmptyParts);
     }
 }
 
@@ -983,8 +790,8 @@ void QDeclarativeViewer::toggleRecordingWithSelection()
             QString fileName = getVideoFileName();
             if (fileName.isEmpty())
                 return;
-            if (!fileName.contains(QRegExp(".[^\\/]*$")))
-                fileName += ".avi";
+            if (!fileName.contains(QRegExp(QLatin1String(".[^\\/]*$"))))
+                fileName += QLatin1String(".avi");
             setRecordFile(fileName);
         }
     }
@@ -1026,7 +833,7 @@ void QDeclarativeViewer::openFile()
 {
     QString cur = canvas->source().toLocalFile();
     if (useQmlFileBrowser) {
-        open("qrc:/browser/Browser.qml");
+        open(QLatin1String("qrc:/browser/Browser.qml"));
     } else {
         QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
         if (!fileName.isEmpty()) {
@@ -1052,6 +859,7 @@ void QDeclarativeViewer::statusChanged()
     if (canvas->status() == QDeclarativeView::Ready) {
         initialSize = canvas->initialSize();
         updateSizeHints(true);
+        QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
     }
 }
 
@@ -1072,7 +880,7 @@ void QDeclarativeViewer::loadTranslationFile(const QString& directory)
 
 void QDeclarativeViewer::loadDummyDataFiles(const QString& directory)
 {
-    QDir dir(directory+"/dummydata", "*.qml");
+    QDir dir(directory + QLatin1String("/dummydata"), QLatin1String("*.qml"));
     QStringList list = dir.entryList();
     for (int i = 0; i < list.size(); ++i) {
         QString qml = list.at(i);
@@ -1114,14 +922,9 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
     delete canvas->rootObject();
     canvas->engine()->clearComponentCache();
     QDeclarativeContext *ctxt = canvas->rootContext();
-    ctxt->setContextProperty("qmlViewer", this);
-#ifdef Q_OS_SYMBIAN
-    ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
-#else
-    ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
-#endif
-
-    ctxt->setContextProperty("runtime", Runtime::instance());
+    ctxt->setContextProperty(QLatin1String("qmlViewer"), this);
+    ctxt->setContextProperty(QLatin1String("qmlViewerFolder"), QDir::currentPath());
+    ctxt->setContextProperty(QLatin1String("runtime"), Runtime::instance());
 
     QString fileName = url.toLocalFile();
     if (!fileName.isEmpty()) {
@@ -1144,6 +947,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
     QTime t;
     t.start();
 
+    QObject::disconnect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
     canvas->setSource(url);
 
     return true;
@@ -1177,6 +981,15 @@ void QDeclarativeViewer::sceneResized(QSize)
     updateSizeHints();
 }
 
+void QDeclarativeViewer::initialSizeChanged(QSize size)
+{
+    if (!isFullScreen() && !isMaximized()) {
+        canvas->setGeometry(0,0,size.width(),size.height());
+        layout()->setSizeConstraint(QLayout::SetFixedSize);
+        layout()->activate();
+    }
+}
+
 void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
 {
     if (event->key() == Qt::Key_0 && devicemode)
@@ -1224,26 +1037,26 @@ bool QDeclarativeViewer::event(QEvent *event)
 void QDeclarativeViewer::senseImageMagick()
 {
     QProcess proc;
-    proc.start("convert", QStringList() << "-h");
+    proc.start(QLatin1String("convert"), QStringList() << QLatin1String("-h"));
     proc.waitForFinished(2000);
-    QString help = proc.readAllStandardOutput();
-    convertAvailable = help.contains("ImageMagick");
+    QString help = QString::fromAscii(proc.readAllStandardOutput());
+    convertAvailable = help.contains(QLatin1String("ImageMagick"));
 }
 
 void QDeclarativeViewer::senseFfmpeg()
 {
     QProcess proc;
-    proc.start("ffmpeg", QStringList() << "-h");
+    proc.start(QLatin1String("ffmpeg"), QStringList() << QLatin1String("-h"));
     proc.waitForFinished(2000);
-    QString ffmpegHelp = proc.readAllStandardOutput();
-    ffmpegAvailable = ffmpegHelp.contains("-s ");
-    ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp;
+    QString ffmpegHelp = QString::fromAscii(proc.readAllStandardOutput());
+    ffmpegAvailable = ffmpegHelp.contains(QLatin1String("-s "));
+    ffmpegHelp = tr("Video recording uses ffmpeg:") + QLatin1String("\n\n") + ffmpegHelp;
 
     QDialog *d = new QDialog(recdlg);
     QVBoxLayout *l = new QVBoxLayout(d);
     QTextBrowser *b = new QTextBrowser(d);
     QFont f = b->font();
-    f.setFamily("courier");
+    f.setFamily(QLatin1String("courier"));
     b->setFont(f);
     b->setText(ffmpegHelp);
     l->addWidget(b);
@@ -1266,7 +1079,7 @@ void QDeclarativeViewer::setRecording(bool on)
         recordTimer.start();
         frame_fmt = record_file.right(4).toLower();
         frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32);
-        if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) {
+        if (frame_fmt != QLatin1String(".png") && (!convertAvailable || frame_fmt != QLatin1String(".gif"))) {
             // Stream video to ffmpeg
 
             QProcess *proc = new QProcess(this);
@@ -1274,19 +1087,19 @@ void QDeclarativeViewer::setRecording(bool on)
             frame_stream = proc;
 
             QStringList args;
-            args << "-y";
-            args << "-r" << QString::number(record_rate);
-            args << "-f" << "rawvideo";
-            args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32");
-            args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height());
-            args << "-i" << "-";
+            args << QLatin1String("-y");
+            args << QLatin1String("-r") << QString::number(record_rate);
+            args << QLatin1String("-f") << QLatin1String("rawvideo");
+            args << QLatin1String("-pix_fmt") << (frame_fmt == QLatin1String(".gif") ? QLatin1String("rgb24") : QLatin1String("rgb32"));
+            args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(canvas->width()).arg(canvas->height());
+            args << QLatin1String("-i") << QLatin1String("-");
             if (record_outsize.isValid()) {
-                args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
-                args << "-aspect" << QString::number(double(canvas->width())/canvas->height());
+                args << QLatin1String("-s") << QString::fromAscii("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
+                args << QLatin1String("-aspect") << QString::number(double(canvas->width())/canvas->height());
             }
             args += record_args;
             args << record_file;
-            proc->start("ffmpeg",args);
+            proc->start(QLatin1String("ffmpeg"), args);
 
         } else {
             // Store frames, save to GIF/PNG
@@ -1309,14 +1122,14 @@ void QDeclarativeViewer::setRecording(bool on)
 
             QString framename;
             bool png_output = false;
-            if (record_file.right(4).toLower()==".png") {
-                if (record_file.contains('%'))
+            if (record_file.right(4).toLower() == QLatin1String(".png")) {
+                if (record_file.contains(QLatin1Char('%')))
                     framename = record_file;
                 else
-                    framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4);
+                    framename = record_file.left(record_file.length()-4) + QLatin1String("%04d") + record_file.right(4);
                 png_output = true;
             } else {
-                framename = "tmp-frame%04d.png";
+                framename = QLatin1String("tmp-frame%04d.png");
                 png_output = false;
             }
             foreach (QImage* img, frames) {
@@ -1327,11 +1140,11 @@ void QDeclarativeViewer::setRecording(bool on)
                 name.sprintf(framename.toLocal8Bit(),frame++);
                 if (record_outsize.isValid())
                     *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
-                if (record_dither=="ordered")
+                if (record_dither==QLatin1String("ordered"))
                     img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name);
-                else if (record_dither=="threshold")
+                else if (record_dither==QLatin1String("threshold"))
                     img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name);
-                else if (record_dither=="floyd")
+                else if (record_dither==QLatin1String("floyd"))
                     img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name);
                 else
                     img->save(name);
@@ -1341,25 +1154,26 @@ void QDeclarativeViewer::setRecording(bool on)
 
             if (!progress.wasCanceled()) {
                 if (png_output) {
-                    framename.replace(QRegExp("%\\d*."),"*");
+                    framename.replace(QRegExp(QLatin1String("%\\d*.")), QLatin1String("*"));
                     qDebug() << "Wrote frames" << framename;
                     inputs.clear(); // don't remove them
                 } else {
                     // ImageMagick and gifsicle for GIF encoding
                     progress.setLabelText(tr("Converting frames to GIF file..."));
                     QStringList args;
-                    args << "-delay" << QString::number(period/10);
+                    args << QLatin1String("-delay") << QString::number(period/10);
                     args << inputs;
                     args << record_file;
                     qDebug() << "Converting..." << record_file << "(this may take a while)";
-                    if (0!=QProcess::execute("convert", args)) {
+                    if (0!=QProcess::execute(QLatin1String("convert"), args)) {
                         qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
                         inputs.clear(); // don't remove them
                         qDebug() << "Wrote frames tmp-frame*.png";
                     } else {
-                        if (record_file.right(4).toLower() == ".gif") {
+                        if (record_file.right(4).toLower() == QLatin1String(".gif")) {
                             qDebug() << "Compressing..." << record_file;
-                            if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file))
+                            if (0!=QProcess::execute(QLatin1String("gifsicle"), QStringList() << QLatin1String("-O2")
+                                                     << QLatin1String("-o") << record_file << record_file))
                                 qWarning() << "Cannot run 'gifsicle' - not compressed";
                         }
                         qDebug() << "Wrote" << record_file;
@@ -1392,6 +1206,7 @@ void QDeclarativeViewer::appAboutToQuit()
     loggerWindow = 0;
     delete tester;
     tester = 0;
+    close();
 }
 
 void QDeclarativeViewer::autoStartRecording()
@@ -1410,12 +1225,12 @@ void QDeclarativeViewer::recordFrame()
 {
     canvas->QWidget::render(&frame);
     if (frame_stream) {
-        if (frame_fmt == ".gif") {
+        if (frame_fmt == QLatin1String(".gif")) {
             // ffmpeg can't do 32bpp with gif
             QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888);
-            frame_stream->write((char*)rgb24.bits(),rgb24.numBytes());
+            frame_stream->write((char*)rgb24.bits(),rgb24.byteCount());
         } else {
-            frame_stream->write((char*)frame.bits(),frame.numBytes());
+            frame_stream->write((char*)frame.bits(),frame.byteCount());
         }
     } else {
         frames.append(new QImage(frame));
@@ -1428,22 +1243,6 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
         return;
     QString o = action->text();
     action->setChecked(true);
-#if defined(Q_WS_S60)
-    CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
-    if (appUi) {
-        CAknAppUi::TAppUiOrientation orientation = appUi->Orientation();
-        if (o == QLatin1String("Auto-orientation")) {
-            appUi->SetOrientationL(CAknAppUi::EAppUiOrientationAutomatic);
-            rotateAction->setVisible(false);
-        } else if (o == QLatin1String("Portrait")) {
-            appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
-            rotateAction->setVisible(true);
-        } else if (o == QLatin1String("Landscape")) {
-            appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
-            rotateAction->setVisible(true);
-        }
-    }
-#else
     if (o == QLatin1String("Portrait"))
         DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
     else if (o == QLatin1String("Landscape"))
@@ -1452,7 +1251,6 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
         DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted);
     else if (o == QLatin1String("Landscape (inverted)"))
         DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted);
-#endif
 }
 
 void QDeclarativeViewer::orientationChanged()
@@ -1475,8 +1273,9 @@ void QDeclarativeViewer::setUseGL(bool useGL)
 #ifdef GL_SUPPORTED
     if (useGL) {
         QGLFormat format = QGLFormat::defaultFormat();
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         format.setSampleBuffers(true);
+        format.setSwapInterval(1);
 #else
         format.setSampleBuffers(false);
 #endif
@@ -1518,7 +1317,7 @@ void QDeclarativeViewer::updateSizeHints(bool initial)
         QSize newWindowSize = initial ? initialSize : canvas->sizeHint();
         //qWarning() << "USH:" << (initial ? "INIT:" : "V2R:") << "setting fixed size " << newWindowSize;
         if (!isFullScreen() && !isMaximized()) {
-            canvas->setFixedSize(newWindowSize);
+            canvas->setGeometry(0,0,newWindowSize.width(),newWindowSize.height());
             resize(1, 1);
             layout()->setSizeConstraint(QLayout::SetFixedSize);
             layout()->activate();
@@ -1541,8 +1340,8 @@ void QDeclarativeViewer::registerTypes()
 
     if (!registered) {
         // registering only for exposing the DeviceOrientation::Orientation enum
-        qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation","");
-        qmlRegisterUncreatableType<DeviceOrientation>("QtQuick",1,0,"Orientation","");
+        qmlRegisterUncreatableType<DeviceOrientation>("Qt", 4, 7, "Orientation", QString());
+        qmlRegisterUncreatableType<DeviceOrientation>("QtQuick", 1, 0, "Orientation", QString());
         registered = true;
     }
 }