diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-12-07 22:29:43 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-12-07 22:29:43 (GMT) |
commit | ef5850afa68f148ab72d46bf64a8a1be1a70bb3b (patch) | |
tree | be4d94ab6c8cfa6710ff4c2fb5f4dcfa4e364871 /tools/qmlviewer/qmlviewer.cpp | |
parent | 29e5c9b27302e455b1ae9d324687ded3a40066d2 (diff) | |
parent | 0a9aa40dd9865e61f2799a6396ce8dcaa68329c5 (diff) | |
download | Qt-ef5850afa68f148ab72d46bf64a8a1be1a70bb3b.zip Qt-ef5850afa68f148ab72d46bf64a8a1be1a70bb3b.tar.gz Qt-ef5850afa68f148ab72d46bf64a8a1be1a70bb3b.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts:
src/declarative/qml/qmlengine.cpp
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 77 |
1 files changed, 70 insertions, 7 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index a8901f9..dcf420e 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 = settingsMenu->addMenu(tr("Properties")); QActionGroup *orientation = new QActionGroup(parent); @@ -566,6 +607,14 @@ void QmlViewer::setLandscape() landscapeOrientation->setChecked(true); } +void QmlViewer::toggleFullScreen() +{ + if (isFullScreen()) + showMaximized(); + else + showFullScreen(); +} + void QmlViewer::setScaleSkin() { if (scaleSkin) @@ -713,11 +762,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)")); @@ -756,6 +800,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()) { @@ -809,7 +858,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()); @@ -824,6 +874,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"); @@ -1235,6 +1292,12 @@ void QmlViewer::setUseGL(bool useGL) } #endif } + +void QmlViewer::setUseNativeFileBrowser(bool use) +{ + useQmlFileBrowser = !use; +} + QT_END_NAMESPACE #include "qmlviewer.moc" |