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 | |
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')
-rw-r--r-- | tools/qmlviewer/content/Browser.qml | 4 | ||||
-rw-r--r-- | tools/qmlviewer/main.cpp | 45 | ||||
-rw-r--r-- | tools/qmlviewer/qmlfolderlistmodel.cpp | 24 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 77 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.h | 11 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.pro | 8 |
6 files changed, 152 insertions, 17 deletions
diff --git a/tools/qmlviewer/content/Browser.qml b/tools/qmlviewer/content/Browser.qml index ce9aed2..7643a57 100644 --- a/tools/qmlviewer/content/Browser.qml +++ b/tools/qmlviewer/content/Browser.qml @@ -11,12 +11,12 @@ Rectangle { FolderListModel { id: folders1 nameFilters: [ "*.qml" ] - folder: initialFolder + folder: qmlViewerFolder } FolderListModel { id: folders2 nameFilters: [ "*.qml" ] - folder: initialFolder + folder: qmlViewerFolder } SystemPalette { id: palette } diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index ac0d732..412d3ef 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -47,6 +47,29 @@ #include <QTranslator> #include <QDebug> +#if defined (Q_OS_SYMBIAN) +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +void myMessageOutput(QtMsgType type, const char *msg) +{ + static int fd = -1; + if (fd == -1) + fd = ::open("E:\\qmlviewer.log", O_WRONLY | O_CREAT); + + ::write(fd, msg, strlen(msg)); + ::write(fd, "\n", 1); + ::fsync(fd); + + switch (type) { + case QtFatalMsg: + abort(); + } +} +#endif + void usage() { qWarning("Usage: qmlviewer [options] <filename>"); @@ -99,6 +122,10 @@ void scriptOptsUsage() int main(int argc, char ** argv) { +#if defined (Q_OS_SYMBIAN) + qInstallMsgHandler(myMessageOutput); +#endif + //### default to using raster graphics backend for now bool gsSpecified = false; for (int i = 0; i < argc; ++i) { @@ -108,8 +135,11 @@ int main(int argc, char ** argv) break; } } + +#if !defined (Q_OS_SYMBIAN) if (!gsSpecified) QApplication::setGraphicsSystem("raster"); +#endif QApplication app(argc, argv); app.setApplicationName("viewer"); @@ -137,6 +167,12 @@ int main(int argc, char ** argv) bool fullScreen = false; bool stayOnTop = false; bool maximized = false; + bool useNativeFileBrowser = true; + +#if defined(Q_OS_SYMBIAN) + maximized = true; + useNativeFileBrowser = false; +#endif for (int i = 1; i < argc; ++i) { bool lastArg = (i == argc - 1); @@ -219,7 +255,7 @@ int main(int argc, char ** argv) Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget); if (stayOnTop) wflags |= Qt::WindowStaysOnTopHint; - + QmlViewer viewer(0, wflags); if (!scriptopts.isEmpty()) { QStringList options = @@ -285,14 +321,19 @@ int main(int argc, char ** argv) viewer.setRecordDither(dither); if (recordargs.count()) viewer.setRecordArgs(recordargs); + + viewer.setUseNativeFileBrowser(useNativeFileBrowser); if (fullScreen && maximized) qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; if (!fileName.isEmpty()) { viewer.openQml(fileName); fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show(); } else { + if (!useNativeFileBrowser) + viewer.open(); fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show(); - viewer.open(); + if (useNativeFileBrowser) + viewer.open(); } viewer.raise(); diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 14d2324..4cbc426 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -193,11 +193,25 @@ void QmlFolderListModel::setFolder(const QUrl &folder) QUrl QmlFolderListModel::parentFolder() const { - int pos = d->folder.path().lastIndexOf(QLatin1Char('/')); - if (pos == -1) - return QUrl(); - QUrl r = d->folder; - r.setPath(d->folder.path().left(pos)); + QUrl r; + QString localFile = d->folder.toLocalFile(); + if (!localFile.isEmpty()) { + QDir dir(localFile); +#if defined(Q_OS_SYMBIAN) + if (dir.isRoot()) + dir.setPath(""); + else +#endif + dir.cdUp(); + r = d->folder; + r.setPath(dir.path()); + } else { + int pos = d->folder.path().lastIndexOf(QLatin1Char('/')); + if (pos == -1) + return QUrl(); + r = d->folder; + r.setPath(d->folder.path().left(pos)); + } return r; } 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" diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index c7d5c24..717258c 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -42,6 +42,7 @@ #ifndef QMLVIEWER_H #define QMLVIEWER_H +#include <QMainWindow> #include <QMenuBar> #include <private/qmltimer_p.h> #include <QTime> @@ -56,7 +57,12 @@ class QProcess; class RecordingDialog; class QmlGraphicsTester; -class QmlViewer : public QWidget +class QmlViewer +#if defined(Q_OS_SYMBIAN) + : public QMainWindow +#else + : public QWidget +#endif { Q_OBJECT public: @@ -85,6 +91,7 @@ public: void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); void setUseGL(bool use); + void setUseNativeFileBrowser(bool); QStringList builtinSkins() const; @@ -122,6 +129,8 @@ private slots: void adjustSizeSlot(); void setPortrait(); void setLandscape(); + void startNetwork(); + void toggleFullScreen(); private: void setupProxy(); diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 2024cff..35e4ba8 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -44,3 +44,11 @@ QT += scripttools \ webkit \ phonon } +symbian { +# TARGET.UID3 = + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h + LIBS += -lesock -lconnmon -linsock + TARGET.CAPABILITY = NetworkServices +} |