From 8d24f015b2f98afc33092eca91727583b9ebb7f6 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 12 Oct 2013 11:59:09 +0900 Subject: Make qtdeclarative compile with -no-gui Change-Id: I079f5e09a0099550348388379c496fc8f8cfa27c Reviewed-by: Alan Alpert --- tools/qml/main.cpp | 102 +++++++++++++++++++++++++++++++++++------------------ tools/qml/qml.pro | 3 +- 2 files changed, 70 insertions(+), 35 deletions(-) (limited to 'tools') diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 804e907cc0..d9857e5b1a 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -42,13 +42,17 @@ #include "conf.h" #include + +#ifdef QT_GUI_LIB #include +#include +#include #ifdef QT_WIDGETS_LIB #include -#endif -#include +#endif // QT_WIDGETS_LIB +#endif // QT_GUI_LIB + #include -#include #include #include #include @@ -128,6 +132,8 @@ void contain(QObject *o, const QUrl &containPath) o->setParent(o2); //Set QObject parent, and assume container will react as needed } +#ifdef QT_GUI_LIB + // Loads qml after receiving a QFileOpenEvent class LoaderApplication : public QGuiApplication { @@ -144,6 +150,8 @@ public: } }; +#endif // QT_GUI_LIB + // Listens to the appEngine signals to determine if all files failed to load class LoadWatcher : public QObject { @@ -200,8 +208,22 @@ void quietMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, const Q // ### Should command line arguments have translations? Qt creator doesn't, so maybe it's not worth it. -bool useCoreApp = false; -bool useWidgetApp = false; +enum QmlApplicationType { + QmlApplicationTypeUnknown + , QmlApplicationTypeCore +#ifdef QT_GUI_LIB + , QmlApplicationTypeGui +#ifdef QT_WIDGETS_LIB + , QmlApplicationTypeWidget +#endif // QT_WIDGETS_LIB +#endif // QT_GUI_LIB +}; + +#ifndef QT_GUI_LIB +QmlApplicationType applicationType = QmlApplicationTypeCore; +#else +QmlApplicationType applicationType = QmlApplicationTypeGui; +#endif // QT_GUI_LIB bool quietMode = false; void printVersion() { @@ -220,12 +242,19 @@ void printUsage() printf("Any argument ending in .qml will be treated as a QML file to be loaded.\n"); printf("Any number of QML files can be loaded. They will share the same engine.\n"); printf("Any argument which is not a recognized option and which does not end in .qml will be ignored.\n"); + printf("'gui' application type is only available if the QtGui module is avaialble.\n"); printf("'widget' application type is only available if the QtWidgets module is avaialble.\n"); printf("\n"); printf("General Options:\n"); printf("\t-h, -help..................... Print this usage information and exit.\n"); printf("\t-v, -version.................. Print the version information and exit.\n"); +#ifdef QT_GUI_LIB +#ifndef QT_WIDGETS_LIB + printf("\t-apptype [core|gui] .......... Select which application class to use. Default is gui.\n"); +#else printf("\t-apptype [core|gui|widget] ... Select which application class to use. Default is gui.\n"); +#endif // QT_WIDGETS_LIB +#endif // QT_GUI_LIB printf("\t-quiet ....................... Suppress all output.\n"); printf("\t-I [path] .................... Prepend the given path to the import paths.\n"); printf("\t-f [file] .................... Load the given file as a QML file.\n"); @@ -244,44 +273,39 @@ void printUsage() void getAppFlags(int &argc, char **argv) { for (int i=0; isetApplicationName("Qml Runtime"); app->setOrganizationName("Qt Project"); diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index fd4021c340..0642696b4e 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -1,4 +1,5 @@ -QT += qml gui core-private +QT = qml core-private +qtHaveModule(gui): QT += gui qtHaveModule(widgets): QT += widgets HEADERS += conf.h -- cgit v1.2.3