diff options
author | mae <qt-info@nokia.com> | 2010-04-08 12:54:42 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-04-08 13:00:35 (GMT) |
commit | c3a54c47048b7123f51f2a1078e156d259445221 (patch) | |
tree | 299c0dfd3c039ec5fbf36f5a64bca13c1b8b4fd7 /tools | |
parent | dc2429a34e8d0168ef33f48ec0da35631be49243 (diff) | |
download | Qt-c3a54c47048b7123f51f2a1078e156d259445221.zip Qt-c3a54c47048b7123f51f2a1078e156d259445221.tar.gz Qt-c3a54c47048b7123f51f2a1078e156d259445221.tar.bz2 |
Tune plugin import mechanism
In shadow build environments, we cannot enforce that shared
library objects for plugins are located in the same directory
as the qmldir file. This makes it hard for Creator to support
mixed projects (qml/c++).
In order to gain more flexibility, the patch introduces a
pluginPathList to QDeclarativeEngine, which completes the existing
importsPathList.
The pluginPathList defaults to ["."], which indicates the directory
where the qmldir file is located in.
The qml viewer tool gains a command line option -P to add to the
pluginPathList.
For consistency, the -L option ("Library") has been renamed to
-I ("Import"). QDeclarativeEngine::importExtension() has been
renamed to QDeclarativeEngine::importPlugin().
The documentation has been adjusted accordingly.
Done with erikv.
Reviewed-by: erikv
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 35 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 5 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 1 |
3 files changed, 36 insertions, 5 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 5099e49..01b3912 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -101,8 +101,9 @@ void usage() qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); qWarning(" -netcache <size> ......................... set disk cache to size bytes"); qWarning(" -translation <translationfile> ........... set the language to run in"); - qWarning(" -L <directory> ........................... prepend to the library search path,"); + qWarning(" -I <directory> ........................... prepend to the module import search path,"); qWarning(" display path if <directory> is empty"); + qWarning(" -P <directory> ........................... prepend to the plugin search path"); qWarning(" -opengl .................................. use a QGLWidget for the viewport"); qWarning(" -script <path> ........................... set the script to use"); qWarning(" -scriptopts <options>|help ............... set the script options to use"); @@ -167,7 +168,8 @@ int main(int argc, char ** argv) QString dither = "none"; QString recordfile; QStringList recordargs; - QStringList libraries; + QStringList imports; + QStringList plugins; QString skin; QString script; QString scriptopts; @@ -239,14 +241,19 @@ int main(int argc, char ** argv) useGL = true; } else if (arg == "-qmlbrowser") { useNativeFileBrowser = false; - } else if (arg == "-L") { + } else if (arg == "-I" || arg == "-L") { + if (arg == "-L") + fprintf(stderr, "-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; } - libraries << QString(argv[++i]); + imports << QString(argv[++i]); + } else if (arg == "-P") { + if (lastArg) usage(); + plugins << QString(argv[++i]); } else if (arg == "-script") { if (lastArg) usage(); script = QString(argv[++i]); @@ -320,9 +327,12 @@ int main(int argc, char ** argv) viewer.addLibraryPath(QCoreApplication::applicationDirPath()); - foreach (QString lib, libraries) + foreach (QString lib, imports) viewer.addLibraryPath(lib); + foreach (QString plugin, plugins) + viewer.addPluginPath(plugin); + viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); if (resizeview) @@ -349,6 +359,21 @@ int main(int argc, char ** argv) viewer.setUseNativeFileBrowser(useNativeFileBrowser); if (fullScreen && maximized) qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; + + if (fileName.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; + } + } + if (!fileName.isEmpty()) { viewer.open(fileName); fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show(); diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 1ab528e..c4ebd80 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -870,6 +870,11 @@ void QDeclarativeViewer::addLibraryPath(const QString& lib) canvas->engine()->addImportPath(lib); } +void QDeclarativeViewer::addPluginPath(const QString& plugin) +{ + canvas->engine()->addPluginPath(plugin); +} + void QDeclarativeViewer::reload() { openQml(currentFileOrUrl); diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 01777bd..6f1e425 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -96,6 +96,7 @@ public: void setDeviceKeys(bool); void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); + void addPluginPath(const QString& plugin); void setUseGL(bool use); void setUseNativeFileBrowser(bool); |