summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer/qmlviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r--tools/qmlviewer/qmlviewer.cpp77
1 files changed, 70 insertions, 7 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 8d8d66a..1811327 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -82,6 +82,19 @@
#include <qfxtester.h>
+#if defined (Q_OS_SYMBIAN)
+#define SYMBIAN_NETWORK_INIT
+#endif
+
+#if defined (SYMBIAN_NETWORK_INIT)
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <QTextCodec>
+#include "sym_iap_util.h"
+#endif
+
QT_BEGIN_NAMESPACE
@@ -327,7 +340,12 @@ QString QmlViewer::getVideoFileName()
QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0)
+#if defined(Q_OS_SYMBIAN)
+ : QMainWindow(parent, flags)
+#else
+ : QWidget(parent, flags)
+#endif
+ , frame_stream(0), scaleSkin(true), mb(0)
, portraitOrientation(0), landscapeOrientation(0)
, m_scriptOptions(0), tester(0), useQmlFileBrowser(true)
{
@@ -374,6 +392,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
setPortrait();
}
+#if !defined(Q_OS_SYMBIAN)
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
@@ -381,6 +400,9 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
if (mb)
layout->addWidget(mb);
layout->addWidget(canvas);
+#else
+ setCentralWidget(canvas);
+#endif
setupProxy();
canvas->engine()->networkAccessManager()->setCookieJar(new PersistentCookieJar(this));
@@ -401,8 +423,12 @@ void QmlViewer::adjustSizeSlot()
QMenuBar *QmlViewer::menuBar() const
{
+#if !defined(Q_OS_SYMBIAN)
if (!mb)
mb = new SizedMenuBar((QWidget*)this, canvas);
+#else
+ mb = QMainWindow::menuBar();
+#endif
return mb;
}
@@ -423,6 +449,13 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
fileMenu->addAction(reloadAction);
+#if defined(Q_OS_SYMBIAN)
+ QAction *networkAction = new QAction(tr("Start &Network"), parent);
+ connect(networkAction, SIGNAL(triggered()), this, SLOT(startNetwork()));
+ fileMenu->addAction(networkAction);
+#endif
+
+#if !defined(Q_OS_SYMBIAN)
if (flatmenu) flatmenu->addSeparator();
QMenu *recordMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Recording"));
@@ -498,13 +531,21 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString)));
if (flatmenu) flatmenu->addSeparator();
+#endif // Q_OS_SYMBIAN
QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
QAction *proxyAction = new QAction(tr("Http &proxy..."), parent);
connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));
settingsMenu->addAction(proxyAction);
+#if !defined(Q_OS_SYMBIAN)
if (!flatmenu)
settingsMenu->addAction(recordOptions);
+#else
+ QAction *fullscreenAction = new QAction(tr("Full Screen"), parent);
+ fullscreenAction->setCheckable(true);
+ connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
+ settingsMenu->addAction(fullscreenAction);
+#endif
QMenu *propertiesMenu = new QMenu(tr("Properties"));
QActionGroup *orientation = new QActionGroup(parent);
@@ -568,6 +609,14 @@ void QmlViewer::setLandscape()
landscapeOrientation->setChecked(true);
}
+void QmlViewer::toggleFullScreen()
+{
+ if (isFullScreen())
+ showMaximized();
+ else
+ showFullScreen();
+}
+
void QmlViewer::setScaleSkin()
{
if (scaleSkin)
@@ -715,11 +764,6 @@ void QmlViewer::open()
{
QString cur = canvas->url().toLocalFile();
if (useQmlFileBrowser) {
-#ifdef Q_OS_SYMBIAN
- canvas->rootContext()->setContextProperty("initialFolder", "E:\\"); // Documents on your S60 phone
-#else
- canvas->rootContext()->setContextProperty("initialFolder", QDir::currentPath());
-#endif
openQml("qrc:/content/Browser.qml");
} else {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
@@ -758,6 +802,11 @@ void QmlViewer::openQml(const QString& file_or_url)
canvas->reset();
QmlContext *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
QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
@@ -811,7 +860,8 @@ void QmlViewer::openQml(const QString& file_or_url)
canvas->updateGeometry();
if (mb)
mb->updateGeometry();
- resize(sizeHint());
+ if (!isFullScreen() && !isMaximized())
+ resize(sizeHint());
} else {
if (scaleSkin)
canvas->resize(canvas->sizeHint());
@@ -826,6 +876,13 @@ void QmlViewer::openQml(const QString& file_or_url)
#endif
}
+void QmlViewer::startNetwork()
+{
+#if defined(SYMBIAN_NETWORK_INIT)
+ qt_SetDefaultIap();
+#endif
+}
+
QStringList QmlViewer::builtinSkins() const
{
QDir dir(":/skins/","*.skin");
@@ -1237,6 +1294,12 @@ void QmlViewer::setUseGL(bool useGL)
}
#endif
}
+
+void QmlViewer::setUseNativeFileBrowser(bool use)
+{
+ useQmlFileBrowser = !use;
+}
+
QT_END_NAMESPACE
#include "qmlviewer.moc"