diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-30 06:49:37 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-30 06:49:37 (GMT) |
commit | 7164fdd762d128eaff681b97f00d95c8bf8cecf3 (patch) | |
tree | 90dcc1e545dbdab5b8f7480c050bb684ac5d7d36 /tools | |
parent | 91119eaa185934d568d0c83e25129b0028b5a607 (diff) | |
parent | ca61cd321b867d912bd13b0530fbf2847d1c593c (diff) | |
download | Qt-7164fdd762d128eaff681b97f00d95c8bf8cecf3.zip Qt-7164fdd762d128eaff681b97f00d95c8bf8cecf3.tar.gz Qt-7164fdd762d128eaff681b97f00d95c8bf8cecf3.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:
Add missing image
Mention scope of id uniqueness
Update QML Documents example
add license header
doc: Add a note about QCoreApplication::applicationDirPath
Add license header
Add moving and flicking properties to PathView
Improve utility of QMLViewer
Add missing \l doc commands
Document elements that are focus scopes.
Remove use of shared NOTIFY signals in QGraphicsScale
Remove use of shared NOTIFY signals
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/Info_mac.plist | 31 | ||||
-rw-r--r-- | tools/qml/browser/Browser.qml (renamed from tools/qml/content/Browser.qml) | 0 | ||||
-rw-r--r-- | tools/qml/browser/browser.qrc | 9 | ||||
-rw-r--r-- | tools/qml/browser/images/folder.png (renamed from tools/qml/content/images/folder.png) | bin | 1841 -> 1841 bytes | |||
-rw-r--r-- | tools/qml/browser/images/titlebar.png (renamed from tools/qml/content/images/titlebar.png) | bin | 1436 -> 1436 bytes | |||
-rw-r--r-- | tools/qml/browser/images/titlebar.sci (renamed from tools/qml/content/images/titlebar.sci) | 0 | ||||
-rw-r--r-- | tools/qml/browser/images/up.png (renamed from tools/qml/content/images/up.png) | bin | 662 -> 662 bytes | |||
-rw-r--r-- | tools/qml/main.cpp | 476 | ||||
-rw-r--r-- | tools/qml/qml.pri | 4 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 62 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 1 | ||||
-rw-r--r-- | tools/qml/qmlruntime.qrc | 9 | ||||
-rw-r--r-- | tools/qml/startup/Logo.qml | 179 | ||||
-rw-r--r-- | tools/qml/startup/qt-back.png | bin | 0 -> 3549 bytes | |||
-rw-r--r-- | tools/qml/startup/qt-blue.jpg | bin | 0 -> 20900 bytes | |||
-rw-r--r-- | tools/qml/startup/qt-front.png | bin | 0 -> 3318 bytes | |||
-rw-r--r-- | tools/qml/startup/qt-sketch.jpg | bin | 0 -> 17048 bytes | |||
-rw-r--r-- | tools/qml/startup/qt-text.png | bin | 0 -> 14565 bytes | |||
-rw-r--r-- | tools/qml/startup/quick-blur.png | bin | 0 -> 2826 bytes | |||
-rw-r--r-- | tools/qml/startup/quick-regular.png | bin | 0 -> 1399 bytes | |||
-rw-r--r-- | tools/qml/startup/shadow.png | bin | 0 -> 1592 bytes | |||
-rw-r--r-- | tools/qml/startup/startup.qml | 167 | ||||
-rw-r--r-- | tools/qml/startup/startup.qrc | 16 | ||||
-rw-r--r-- | tools/qml/startup/white-star.png | bin | 0 -> 2651 bytes |
24 files changed, 761 insertions, 193 deletions
diff --git a/tools/qml/Info_mac.plist b/tools/qml/Info_mac.plist index 80ca6a3..0877547 100644 --- a/tools/qml/Info_mac.plist +++ b/tools/qml/Info_mac.plist @@ -14,5 +14,36 @@ <string>@TYPEINFO@</string> <key>CFBundleExecutable</key> <string>@EXECUTABLE@</string> + <key>UTExportedTypeDeclarations</key> + <array> + <dict> + <key>UTTypeIdentifier</key> + <string>com.nokia.qt.qml</string> + <key>UTTypeDescription</key> + <string>Qt Markup Language</string> + <key>UTTypeConformsTo</key> + <array> + <string>public.plain-text</string> + </array> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qml</string> + </array> + </dict> + </dict> + </array> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>LSItemContentTypes</key> + <array> + <string>com.nokia.qt.qml</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> </dict> </plist> diff --git a/tools/qml/content/Browser.qml b/tools/qml/browser/Browser.qml index ff2bb47..ff2bb47 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/browser/Browser.qml diff --git a/tools/qml/browser/browser.qrc b/tools/qml/browser/browser.qrc new file mode 100644 index 0000000..9c688e7 --- /dev/null +++ b/tools/qml/browser/browser.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/browser"> + <file>Browser.qml</file> + <file>images/up.png</file> + <file>images/folder.png</file> + <file>images/titlebar.sci</file> + <file>images/titlebar.png</file> + </qresource> +</RCC> diff --git a/tools/qml/content/images/folder.png b/tools/qml/browser/images/folder.png Binary files differindex e53e2ad..e53e2ad 100644 --- a/tools/qml/content/images/folder.png +++ b/tools/qml/browser/images/folder.png diff --git a/tools/qml/content/images/titlebar.png b/tools/qml/browser/images/titlebar.png Binary files differindex 51c9008..51c9008 100644 --- a/tools/qml/content/images/titlebar.png +++ b/tools/qml/browser/images/titlebar.png diff --git a/tools/qml/content/images/titlebar.sci b/tools/qml/browser/images/titlebar.sci index 0418d94..0418d94 100644 --- a/tools/qml/content/images/titlebar.sci +++ b/tools/qml/browser/images/titlebar.sci diff --git a/tools/qml/content/images/up.png b/tools/qml/browser/images/up.png Binary files differindex b05f802..b05f802 100644 --- a/tools/qml/content/images/up.png +++ b/tools/qml/browser/images/up.png diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 4b1162e..7421b5e 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -56,7 +56,8 @@ QT_USE_NAMESPACE QtMsgHandler systemMsgOutput = 0; - +static QDeclarativeViewer *openFile(const QString &fileName); +static void showViewer(QDeclarativeViewer *viewer); #if defined (Q_OS_SYMBIAN) #include <unistd.h> @@ -117,6 +118,11 @@ void myMessageOutput(QtMsgType type, const char *msg) #endif +static QDeclarativeViewer* globalViewer = 0; + +// The qml file that is shown if the user didn't specify a QML file +QString initialFile = "qrc:/startup/startup.qml"; + void usage() { qWarning("Usage: qmlviewer [options] <filename>"); @@ -175,135 +181,200 @@ void scriptOptsUsage() enum WarningsConfig { ShowWarnings, HideWarnings, DefaultWarnings }; -int main(int argc, char ** argv) +struct ViewerOptions { -#if defined (Q_OS_SYMBIAN) - qInstallMsgHandler(myMessageOutput); -#else - systemMsgOutput = qInstallMsgHandler(myMessageOutput); + ViewerOptions() + : frameless(false), + fps(0.0), + autorecord_from(0), + autorecord_to(0), + dither("none"), + runScript(false), + devkeys(false), + cache(0), + useGL(false), + fullScreen(false), + stayOnTop(false), + maximized(false), + useNativeFileBrowser(true), + experimentalGestures(false), + warningsConfig(DefaultWarnings), + sizeToView(true) + { +#if defined(Q_OS_SYMBIAN) + maximized = true; + useNativeFileBrowser = false; #endif -#if defined (Q_OS_WIN) - // Debugging output is not visible by default on Windows - - // therefore show modal dialog with errors instad. - atexit(showWarnings); +#if defined(Q_WS_MAC) + useGL = true; #endif - -#if defined (Q_WS_X11) || defined (Q_WS_MAC) - //### default to using raster graphics backend for now - bool gsSpecified = false; - for (int i = 0; i < argc; ++i) { - QString arg = argv[i]; - if (arg == "-graphicssystem") { - gsSpecified = true; - break; - } } - if (!gsSpecified) - QApplication::setGraphicsSystem("raster"); -#endif - - QApplication app(argc, argv); - app.setApplicationName("QtQmlViewer"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); - - - - QDeclarativeViewer::registerTypes(); - QDeclarativeTester::registerTypes(); - - bool frameless = false; - QString fileName; - double fps = 0; - int autorecord_from = 0; - int autorecord_to = 0; - QString dither = "none"; + bool frameless; + double fps; + int autorecord_from; + int autorecord_to; + QString dither; QString recordfile; QStringList recordargs; QStringList imports; QStringList plugins; QString script; QString scriptopts; - bool runScript = false; - bool devkeys = false; - int cache = 0; + bool runScript; + bool devkeys; + int cache; QString translationFile; - bool useGL = false; - bool fullScreen = false; - bool stayOnTop = false; - bool maximized = false; - bool useNativeFileBrowser = true; - bool experimentalGestures = false; + bool useGL; + bool fullScreen; + bool stayOnTop; + bool maximized; + bool useNativeFileBrowser; + bool experimentalGestures; - WarningsConfig warningsConfig = DefaultWarnings; - bool sizeToView = true; + WarningsConfig warningsConfig; + bool sizeToView; -#if defined(Q_OS_SYMBIAN) - maximized = true; - useNativeFileBrowser = false; -#endif + QDeclarativeViewer::ScriptOptions scriptOptions; +}; -#if defined(Q_WS_MAC) - useGL = true; -#endif +static ViewerOptions opts; +static QStringList fileNames; - for (int i = 1; i < argc; ++i) { - bool lastArg = (i == argc - 1); - QString arg = argv[i]; +class Application : public QApplication +{ + Q_OBJECT +public: + Application(int &argc, char **&argv) + : QApplication(argc, argv) + {} + +protected: + bool event(QEvent *ev) + { + if (ev->type() != QEvent::FileOpen) + return QApplication::event(ev); + + QFileOpenEvent *fev = static_cast<QFileOpenEvent *>(ev); + + globalViewer->open(fev->file()); + if (!globalViewer->isVisible()) + showViewer(globalViewer); + + return true; + } + +private Q_SLOTS: + void showInitialViewer() + { + QApplication::processEvents(); + + QDeclarativeViewer *viewer = globalViewer; + if (!viewer) + return; + if (viewer->currentFile().isEmpty()) { + if(opts.useNativeFileBrowser) + viewer->open(initialFile); + else + viewer->openFile(); + } + if (!viewer->isVisible()) + showViewer(viewer); + } +}; + +static void parseScriptOptions() +{ + QStringList options = + opts.scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); + + QDeclarativeViewer::ScriptOptions scriptOptions = 0; + for (int i = 0; i < options.count(); ++i) { + const QString &option = options.at(i); + if (option == QLatin1String("help")) { + scriptOptsUsage(); + } else if (option == QLatin1String("play")) { + scriptOptions |= QDeclarativeViewer::Play; + } else if (option == QLatin1String("record")) { + scriptOptions |= QDeclarativeViewer::Record; + } else if (option == QLatin1String("testimages")) { + scriptOptions |= QDeclarativeViewer::TestImages; + } else if (option == QLatin1String("testerror")) { + scriptOptions |= QDeclarativeViewer::TestErrorProperty; + } else if (option == QLatin1String("exitoncomplete")) { + scriptOptions |= QDeclarativeViewer::ExitOnComplete; + } else if (option == QLatin1String("exitonfailure")) { + scriptOptions |= QDeclarativeViewer::ExitOnFailure; + } else if (option == QLatin1String("saveonexit")) { + scriptOptions |= QDeclarativeViewer::SaveOnExit; + } else if (option == QLatin1String("snapshot")) { + scriptOptions |= QDeclarativeViewer::Snapshot; + } else { + scriptOptsUsage(); + } + } + + opts.scriptOptions = scriptOptions; +} + +static void parseCommandLineOptions(const QStringList &arguments) +{ + for (int i = 1; i < arguments.count(); ++i) { + bool lastArg = (i == arguments.count() - 1); + QString arg = arguments.at(i); if (arg == "-frameless") { - frameless = true; + opts.frameless = true; } else if (arg == "-maximized") { - maximized = true; + opts.maximized = true; } else if (arg == "-fullscreen") { - fullScreen = true; + opts.fullScreen = true; } else if (arg == "-stayontop") { - stayOnTop = true; + opts.stayOnTop = true; } else if (arg == "-netcache") { if (lastArg) usage(); - cache = QString(argv[++i]).toInt(); + opts.cache = arguments.at(++i).toInt(); } else if (arg == "-recordrate") { if (lastArg) usage(); - fps = QString(argv[++i]).toDouble(); + opts.fps = arguments.at(++i).toDouble(); } else if (arg == "-recordfile") { if (lastArg) usage(); - recordfile = QString(argv[++i]); + opts.recordfile = arguments.at(++i); } else if (arg == "-record") { if (lastArg) usage(); - recordargs << QString(argv[++i]); + opts.recordargs << arguments.at(++i); } else if (arg == "-recorddither") { if (lastArg) usage(); - dither = QString(argv[++i]); + opts.dither = arguments.at(++i); } else if (arg == "-autorecord") { if (lastArg) usage(); - QString range = QString(argv[++i]); + QString range = arguments.at(++i); int dash = range.indexOf('-'); if (dash > 0) - autorecord_from = range.left(dash).toInt(); - autorecord_to = range.mid(dash+1).toInt(); + opts.autorecord_from = range.left(dash).toInt(); + opts.autorecord_to = range.mid(dash+1).toInt(); } else if (arg == "-devicekeys") { - devkeys = true; + opts.devkeys = true; } else if (arg == "-dragthreshold") { if (lastArg) usage(); - app.setStartDragDistance(QString(argv[++i]).toInt()); + qApp->setStartDragDistance(arguments.at(++i).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { qWarning("Qt QML Viewer version %s", QT_VERSION_STR); exit(0); } else if (arg == "-translation") { if (lastArg) usage(); - translationFile = argv[++i]; + opts.translationFile = arguments.at(++i); } else if (arg == "-opengl") { - useGL = true; + opts.useGL = true; } else if (arg == "-qmlbrowser") { - useNativeFileBrowser = false; + opts.useNativeFileBrowser = false; } else if (arg == "-warnings") { if (lastArg) usage(); - QString warningsStr = QString(argv[++i]); + QString warningsStr = arguments.at(++i); if (warningsStr == QLatin1String("show")) { - warningsConfig = ShowWarnings; + opts.warningsConfig = ShowWarnings; } else if (warningsStr == QLatin1String("hide")) { - warningsConfig = HideWarnings; + opts.warningsConfig = HideWarnings; } else { usage(); } @@ -316,152 +387,203 @@ int main(int argc, char ** argv) qWarning("Current search path: %s", paths.toLocal8Bit().constData()); exit(0); } - imports << QString(argv[++i]); + opts.imports << arguments.at(++i); } else if (arg == "-P") { if (lastArg) usage(); - plugins << QString(argv[++i]); + opts.plugins << arguments.at(++i); } else if (arg == "-script") { if (lastArg) usage(); - script = QString(argv[++i]); + opts.script = arguments.at(++i); } else if (arg == "-scriptopts") { if (lastArg) usage(); - scriptopts = QString(argv[++i]); + opts.scriptopts = arguments.at(++i); } else if (arg == "-savescript") { if (lastArg) usage(); - script = QString(argv[++i]); - runScript = false; + opts.script = arguments.at(++i); + opts.runScript = false; } else if (arg == "-playscript") { if (lastArg) usage(); - script = QString(argv[++i]); - runScript = true; + opts.script = arguments.at(++i); + opts.runScript = true; } else if (arg == "-sizeviewtorootobject") { - sizeToView = false; + opts.sizeToView = false; } else if (arg == "-sizerootobjecttoview") { - sizeToView = true; + opts.sizeToView = true; } else if (arg == "-experimentalgestures") { - experimentalGestures = true; - } else if (arg[0] != '-') { - fileName = arg; - } else if (1 || arg == "-help") { + opts.experimentalGestures = true; + } else if (!arg.startsWith('-')) { + fileNames.append(arg); + } else if (true || arg == "-help") { usage(); } } - QTranslator qmlTranslator; - if (!translationFile.isEmpty()) { - qmlTranslator.load(translationFile); - app.installTranslator(&qmlTranslator); + if (!opts.scriptopts.isEmpty()) { + + parseScriptOptions(); + + if (opts.script.isEmpty()) + usage(); + + if (!(opts.scriptOptions & QDeclarativeViewer::Record) && !(opts.scriptOptions & QDeclarativeViewer::Play)) + scriptOptsUsage(); + } else if (!opts.script.isEmpty()) { + usage(); } - Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget); - if (stayOnTop) +} + +static QDeclarativeViewer *createViewer() +{ + Qt::WFlags wflags = (opts.frameless ? Qt::FramelessWindowHint : Qt::Widget); + if (opts.stayOnTop) wflags |= Qt::WindowStaysOnTopHint; QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags); viewer->setAttribute(Qt::WA_DeleteOnClose, true); - if (!scriptopts.isEmpty()) { - QStringList options = - scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); - - QDeclarativeViewer::ScriptOptions scriptOptions = 0; - for (int i = 0; i < options.count(); ++i) { - const QString &option = options.at(i); - if (option == QLatin1String("help")) { - scriptOptsUsage(); - } else if (option == QLatin1String("play")) { - scriptOptions |= QDeclarativeViewer::Play; - } else if (option == QLatin1String("record")) { - scriptOptions |= QDeclarativeViewer::Record; - } else if (option == QLatin1String("testimages")) { - scriptOptions |= QDeclarativeViewer::TestImages; - } else if (option == QLatin1String("testerror")) { - scriptOptions |= QDeclarativeViewer::TestErrorProperty; - } else if (option == QLatin1String("exitoncomplete")) { - scriptOptions |= QDeclarativeViewer::ExitOnComplete; - } else if (option == QLatin1String("exitonfailure")) { - scriptOptions |= QDeclarativeViewer::ExitOnFailure; - } else if (option == QLatin1String("saveonexit")) { - scriptOptions |= QDeclarativeViewer::SaveOnExit; - } else if (option == QLatin1String("snapshot")) { - scriptOptions |= QDeclarativeViewer::Snapshot; - } else { - scriptOptsUsage(); - } - } - - if (script.isEmpty()) - usage(); - if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play)) - scriptOptsUsage(); - viewer->setScriptOptions(scriptOptions); - viewer->setScript(script); - } else if (!script.isEmpty()) { - usage(); + if (!opts.scriptopts.isEmpty()) { + viewer->setScriptOptions(opts.scriptOptions); + viewer->setScript(opts.script); } #if !defined(Q_OS_SYMBIAN) logger = viewer->warningsWidget(); - if (warningsConfig == ShowWarnings) { + if (opts.warningsConfig == ShowWarnings) { logger.data()->setDefaultVisibility(LoggerWidget::ShowWarnings); logger.data()->show(); - } else if (warningsConfig == HideWarnings){ + } else if (opts.warningsConfig == HideWarnings){ logger.data()->setDefaultVisibility(LoggerWidget::HideWarnings); } #endif - if (experimentalGestures) + if (opts.experimentalGestures) viewer->enableExperimentalGestures(); - foreach (QString lib, imports) + foreach (QString lib, opts.imports) viewer->addLibraryPath(lib); - foreach (QString plugin, plugins) + foreach (QString plugin, opts.plugins) viewer->addPluginPath(plugin); - viewer->setNetworkCacheSize(cache); - viewer->setRecordFile(recordfile); - viewer->setSizeToView(sizeToView); - if (fps>0) - viewer->setRecordRate(fps); - if (autorecord_to) - viewer->setAutoRecord(autorecord_from,autorecord_to); - if (devkeys) + viewer->setNetworkCacheSize(opts.cache); + viewer->setRecordFile(opts.recordfile); + viewer->setSizeToView(opts.sizeToView); + if (opts.fps > 0) + viewer->setRecordRate(opts.fps); + if (opts.autorecord_to) + viewer->setAutoRecord(opts.autorecord_from, opts.autorecord_to); + if (opts.devkeys) viewer->setDeviceKeys(true); - viewer->setRecordDither(dither); - if (recordargs.count()) - viewer->setRecordArgs(recordargs); + viewer->setRecordDither(opts.dither); + if (opts.recordargs.count()) + viewer->setRecordArgs(opts.recordargs); + + viewer->setUseNativeFileBrowser(opts.useNativeFileBrowser); - viewer->setUseNativeFileBrowser(useNativeFileBrowser); - if (fullScreen && maximized) + return viewer; +} + +void showViewer(QDeclarativeViewer *viewer) +{ + if (opts.fullScreen) + viewer->showFullScreen(); + else if (opts.maximized) + viewer->showMaximized(); + else + viewer->show(); + + viewer->setUseGL(opts.useGL); + viewer->raise(); +} + +QDeclarativeViewer *openFile(const QString &fileName) +{ + QDeclarativeViewer *viewer = globalViewer; + + viewer->open(fileName); + showViewer(viewer); + + return viewer; +} + +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) || defined (Q_WS_MAC) + //### default to using raster graphics backend for now + bool gsSpecified = false; + for (int i = 0; i < argc; ++i) { + QString arg = argv[i]; + if (arg == "-graphicssystem") { + gsSpecified = true; + break; + } + } + + if (!gsSpecified) + QApplication::setGraphicsSystem("raster"); +#endif + + Application app(argc, argv); + app.setApplicationName("QtQmlViewer"); + app.setOrganizationName("Nokia"); + app.setOrganizationDomain("nokia.com"); + + QDeclarativeViewer::registerTypes(); + QDeclarativeTester::registerTypes(); + + parseCommandLineOptions(app.arguments()); + + QTranslator qmlTranslator; + if (!opts.translationFile.isEmpty()) { + qmlTranslator.load(opts.translationFile); + app.installTranslator(&qmlTranslator); + } + + if (opts.fullScreen && opts.maximized) qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; - if (fileName.isEmpty()) { + if (fileNames.isEmpty()) { QFile qmlapp(QLatin1String("qmlapp")); if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) { - QString content = QString::fromUtf8(qmlapp.readAll()); - qmlapp.close(); - - int newline = content.indexOf(QLatin1Char('\n')); - if (newline >= 0) - fileName = content.left(newline); - else - fileName = content; - } + QString content = QString::fromUtf8(qmlapp.readAll()); + qmlapp.close(); + + int newline = content.indexOf(QLatin1Char('\n')); + if (newline >= 0) + fileNames += content.left(newline); + else + fileNames += content; + } } - if (!fileName.isEmpty()) { - viewer->open(fileName); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); + globalViewer = createViewer(); + + if (fileNames.isEmpty()) { + // show the initial viewer delayed. + // This prevents an initial viewer popping up while there + // are FileOpen events coming through the event queue + QTimer::singleShot(1, &app, SLOT(showInitialViewer())); } else { - if (!useNativeFileBrowser) - viewer->openFile(); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); - if (useNativeFileBrowser) - viewer->openFile(); + foreach (const QString &fileName, fileNames) + openFile(fileName); } - viewer->setUseGL(useGL); - viewer->raise(); + + QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); return app.exec(); } + +#include "main.moc" diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 80afb45..e5b2c7f 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -16,7 +16,9 @@ SOURCES += $$PWD/qmlruntime.cpp \ $$PWD/qdeclarativetester.cpp \ $$PWD/loggerwidget.cpp -RESOURCES = $$PWD/qmlruntime.qrc +RESOURCES = $$PWD/browser/browser.qrc \ + $$PWD/startup/startup.qrc + symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { SOURCES += $$PWD/deviceorientation_symbian.cpp FORMS = $$PWD/recopts.ui \ diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 951b187..08a578c 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -102,6 +102,49 @@ QT_BEGIN_NAMESPACE +class DragAndDropView : public QDeclarativeView +{ + Q_OBJECT +public: + DragAndDropView(QDeclarativeViewer *parent = 0) + : QDeclarativeView(parent) + { + setAcceptDrops(true); + } + + void dragEnterEvent(QDragEnterEvent *event) + { + const QMimeData *mimeData = event->mimeData(); + if (mimeData->hasUrls()) + event->acceptProposedAction(); + } + + void dragMoveEvent(QDragMoveEvent *event) + { + event->acceptProposedAction(); + } + + void dragLeaveEvent(QDragLeaveEvent *event) + { + event->accept(); + } + + void dropEvent(QDropEvent *event) + { + const QMimeData *mimeData = event->mimeData(); + if (!mimeData->hasUrls()) + return; + const QList<QUrl> urlList = mimeData->urls(); + foreach (const QUrl &url, urlList) { + if (url.scheme() == QLatin1String("file")) { + static_cast<QDeclarativeViewer *>(parent())->open(url.toLocalFile()); + event->accept(); + return; + } + } + } +}; + class Runtime : public QObject { Q_OBJECT @@ -596,7 +639,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) recdlg->warning->hide(); } - canvas = new QDeclarativeView(this); + canvas = new DragAndDropView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); @@ -605,7 +648,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged())); - QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); + QObject::connect(canvas->engine(), SIGNAL(quit()), this, SLOT(close())); QObject::connect(warningsWidget(), SIGNAL(opened()), this, SLOT(warningsWidgetOpened())); QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed())); @@ -664,11 +707,11 @@ LoggerWidget *QDeclarativeViewer::warningsWidget() const void QDeclarativeViewer::createMenu() { QAction *openAction = new QAction(tr("&Open..."), this); - openAction->setShortcut(QKeySequence("Ctrl+O")); + openAction->setShortcuts(QKeySequence::Open); connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); QAction *reloadAction = new QAction(tr("&Reload"), this); - reloadAction->setShortcut(QKeySequence("Ctrl+R")); + reloadAction->setShortcuts(QKeySequence::Refresh); connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this); @@ -717,10 +760,16 @@ void QDeclarativeViewer::createMenu() landscapeInvAction->setCheckable(true); QAction *aboutAction = new QAction(tr("&About Qt..."), this); + aboutAction->setMenuRole(QAction::AboutQtRole); connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + QAction *closeAction = new QAction(tr("&Close"), this); + closeAction->setShortcuts(QKeySequence::Close); + connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); + QAction *quitAction = new QAction(tr("&Quit"), this); - quitAction->setShortcut(QKeySequence("Ctrl+Q")); + quitAction->setMenuRole(QAction::QuitRole); + quitAction->setShortcuts(QKeySequence::Quit); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QMenuBar *menu = menuBar(); @@ -751,6 +800,7 @@ void QDeclarativeViewer::createMenu() fileMenu->addAction(openAction); fileMenu->addAction(reloadAction); fileMenu->addSeparator(); + fileMenu->addAction(closeAction); fileMenu->addAction(quitAction); #if !defined(Q_OS_SYMBIAN) @@ -927,7 +977,7 @@ void QDeclarativeViewer::openFile() { QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { - open("qrc:/content/Browser.qml"); + open("qrc:/browser/Browser.qml"); } else { QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); if (!fileName.isEmpty()) { diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 68d3452..7385b14 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,6 +105,7 @@ public: QDeclarativeView *view() const; LoggerWidget *warningsWidget() const; + QString currentFile() const { return currentFileOrUrl; } void enableExperimentalGestures(); diff --git a/tools/qml/qmlruntime.qrc b/tools/qml/qmlruntime.qrc deleted file mode 100644 index 3a9e608..0000000 --- a/tools/qml/qmlruntime.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/" > - <file>content/Browser.qml</file> - <file>content/images/up.png</file> - <file>content/images/folder.png</file> - <file>content/images/titlebar.sci</file> - <file>content/images/titlebar.png</file> - </qresource> -</RCC> diff --git a/tools/qml/startup/Logo.qml b/tools/qml/startup/Logo.qml new file mode 100644 index 0000000..8d9708d --- /dev/null +++ b/tools/qml/startup/Logo.qml @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + id: myApp + width: 411 + height: 411 + color: "transparent" + property alias logoState : myApp.state + signal animationFinished + + Item { + id: sketchBlueHolder + width: sketchLogo.width + height: sketchLogo.height + Image { + id: image1 + x: -44 + y: -45 + smooth: true + source: "shadow.png" + } + Item { + clip: true + width: sketchLogo.width + height: sketchLogo.height + Image { + id: sketchLogo + smooth: true + source: "qt-sketch.jpg" + } + Image { + id: blueLogo + y: -420 + smooth: true + source: "qt-blue.jpg" + } + } + } + + states: [ + State { + name: "showBlueprint" + PropertyChanges { + target: blueLogo + y: 0 + } + PropertyChanges { + target: sketchLogo + opacity: 0 + } + }, + State { + extend: "showBlueprint" + name: "finale" + PropertyChanges { + target: fullLogo + opacity: 1 + } + PropertyChanges { + target: backLogo + opacity: 1 + scale: 1 + } + PropertyChanges { + target: frontLogo + opacity: 1 + scale: 1 + } + PropertyChanges { + target: qtText + opacity: 1 + scale: 1 + } + PropertyChanges { + target: sketchBlueHolder + opacity: 0 + scale: 1.4 + } + } + ] + + transitions: [ + Transition { + to: "showBlueprint" + SequentialAnimation { + NumberAnimation { property: "y"; duration: 600; easing.type: "OutBounce" } + PropertyAction { target: sketchLogo; property: "opacity" } + } + }, + Transition { + to: "finale" + PropertyAction { target: fullLogo; property: "opacity" } + SequentialAnimation { + NumberAnimation { target: backLogo; properties: "scale, opacity"; duration: 300 } + NumberAnimation { target: frontLogo; properties: "scale, opacity"; duration: 300 } + ParallelAnimation { + NumberAnimation { target: qtText; properties: "opacity, scale"; duration: 400; easing.type: "OutQuad" } + NumberAnimation { target: sketchBlueHolder; property: "opacity"; duration: 300; easing.type: "OutQuad" } + NumberAnimation { target: sketchBlueHolder; property: "scale"; duration: 320; easing.type: "OutQuad" } + } + PauseAnimation { duration: 1000 } + ScriptAction { script: myApp.animationFinished() } + } + } + ] + + Item { + id: fullLogo + opacity: 0 + Image { + id: backLogo + x: -16 + y: -41 + opacity: 0 + scale: 0.7 + smooth: true + source: "qt-back.png" + } + Image { + id: frontLogo + x: -17 + y: -41 + opacity: 0 + scale: 1.2 + smooth: true + source: "qt-front.png" + } + Image { + id: qtText + x: -10 + y: -41 + opacity: 0 + scale: 1.2 + smooth: true + source: "qt-text.png" + } + } +} diff --git a/tools/qml/startup/qt-back.png b/tools/qml/startup/qt-back.png Binary files differnew file mode 100644 index 0000000..077215f --- /dev/null +++ b/tools/qml/startup/qt-back.png diff --git a/tools/qml/startup/qt-blue.jpg b/tools/qml/startup/qt-blue.jpg Binary files differnew file mode 100644 index 0000000..b204896 --- /dev/null +++ b/tools/qml/startup/qt-blue.jpg diff --git a/tools/qml/startup/qt-front.png b/tools/qml/startup/qt-front.png Binary files differnew file mode 100644 index 0000000..dbfb43e --- /dev/null +++ b/tools/qml/startup/qt-front.png diff --git a/tools/qml/startup/qt-sketch.jpg b/tools/qml/startup/qt-sketch.jpg Binary files differnew file mode 100644 index 0000000..1ede6f0 --- /dev/null +++ b/tools/qml/startup/qt-sketch.jpg diff --git a/tools/qml/startup/qt-text.png b/tools/qml/startup/qt-text.png Binary files differnew file mode 100644 index 0000000..d44995c --- /dev/null +++ b/tools/qml/startup/qt-text.png diff --git a/tools/qml/startup/quick-blur.png b/tools/qml/startup/quick-blur.png Binary files differnew file mode 100644 index 0000000..29ec243 --- /dev/null +++ b/tools/qml/startup/quick-blur.png diff --git a/tools/qml/startup/quick-regular.png b/tools/qml/startup/quick-regular.png Binary files differnew file mode 100644 index 0000000..38321cb --- /dev/null +++ b/tools/qml/startup/quick-regular.png diff --git a/tools/qml/startup/shadow.png b/tools/qml/startup/shadow.png Binary files differnew file mode 100644 index 0000000..44f92fe --- /dev/null +++ b/tools/qml/startup/shadow.png diff --git a/tools/qml/startup/startup.qml b/tools/qml/startup/startup.qml new file mode 100644 index 0000000..be67598 --- /dev/null +++ b/tools/qml/startup/startup.qml @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + id: treatsApp + width: 800 + height: 480 + color: "darkgrey" + Component.onCompleted: treatsApp.state = "part1" + signal animationFinished + + Logo { + id: logo + x: 165 + y: 35 + rotation: -15 + scale: 0.6 + opacity: 0 + onAnimationFinished: treatsApp.animationFinished(); + } + + states: [ + State { + name: "part1" + PropertyChanges { + target: logo + scale: 0.8 + opacity: 1 + rotation: 0 + } + PropertyChanges { + target: treatsApp + color: "black" + } + PropertyChanges { + target: logo + y: 10 + } + PropertyChanges { + target: quickblur + x: logo.x + 145 + } + PropertyChanges { + target: blurText + opacity: 0 + } + PropertyChanges { + target: quickregular + opacity: 1 + } + PropertyChanges { + target: star + x: -7 + y: -37 + } + } + ] + + + Item { + id: quickblur + x: 800//325 + y: 344 + Image { + id: blurText + source: "quick-blur.png" + } + Image { + id: quickregular + x: -1 + y: 0 + opacity: 0 + source: "quick-regular.png" + } + Image { + id: star + x: -1 + y: 0 + opacity: 0 + source: "white-star.png" + smooth: true + NumberAnimation on rotation { + from: 0 + to: 360 + loops: NumberAnimation.Infinite + running: true + duration: 2000 + } + } + } + + transitions: [ + Transition { + ParallelAnimation { + NumberAnimation { target: logo; property: "opacity"; duration: 500 } + NumberAnimation { target: logo; property: "scale"; duration: 4000; } + NumberAnimation { target: logo; property: "rotation"; duration: 2000; easing.type: "OutBack"} + ColorAnimation { duration: 3000} + SequentialAnimation { + PauseAnimation { duration: 1000 } + ScriptAction { script: logo.logoState = "showBlueprint" } + PauseAnimation { duration: 800 } + ScriptAction { script: logo.logoState = "finale" } + PauseAnimation { duration: 800 } + ParallelAnimation { + NumberAnimation { target: quickblur; property: "x"; duration: 200;} + SequentialAnimation { + PauseAnimation { duration: 200} + ParallelAnimation { + NumberAnimation { target: blurText; property: "opacity"; duration: 300;} + NumberAnimation { target: quickregular; property: "opacity"; duration: 300;} + } + NumberAnimation { target: star; property: "opacity"; from: 0; to: 1; duration: 500 } + PauseAnimation { duration: 200 } + NumberAnimation { target: star; property: "opacity"; from: 1; to: 0; duration: 500 } + } + SequentialAnimation { + PauseAnimation { duration: 150} + NumberAnimation { target: logo; property: "y"; duration: 300; easing.type: "OutBounce" } + } + } + } + } + } + ] + +} // treatsApp diff --git a/tools/qml/startup/startup.qrc b/tools/qml/startup/startup.qrc new file mode 100644 index 0000000..52e6705 --- /dev/null +++ b/tools/qml/startup/startup.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/startup"> + <file>Logo.qml</file> + <file>qt-back.png</file> + <file>qt-blue.jpg</file> + <file>qt-front.png</file> + <file>qt-sketch.jpg</file> + <file>qt-text.png</file> + <file>quick-blur.png</file> + <file>quick-regular.png</file> + <file>shadow.png</file> + <file>startup.qml</file> + <file>startup.qrc</file> + <file>white-star.png</file> + </qresource> +</RCC> diff --git a/tools/qml/startup/white-star.png b/tools/qml/startup/white-star.png Binary files differnew file mode 100644 index 0000000..f467c94 --- /dev/null +++ b/tools/qml/startup/white-star.png |