aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/main.cpp10
-rw-r--r--tools/qmleasing/splineeditor.cpp4
-rw-r--r--tools/qmleasing/splineeditor.h4
-rw-r--r--tools/qmlimportscanner/main.cpp36
-rw-r--r--tools/qmlplugindump/main.cpp11
-rw-r--r--tools/qmlscene/main.cpp16
6 files changed, 46 insertions, 35 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 071908e78e..31fd9b383f 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -215,7 +215,7 @@ public Q_SLOTS:
returnCode = retCode;
}
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
void onOpenGlContextCreated(QOpenGLContext *context);
#endif
};
@@ -237,7 +237,7 @@ void LoadWatcher::contain(QObject *o, const QUrl &containPath)
void LoadWatcher::checkForWindow(QObject *o)
{
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
if (verboseMode && o->isWindowType() && o->inherits("QQuickWindow")) {
connect(o, SIGNAL(openglContextCreated(QOpenGLContext*)),
this, SLOT(onOpenGlContextCreated(QOpenGLContext*)));
@@ -247,7 +247,7 @@ void LoadWatcher::checkForWindow(QObject *o)
#endif // QT_GUI_LIB && !QT_NO_OPENGL
}
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
void LoadWatcher::onOpenGlContextCreated(QOpenGLContext *context)
{
context->makeCurrent(qobject_cast<QWindow *>(sender()));
@@ -524,7 +524,7 @@ int main(int argc, char *argv[])
if (quietMode && verboseMode)
verboseMode = false;
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
//qt_ translations loaded by QQmlApplicationEngine
QString sysLocale = QLocale::system().name();
@@ -569,7 +569,7 @@ int main(int argc, char *argv[])
for (const QString &path : qAsConst(files)) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QRegularExpression urlRe("[[:word:]]+://.*");
if (urlRe.match(path).hasMatch()) { //Treat as a URL
QUrl url = QUrl::fromUserInput(path);
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index 6fee013c62..01a279afbf 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -224,7 +224,7 @@ void SplineEditor::mouseReleaseEvent(QMouseEvent *e)
}
}
-#ifndef QT_NO_CONTEXTMENU
+#if QT_CONFIG(contextmenu)
void SplineEditor::contextMenuEvent(QContextMenuEvent *e)
{
int index = findControlPoint(e->pos());
@@ -244,7 +244,7 @@ void SplineEditor::contextMenuEvent(QContextMenuEvent *e)
addPoint(e->pos());
}
}
-#endif // QT_NO_CONTEXTMENU
+#endif // contextmenu
void SplineEditor::invalidate()
{
diff --git a/tools/qmleasing/splineeditor.h b/tools/qmleasing/splineeditor.h
index 243e199cd0..414b787bc3 100644
--- a/tools/qmleasing/splineeditor.h
+++ b/tools/qmleasing/splineeditor.h
@@ -79,9 +79,9 @@ protected:
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
-#ifndef QT_NO_CONTEXTMENU
+#if QT_CONFIG(contextmenu)
void contextMenuEvent(QContextMenuEvent *);
-#endif // QT_NO_CONTEXTMENU
+#endif // contextmenu
void invalidate();
void invalidateSmoothList();
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 1e5f7a9921..b2ff751231 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -58,6 +58,7 @@ QStringList g_qmlImportPaths;
static inline QString typeLiteral() { return QStringLiteral("type"); }
static inline QString versionLiteral() { return QStringLiteral("version"); }
static inline QString nameLiteral() { return QStringLiteral("name"); }
+static inline QString relativePathLiteral() { return QStringLiteral("relativePath"); }
static inline QString pluginsLiteral() { return QStringLiteral("plugins"); }
static inline QString pathLiteral() { return QStringLiteral("path"); }
static inline QString classnamesLiteral() { return QStringLiteral("classnames"); }
@@ -162,8 +163,9 @@ QVariantMap pluginsForModulePath(const QString &modulePath) {
return pluginInfo;
}
-// Search for a given qml import in g_qmlImportPaths.
-QString resolveImportPath(const QString &uri, const QString &version)
+// Search for a given qml import in g_qmlImportPaths and return a pair
+// of absolute / relative paths (for deployment).
+QPair<QString, QString> resolveImportPath(const QString &uri, const QString &version)
{
const QLatin1Char dot('.');
const QLatin1Char slash('/');
@@ -180,18 +182,21 @@ QString resolveImportPath(const QString &uri, const QString &version)
// - qml/QtQml.2/Models
// - qml/QtQml/Models
if (ver.isEmpty()) {
- const QString candidatePath = QDir::cleanPath(qmlImportPath + slash + parts.join(slash));
+ QString relativePath = parts.join(slash);
+ if (relativePath.endsWith(slash))
+ relativePath.chop(1);
+ const QString candidatePath = QDir::cleanPath(qmlImportPath + slash + relativePath);
if (QDir(candidatePath).exists())
- return candidatePath; // import found
+ return qMakePair(candidatePath, relativePath); // import found
} else {
for (int index = parts.count() - 1; index >= 0; --index) {
- const QString candidatePath = QDir::cleanPath(qmlImportPath + slash
- + parts.mid(0, index + 1).join(slash)
- + dot + ver + slash
- + parts.mid(index + 1).join(slash));
-
+ QString relativePath = parts.mid(0, index + 1).join(slash)
+ + dot + ver + slash + parts.mid(index + 1).join(slash);
+ if (relativePath.endsWith(slash))
+ relativePath.chop(1);
+ const QString candidatePath = QDir::cleanPath(qmlImportPath + slash + relativePath);
if (QDir(candidatePath).exists())
- return candidatePath; // import found
+ return qMakePair(candidatePath, relativePath); // import found
}
}
}
@@ -207,7 +212,7 @@ QString resolveImportPath(const QString &uri, const QString &version)
ver = ver.mid(0, lastDot);
}
- return QString(); // not found
+ return QPair<QString, QString>(); // not found
}
// Find absolute file system paths and plugins for a list of modules.
@@ -219,9 +224,12 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
for (int i = 0; i < importsCopy.length(); ++i) {
QVariantMap import = qvariant_cast<QVariantMap>(importsCopy[i]);
if (import[typeLiteral()] == QLatin1String("module")) {
- QString path = resolveImportPath(import.value(nameLiteral()).toString(), import.value(versionLiteral()).toString());
- if (!path.isEmpty())
- import[pathLiteral()] = path;
+ const QPair<QString, QString> paths =
+ resolveImportPath(import.value(nameLiteral()).toString(), import.value(versionLiteral()).toString());
+ if (!paths.first.isEmpty()) {
+ import.insert(pathLiteral(), paths.first);
+ import.insert(relativePathLiteral(), paths.second);
+ }
QVariantMap plugininfo = pluginsForModulePath(import.value(pathLiteral()).toString());
QString plugins = plugininfo.value(pluginsLiteral()).toString();
QString classnames = plugininfo.value(classnamesLiteral()).toString();
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index cfd14aff6d..883afa057c 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -72,11 +72,12 @@
#include <qt_windows.h>
#endif
+namespace {
-static const uint qtQmlMajorVersion = 2;
-static const uint qtQmlMinorVersion = 2;
-static const uint qtQuickMajorVersion = 2;
-static const uint qtQuickMinorVersion = 8;
+const uint qtQmlMajorVersion = 2;
+const uint qtQmlMinorVersion = 2;
+const uint qtQuickMajorVersion = 2;
+const uint qtQuickMinorVersion = 8;
const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2")
.arg(qtQuickMajorVersion)
@@ -89,6 +90,8 @@ bool creatable = true;
QString currentProperty;
QString inObjectInstantiation;
+}
+
static QString enquote(const QString &string)
{
QString s = string;
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index db0af1d071..1e8d91a95b 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -289,7 +289,7 @@ static bool checkVersion(const QUrl &url)
static void displayFileDialog(Options *options)
{
-#if defined(QT_WIDGETS_LIB) && !defined(QT_NO_FILEDIALOG)
+#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog)
QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)");
if (!fileName.isEmpty()) {
QFileInfo fi(fileName);
@@ -301,7 +301,7 @@ static void displayFileDialog(Options *options)
#endif
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
static void loadTranslationFile(QTranslator &translator, const QString& directory)
{
translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n"));
@@ -361,7 +361,7 @@ static void usage()
puts(" ");
exit(1);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Listen on GL context creation of the QQuickWindow in order to print diagnostic output.
class DiagnosticGlContextCreationListener : public QObject {
Q_OBJECT
@@ -405,7 +405,7 @@ static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *windo
if (verbose) {
newTitle += QLatin1String(" [Qt ") + QLatin1String(QT_VERSION_STR) + QLatin1Char(' ')
+ QGuiApplication::platformName() + QLatin1Char(' ');
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
? QLatin1String("GL") : QLatin1String("GLES");
#endif
@@ -509,7 +509,7 @@ int main(int argc, char ** argv)
}
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator translator;
QTranslator qtTranslator;
QString sysLocale = QLocale::system().name();
@@ -545,7 +545,7 @@ int main(int argc, char ** argv)
if (!options.url.isEmpty()) {
if (!options.versionDetection || checkVersion(options.url)) {
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator translator;
#endif
@@ -559,7 +559,7 @@ int main(int argc, char ** argv)
engine.addPluginPath(pluginPaths.at(i));
if (options.url.isLocalFile()) {
QFileInfo fi(options.url.toLocalFile());
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
loadTranslationFile(translator, fi.path());
#endif
loadDummyDataFiles(engine, fi.path());
@@ -598,7 +598,7 @@ int main(int argc, char ** argv)
if (window) {
setWindowTitle(options.verbose, topLevel, window.data());
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (options.verbose)
new DiagnosticGlContextCreationListener(window.data());
#endif