aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2013-11-18 15:57:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-20 16:07:26 +0100
commit61cf2b0633e8af564d1368dc377da0b6869fb4c9 (patch)
tree95cc0bb3a4527d64664b98342f86b5a12ee1054d /tools
parent3f1245aabc125c416f26028a12923f9055765e4f (diff)
qml tool on OSX: wait for a timeout before exiting
Double-clicking to open a QML file was not working because it would exit if no files are given on the command line. It needs to wait a while for the QFileOpenEvent. Task-number: QTBUG-34926 Change-Id: Icb585a777b0438db85120c62e7717f0f6eafffb1 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/main.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index ddcd259ae0..804241f023 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -72,8 +72,11 @@
#define VERSION_MIN 0
#define VERSION_STR "1.0"
+#define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms
+
static Config *conf = 0;
static QQmlApplicationEngine *qae = 0;
+static int exitTimerId = -1;
static void loadConf(const QString &override, bool quiet) // Terminates app on failure
{
@@ -138,6 +141,8 @@ void contain(QObject *o, const QUrl &containPath)
#ifdef QT_GUI_LIB
+void noFilesGiven();
+
// Loads qml after receiving a QFileOpenEvent
class LoaderApplication : public QGuiApplication
{
@@ -146,12 +151,21 @@ public:
bool event(QEvent *ev)
{
- if (ev->type() == QEvent::FileOpen)
+ if (ev->type() == QEvent::FileOpen) {
+ if (exitTimerId >= 0) {
+ killTimer(exitTimerId);
+ exitTimerId = -1;
+ }
qae->load(static_cast<QFileOpenEvent *>(ev)->url());
+ }
else
return QGuiApplication::event(ev);
return true;
}
+
+ void timerEvent(QTimerEvent *) {
+ noFilesGiven();
+ }
};
#endif // QT_GUI_LIB
@@ -274,6 +288,13 @@ void printUsage()
exit(0);
}
+void noFilesGiven()
+{
+ if (!quietMode)
+ printf("qml: No files specified. Terminating.\n");
+ exit(1);
+}
+
//Called before application initialization, removes arguments it uses
void getAppFlags(int &argc, char **argv)
{
@@ -462,9 +483,12 @@ int main(int argc, char *argv[])
qInstallMessageHandler(quietMessageHandler);
if (files.count() <= 0) {
- if (!quietMode)
- printf("qml: No files specified. Terminating.\n");
- exit(1);
+#if defined(Q_OS_MAC)
+ if (applicationType == QmlApplicationTypeGui)
+ exitTimerId = static_cast<LoaderApplication *>(app)->startTimer(FILE_OPEN_EVENT_WAIT_TIME);
+ else
+#endif
+ noFilesGiven();
}
qae = &e;