diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-22 19:20:19 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-22 19:20:19 (GMT) |
commit | 74c6d263bebd0a3d74d0ca751985589c556c6c9b (patch) | |
tree | 2ab0c98c4e970c5c5988ce19d4cfb178d414a916 /tools | |
parent | 4894e6dd57c31e0196c6fdae4d1b2fb16b9f1b16 (diff) | |
parent | 0b6fd8966972616232054c5194243c52ca360bf8 (diff) | |
download | Qt-74c6d263bebd0a3d74d0ca751985589c556c6c9b.zip Qt-74c6d263bebd0a3d74d0ca751985589c556c6c9b.tar.gz Qt-74c6d263bebd0a3d74d0ca751985589c556c6c9b.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (135 commits)
Do not treat images in qml examples differently.
Replace Flickable overshoot property with boundsBehavior
Autotests and doc
Give error on attempt to import types from too-early version number.
Remove (undocumented) QML bindings for effects.
De-straighten them lines.
Doc: fix QStringList model doc (really).
Doc: fix QStringList model docs
Change return type to match value().
Add duration and easing properties to AnchorAnimation.
Autotest
Remove dead code
Compile on Windows (export decl fix).
Fix versioning of Qt Declarative's in-built types
Fixed declarative/parserstress autotest.
Fix parsing of regular expression literals.
Fill out QGraphicsLayout bindings
Update test files to new syntax
Compile without Qt3 support.
Ensure workerscript.qml works (autotested).
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qdoc3/cppcodeparser.cpp | 44 | ||||
-rw-r--r-- | tools/qdoc3/htmlgenerator.cpp | 4 | ||||
-rw-r--r-- | tools/qml/content/Browser.qml | 2 | ||||
-rw-r--r-- | tools/qml/loggerwidget.cpp | 70 | ||||
-rw-r--r-- | tools/qml/loggerwidget.h | 63 | ||||
-rw-r--r-- | tools/qml/main.cpp | 123 | ||||
-rw-r--r-- | tools/qml/qdeclarativefolderlistmodel.cpp | 2 | ||||
-rw-r--r-- | tools/qml/qdeclarativetester.cpp | 13 | ||||
-rw-r--r-- | tools/qml/qml.pri | 7 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 115 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 4 |
11 files changed, 341 insertions, 106 deletions
diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 6884781..13678af 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -492,7 +492,7 @@ const FunctionNode *CppCodeParser::findFunctionNode(const QString& synopsis, candidates << overload; } - + /* There are several functions with the correct parameter count, but only one has the correct @@ -545,7 +545,7 @@ QSet<QString> CppCodeParser::topicCommands() } /*! - Process the topic \a command in context \a doc with argument \a arg. + Process the topic \a command in context \a doc with argument \a arg. */ Node *CppCodeParser::processTopicCommand(const Doc& doc, const QString& command, @@ -731,7 +731,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, return new QmlClassNode(tre->root(), names[0], classNode); } else if (command == COMMAND_QMLBASICTYPE) { -#if 0 +#if 0 QStringList parts = arg.split(" "); qDebug() << command << parts; if (parts.size() > 1) { @@ -741,7 +741,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, return new QmlBasicTypeNode(pageNode, parts[0]); } } -#endif +#endif return new QmlBasicTypeNode(tre->root(), arg); } else if ((command == COMMAND_QMLSIGNAL) || @@ -912,13 +912,13 @@ QSet<QString> CppCodeParser::otherMetaCommands() << COMMAND_NEXTPAGE << COMMAND_PREVIOUSPAGE << COMMAND_INDEXPAGE -#ifdef QDOC_QML +#ifdef QDOC_QML << COMMAND_STARTPAGE << COMMAND_QMLINHERITS << COMMAND_QMLDEFAULT; -#else +#else << COMMAND_STARTPAGE; -#endif +#endif } /*! @@ -2119,7 +2119,7 @@ bool CppCodeParser::matchDocsAndStuff() } ++a; } -#endif +#endif } NodeList::Iterator n = nodes.begin(); @@ -2268,18 +2268,15 @@ void CppCodeParser::instantiateIteratorMacro(const QString &container, void CppCodeParser::createExampleFileNodes(FakeNode *fake) { QString examplePath = fake->name(); - - // we can assume that this file always exists - QString proFileName = examplePath + "/" + - examplePath.split("/").last() + ".pro"; - + QString proFileName = examplePath + "/" + examplePath.split("/").last() + ".pro"; QString userFriendlyFilePath; + QString fullPath = Config::findFile(fake->doc().location(), exampleFiles, exampleDirs, proFileName, userFriendlyFilePath); - + if (fullPath.isEmpty()) { QString tmp = proFileName; proFileName = examplePath + "/" + "qbuild.pro"; @@ -2290,9 +2287,18 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake) proFileName, userFriendlyFilePath); if (fullPath.isEmpty()) { - fake->doc().location().warning( - tr("Cannot find file '%1' or '%2'").arg(tmp).arg(proFileName)); - return; + proFileName = examplePath + "/" + examplePath.split("/").last() + ".qmlproject"; + userFriendlyFilePath.clear(); + fullPath = Config::findFile(fake->doc().location(), + exampleFiles, + exampleDirs, + proFileName, + userFriendlyFilePath); + if (fullPath.isEmpty()) { + fake->doc().location().warning( + tr("Cannot find file '%1' or '%2'").arg(tmp).arg(proFileName)); + return; + } } } @@ -2315,14 +2321,14 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake) i.remove(); } else if (fileName.contains("/qrc_") || fileName.contains("/moc_") - || fileName.contains("/ui_")) + || fileName.contains("/ui_")) i.remove(); } if (!mainCpp.isEmpty()) exampleFiles.append(mainCpp); // add any qmake Qt resource files and qmake project files - exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro"); + exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro qmldir"); } foreach (const QString &exampleFile, exampleFiles) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index bf2f724..9a5ffca 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4311,7 +4311,9 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << "<tr><td>"; out() << "<a name=\"" + refForNode(qpn) + "\"></a>"; if (!qpn->isWritable()) - out() << "<span class=\"qmlreadonly\">read-only</span>"; + out() << "<span class=\"qmlreadonly\">read-only </span>"; + if (qpgn->isDefault()) + out() << "<span class=\"qmldefault\">default </span>"; generateQmlItem(qpn, relative, marker, false); out() << "</td></tr>"; if (qpgn->isDefault()) { diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index 8882d5a..0912f58 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Rectangle { id: root diff --git a/tools/qml/loggerwidget.cpp b/tools/qml/loggerwidget.cpp new file mode 100644 index 0000000..015d1b0 --- /dev/null +++ b/tools/qml/loggerwidget.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "loggerwidget.h" +#include <qglobal.h> +#include <QDebug> + +QT_BEGIN_NAMESPACE + +LoggerWidget::LoggerWidget(QWidget *parent) : + QPlainTextEdit(parent), + m_keepClosed(false) +{ + setAttribute(Qt::WA_QuitOnClose, false); + setWindowTitle(tr("Qt Declarative UI Viewer - Logger")); +} + +void LoggerWidget::append(const QString &msg) +{ + appendPlainText(msg); + + if (!m_keepClosed && !isVisible()) + setVisible(true); +} + +void LoggerWidget::closeEvent(QCloseEvent *event) +{ + m_keepClosed = true; + QWidget::closeEvent(event); +} + +QT_END_NAMESPACE diff --git a/tools/qml/loggerwidget.h b/tools/qml/loggerwidget.h new file mode 100644 index 0000000..5c4a701 --- /dev/null +++ b/tools/qml/loggerwidget.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LOGGERWIDGET_H +#define LOGGERWIDGET_H + +#include <QPlainTextEdit> + +QT_BEGIN_NAMESPACE + +class LoggerWidget : public QPlainTextEdit { +Q_OBJECT +public: + LoggerWidget(QWidget *parent=0); +public slots: + void append(const QString &msg); +protected: + void closeEvent(QCloseEvent *event); +private: + bool m_keepClosed; +}; + +QT_END_NAMESPACE + +#endif // LOGGERWIDGET_H diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 45c2b85..cba5650 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -42,16 +42,20 @@ #include "qdeclarative.h" #include "qmlruntime.h" #include "qdeclarativeengine.h" +#include "loggerwidget.h" #include <QWidget> #include <QDir> #include <QApplication> #include <QTranslator> #include <QDebug> +#include <QMessageBox> #include "qdeclarativetester.h" #include "qdeclarativefolderlistmodel.h" QT_USE_NAMESPACE +QtMsgHandler systemMsgOutput; + #if defined (Q_OS_SYMBIAN) #include <unistd.h> #include <sys/types.h> @@ -73,6 +77,36 @@ void myMessageOutput(QtMsgType type, const char *msg) abort(); } } + +#else // !defined (Q_OS_SYMBIAN) + +QWeakPointer<LoggerWidget> logger; + +QString warnings; +void showWarnings() +{ + if (!warnings.isEmpty()) { + QMessageBox::warning(0, QApplication::tr("Qt Declarative UI Runtime"), warnings); + } +} + +void myMessageOutput(QtMsgType type, const char *msg) +{ + if (!logger.isNull()) { + QString strMsg = QString::fromAscii(msg); + QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); + } else { + warnings += msg; + warnings += QLatin1Char('\n'); + } + if (systemMsgOutput) { // Windows + systemMsgOutput(type, msg); + } else { // Unix + fprintf(stderr, "%s\n",msg); + fflush(stderr); + } +} + #endif void usage() @@ -88,7 +122,10 @@ void usage() qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame"); qWarning(" \"list\" for a list of built-ins"); qWarning(" -resizeview .............................. resize the view, not the skin"); + qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); + qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); + qWarning(" -nolog ................................... do not show log window"); qWarning(" -recordfile <output> ..................... set video recording file"); qWarning(" - ImageMagick 'convert' for GIF)"); qWarning(" - png file for raw frames"); @@ -135,6 +172,14 @@ int main(int argc, char ** argv) { #if defined (Q_OS_SYMBIAN) qInstallMsgHandler(myMessageOutput); +#else + systemMsgOutput = qInstallMsgHandler(myMessageOutput); +#endif + +#if defined (Q_OS_WIN) + // Debugging output is not visible by default on Windows - + // therefore show modal dialog with errors instad. + atexit(showWarnings); #endif #if defined (Q_WS_X11) @@ -184,6 +229,8 @@ int main(int argc, char ** argv) bool stayOnTop = false; bool maximized = false; bool useNativeFileBrowser = true; + bool showLogWidget = true; + bool sizeToView = true; #if defined(Q_OS_SYMBIAN) maximized = true; @@ -234,8 +281,8 @@ int main(int argc, char ** argv) if (lastArg) usage(); app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { - fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); - return 0; + qWarning("Qt Declarative UI Viewer version %s", QT_VERSION_STR); + exit(0); } else if (arg == "-translation") { if (lastArg) usage(); translationFile = argv[++i]; @@ -243,14 +290,16 @@ int main(int argc, char ** argv) useGL = true; } else if (arg == "-qmlbrowser") { useNativeFileBrowser = false; + } else if (arg == "-nolog") { + showLogWidget = false; } else if (arg == "-I" || arg == "-L") { if (arg == "-L") - fprintf(stderr, "-L option provided for compatibility only, use -I instead\n"); + qWarning("-L option provided for compatibility only, use -I instead"); if (lastArg) { QDeclarativeEngine tmpEngine; QString paths = tmpEngine.importPathList().join(QLatin1String(":")); - fprintf(stderr, "Current search path: %s\n", paths.toLocal8Bit().constData()); - return 0; + qWarning("Current search path: %s", paths.toLocal8Bit().constData()); + exit(0); } imports << QString(argv[++i]); } else if (arg == "-P") { @@ -270,6 +319,10 @@ int main(int argc, char ** argv) if (lastArg) usage(); script = QString(argv[++i]); runScript = true; + } else if (arg == "-sizeviewtorootobject") { + sizeToView = false; + } else if (arg == "-sizerootobjecttoview") { + sizeToView = true; } else if (arg[0] != '-') { fileName = arg; } else if (1 || arg == "-help") { @@ -287,7 +340,14 @@ int main(int argc, char ** argv) if (stayOnTop) wflags |= Qt::WindowStaysOnTopHint; - QDeclarativeViewer viewer(0, wflags); +#if !defined(Q_OS_SYMBIAN) + LoggerWidget loggerWidget(0); + if (showLogWidget) { + logger = &loggerWidget; + } +#endif + + QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags); if (!scriptopts.isEmpty()) { QStringList options = scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); @@ -323,44 +383,45 @@ int main(int argc, char ** argv) if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play)) scriptOptsUsage(); - viewer.setScriptOptions(scriptOptions); - viewer.setScript(script); + viewer->setScriptOptions(scriptOptions); + viewer->setScript(script); } else if (!script.isEmpty()) { usage(); } - viewer.addLibraryPath(QCoreApplication::applicationDirPath()); + viewer->addLibraryPath(QCoreApplication::applicationDirPath()); foreach (QString lib, imports) - viewer.addLibraryPath(lib); + viewer->addLibraryPath(lib); foreach (QString plugin, plugins) - viewer.addPluginPath(plugin); + viewer->addPluginPath(plugin); - viewer.setNetworkCacheSize(cache); - viewer.setRecordFile(recordfile); + viewer->setNetworkCacheSize(cache); + viewer->setRecordFile(recordfile); + viewer->setSizeToView(sizeToView); if (resizeview) - viewer.setScaleView(); + viewer->setScaleView(); if (fps>0) - viewer.setRecordRate(fps); + viewer->setRecordRate(fps); if (autorecord_to) - viewer.setAutoRecord(autorecord_from,autorecord_to); + viewer->setAutoRecord(autorecord_from,autorecord_to); if (!skin.isEmpty()) { if (skin == "list") { - foreach (QString s, viewer.builtinSkins()) + foreach (QString s, viewer->builtinSkins()) qWarning() << qPrintable(s); exit(0); } else { - viewer.setSkin(skin); + viewer->setSkin(skin); } } if (devkeys) - viewer.setDeviceKeys(true); - viewer.setRecordDither(dither); + viewer->setDeviceKeys(true); + viewer->setRecordDither(dither); if (recordargs.count()) - viewer.setRecordArgs(recordargs); + viewer->setRecordArgs(recordargs); - viewer.setUseNativeFileBrowser(useNativeFileBrowser); + viewer->setUseNativeFileBrowser(useNativeFileBrowser); if (fullScreen && maximized) qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; @@ -379,17 +440,19 @@ int main(int argc, char ** argv) } if (!fileName.isEmpty()) { - viewer.open(fileName); - fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show(); + viewer->open(fileName); + fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); } else { if (!useNativeFileBrowser) - viewer.openFile(); - fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show(); + viewer->openFile(); + fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); if (useNativeFileBrowser) - viewer.openFile(); + viewer->openFile(); } - viewer.setUseGL(useGL); - viewer.raise(); + viewer->setUseGL(useGL); + viewer->raise(); - return app.exec(); + int rv = app.exec(); + delete viewer; + exit(rv); } diff --git a/tools/qml/qdeclarativefolderlistmodel.cpp b/tools/qml/qdeclarativefolderlistmodel.cpp index d36033d..5a9d88b 100644 --- a/tools/qml/qdeclarativefolderlistmodel.cpp +++ b/tools/qml/qdeclarativefolderlistmodel.cpp @@ -413,7 +413,7 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) void QDeclarativeFolderListModel::registerTypes() { - qmlRegisterType<QDeclarativeFolderListModel>("Qt",4,6,"FolderListModel"); + qmlRegisterType<QDeclarativeFolderListModel>("Qt",4,7,"FolderListModel"); } QT_END_NAMESPACE diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index 11fa22f..9864df6 100644 --- a/tools/qml/qdeclarativetester.cpp +++ b/tools/qml/qdeclarativetester.cpp @@ -181,7 +181,7 @@ void QDeclarativeTester::save() file.open(QIODevice::WriteOnly); QTextStream ts(&file); - ts << "import Qt.VisualTest 4.6\n\n"; + ts << "import Qt.VisualTest 4.7\n\n"; ts << "VisualTest {\n"; int imgCount = 0; @@ -251,7 +251,8 @@ void QDeclarativeTester::updateCurrentTime(int msec) m_view->render(&p); } - bool snapshot = msec == 16 && options & QDeclarativeViewer::Snapshot; + bool snapshot = msec == 16 && (options & QDeclarativeViewer::Snapshot + || (testscript && testscript->count() == 2)); FrameEvent fe; fe.msec = msec; @@ -397,10 +398,10 @@ void QDeclarativeTester::updateCurrentTime(int msec) void QDeclarativeTester::registerTypes() { - qmlRegisterType<QDeclarativeVisualTest>("Qt.VisualTest", 4,6, "VisualTest"); - qmlRegisterType<QDeclarativeVisualTestFrame>("Qt.VisualTest", 4,6, "Frame"); - qmlRegisterType<QDeclarativeVisualTestMouse>("Qt.VisualTest", 4,6, "Mouse"); - qmlRegisterType<QDeclarativeVisualTestKey>("Qt.VisualTest", 4,6, "Key"); + qmlRegisterType<QDeclarativeVisualTest>("Qt.VisualTest", 4,7, "VisualTest"); + qmlRegisterType<QDeclarativeVisualTestFrame>("Qt.VisualTest", 4,7, "Frame"); + qmlRegisterType<QDeclarativeVisualTestMouse>("Qt.VisualTest", 4,7, "Mouse"); + qmlRegisterType<QDeclarativeVisualTestKey>("Qt.VisualTest", 4,7, "Key"); } QT_END_NAMESPACE diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index c48e919..d343c76 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -10,11 +10,13 @@ HEADERS += $$PWD/qmlruntime.h \ $$PWD/proxysettings.h \ $$PWD/qdeclarativetester.h \ $$PWD/deviceorientation.h \ - $$PWD/qdeclarativefolderlistmodel.h + $$PWD/qdeclarativefolderlistmodel.h \ + $$PWD/loggerwidget.h SOURCES += $$PWD/qmlruntime.cpp \ $$PWD/proxysettings.cpp \ $$PWD/qdeclarativetester.cpp \ - $$PWD/qdeclarativefolderlistmodel.cpp + $$PWD/qdeclarativefolderlistmodel.cpp \ + $$PWD/loggerwidget.cpp RESOURCES = $$PWD/qmlruntime.qrc maemo5 { @@ -26,4 +28,3 @@ FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui include(../shared/deviceskin/deviceskin.pri) - diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 53409c1..87a4d21 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -496,7 +496,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) canvas = new QDeclarativeView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); + canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); @@ -519,7 +519,6 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) #else setCentralWidget(canvas); #endif - namFactory = new NetworkAccessManagerFactory; canvas->engine()->setNetworkAccessManagerFactory(namFactory); @@ -753,10 +752,11 @@ void QDeclarativeViewer::setScaleSkin() if (scaleSkin) return; scaleSkin = true; - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); if (skin) { - canvas->setFixedSize(canvas->sizeHint()); - skin->setScreenSize(canvas->sizeHint()); + canvas->resize(initialSize); + canvas->setFixedSize(initialSize); + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + updateSizeHints(); } } @@ -766,11 +766,8 @@ void QDeclarativeViewer::setScaleView() return; scaleSkin = false; if (skin) { - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(16777215,16777215)); - canvas->resize(skin->standardScreenSize()); - skin->setScreenSize(skin->standardScreenSize()); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + updateSizeHints(); } } @@ -916,19 +913,12 @@ void QDeclarativeViewer::statusChanged() tester->executefailure(); if (canvas->status() == QDeclarativeView::Ready) { - if (!skin) { - canvas->updateGeometry(); - if (mb) - mb->updateGeometry(); - if (!isFullScreen() && !isMaximized()) - resize(sizeHint()); - } else { - if (scaleSkin) - canvas->resize(canvas->sizeHint()); - else { - canvas->setFixedSize(skin->standardScreenSize()); - canvas->resize(skin->standardScreenSize()); - } + initialSize = canvas->sizeHint(); + if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { + QSize newWindowSize = initialSize; + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + updateSizeHints(); + resize(newWindowSize); } } } @@ -1011,8 +1001,6 @@ bool QDeclarativeViewer::open(const QString& file_or_url) canvas->setSource(url); - qWarning() << "Wall startup time:" << t.elapsed(); - return true; } @@ -1056,41 +1044,43 @@ void QDeclarativeViewer::setSkin(const QString& skinDirOrName) skin->deleteLater(); } - canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject); - DeviceSkinParameters parameters; if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { layout()->setEnabled(false); - //setMenuBar(0); if (mb) mb->hide(); if (!err.isEmpty()) qWarning() << err; skin = new PreviewDeviceSkin(parameters,this); - canvas->resize(canvas->sizeHint()); if (scaleSkin) skin->setPreviewAndScale(canvas); else skin->setPreview(canvas); createMenu(0,skin->menu); + if (scaleSkin) { + canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); + } + updateSizeHints(); skin->show(); - } else { + } else if (skin) { skin = 0; clearMask(); menuBar()->clear(); - canvas->setParent(this, Qt::SubWindow); createMenu(menuBar(),0); - mb->show(); - setMinimumSize(QSize(0,0)); - setMaximumSize(QSize(16777215,16777215)); - canvas->setMinimumSize(QSize(0,0)); - canvas->setMaximumSize(QSize(16777215,16777215)); - QRect g = geometry(); - g.setSize(sizeHint()); + canvas->setParent(this, Qt::SubWindow); setParent(0,windowFlags()); // recreate - canvas->move(0,menuBar()->sizeHint().height()); - setGeometry(g); + mb->show(); + canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); + updateSizeHints(); + layout()->setEnabled(true); + if (!scaleSkin) { + canvas->resize(initialSize); + canvas->setFixedSize(initialSize); + } + QSize newWindowSize = canvas->size(); + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + resize(newWindowSize); show(); } canvas->show(); @@ -1122,9 +1112,10 @@ void QDeclarativeViewer::setRecordRate(int fps) void QDeclarativeViewer::sceneResized(QSize size) { if (size.width() > 0 && size.height() > 0) { - if (skin && scaleSkin) - skin->setScreenSize(size); - } + if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { + updateSizeHints(); + } + } } void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) @@ -1397,13 +1388,49 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use) useQmlFileBrowser = !use; } +void QDeclarativeViewer::setSizeToView(bool sizeToView) +{ + QDeclarativeView::ResizeMode resizeMode = sizeToView ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject; + if (resizeMode != canvas->resizeMode()) { + canvas->setResizeMode(resizeMode); + updateSizeHints(); + } +} + +void QDeclarativeViewer::updateSizeHints() +{ + if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { + QSize newWindowSize = canvas->sizeHint(); + if (!skin) { + newWindowSize.setHeight(newWindowSize.height()+menuBar()->height()); + } + if (!isFullScreen() && !isMaximized()) { + resize(newWindowSize); + setFixedSize(newWindowSize); + if (skin && scaleSkin) { + skin->setScreenSize(newWindowSize); + } + } + } else { // QDeclarativeView::SizeRootObjectToView + canvas->setMinimumSize(QSize(0,0)); + canvas->setMaximumSize(QSize(16777215,16777215)); + setMinimumSize(QSize(0,0)); + setMaximumSize(QSize(16777215,16777215)); + if (skin && !scaleSkin) { + canvas->setFixedSize(skin->standardScreenSize()); + skin->setScreenSize(skin->standardScreenSize()); + } + } + updateGeometry(); +} + void QDeclarativeViewer::registerTypes() { static bool registered = false; if (!registered) { // registering only for exposing the DeviceOrientation::Orientation enum - qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation"); + qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation",""); registered = true; } } diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 2089dda..a00a703 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -100,7 +100,8 @@ public: void addPluginPath(const QString& plugin); void setUseGL(bool use); void setUseNativeFileBrowser(bool); - + void updateSizeHints(); + void setSizeToView(bool sizeToView); QStringList builtinSkins() const; QMenuBar *menuBar() const; @@ -149,6 +150,7 @@ private: PreviewDeviceSkin *skin; QSize skinscreensize; QDeclarativeView *canvas; + QSize initialSize; QString currentFileOrUrl; QDeclarativeTimer recordTimer; QString frame_fmt; |