From 9b90ab99141fba6730098178a456a48a6f2f68b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Dapena=20Paz?= Date: Tue, 8 Jan 2013 20:17:05 +0100 Subject: [PATCH] Add QWindowSystemInterface::handleFileOpen(const QUrl&) In some cases, the call to handleFileOpen may receive a non local URL. With previous API, there was no way to pass it to other layers. With this change, any platform plugin creating this event can directly pass a URL. Change-Id: Ibd7299ad6c09527e1db979840bd67726882efb9b Reviewed-by: Jose Dapena Paz Reviewed-by: Thiago Macieira Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qguiapplication.cpp | 4 ++-- src/gui/kernel/qwindowsysteminterface.cpp | 6 ++++++ src/gui/kernel/qwindowsysteminterface.h | 1 + src/gui/kernel/qwindowsysteminterface_p.h | 7 +++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0de4ba7f4a..c73eeadbfb 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1674,10 +1674,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) { - if (e->fileName.isEmpty()) + if (e->url.isEmpty()) return; - QFileOpenEvent event(e->fileName); + QFileOpenEvent event(e->url); QGuiApplication::sendSpontaneousEvent(qApp, &event); } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 27bb4bae00..92434d1181 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -575,6 +575,12 @@ void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName) QGuiApplicationPrivate::processWindowSystemEvent(&e); } +void QWindowSystemInterface::handleFileOpenEvent(const QUrl &url) +{ + QWindowSystemInterfacePrivate::FileOpenEvent e(url); + QGuiApplicationPrivate::processWindowSystemEvent(&e); +} + void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global, int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, qint64 uid, diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 7582f092a3..72bebe19fe 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -158,6 +158,7 @@ public: static void handleThemeChange(QWindow *tlw); static void handleFileOpenEvent(const QString& fileName); + static void handleFileOpenEvent(const QUrl &url); static void handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global, int device, int pointerType, qreal pressure, int xTilt, int yTilt, diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 6c12877035..d0b728ec4d 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -285,9 +285,12 @@ public: class FileOpenEvent : public WindowSystemEvent { public: FileOpenEvent(const QString& fileName) - : WindowSystemEvent(FileOpen), fileName(fileName) + : WindowSystemEvent(FileOpen), url(QUrl::fromLocalFile(fileName)) { } - QString fileName; + FileOpenEvent(const QUrl &url) + : WindowSystemEvent(FileOpen), url(url) + { } + QUrl url; }; class TabletEvent : public InputEvent {