Make QFileOpenEvents delivered again.

Create a FileOpenEvent within QWindowSystemInterfacePrivate and handle
it in QWindowSystemSystemInterface and QGuiApplication

Change-Id: Ie777c923958d83d56e8648c9bfb1f9dcb985654d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Christoph Schleifenbaum 2012-04-05 16:31:40 +02:00 committed by Qt by Nokia
parent e3bbfe00d1
commit 358fd91951
6 changed files with 34 additions and 5 deletions

View File

@ -1412,6 +1412,15 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
} }
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
{
if (e->fileName.isEmpty())
return;
QFileOpenEvent event(e->fileName);
QGuiApplication::sendSpontaneousEvent(qApp, &event);
}
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k)
{ {
return qHash(k.device) + k.touchPointId; return qHash(k.device) + k.touchPointId;

View File

@ -121,6 +121,8 @@ public:
static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e); static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);

View File

@ -520,4 +520,10 @@ bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray
return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result); return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result);
} }
void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName)
{
QWindowSystemInterfacePrivate::FileOpenEvent e(fileName);
QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -148,6 +148,8 @@ public:
static void handleThemeChange(QWindow *tlw); static void handleThemeChange(QWindow *tlw);
static void handleFileOpenEvent(const QString& fileName);
// For event dispatcher implementations // For event dispatcher implementations
static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags); static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);
static int windowSystemEventsQueued(); static int windowSystemEventsQueued();

View File

@ -68,7 +68,8 @@ public:
ScreenLogicalDotsPerInch, ScreenLogicalDotsPerInch,
ScreenRefreshRate, ScreenRefreshRate,
ThemeChange, ThemeChange,
Expose Expose,
FileOpen
}; };
class WindowSystemEvent { class WindowSystemEvent {
@ -257,6 +258,14 @@ public:
QRegion region; QRegion region;
}; };
class FileOpenEvent : public WindowSystemEvent {
public:
FileOpenEvent(const QString& fileName)
: WindowSystemEvent(FileOpen), fileName(fileName)
{ }
QString fileName;
};
static QList<WindowSystemEvent *> windowSystemEventQueue; static QList<WindowSystemEvent *> windowSystemEventQueue;
static QMutex queueMutex; static QMutex queueMutex;

View File

@ -80,6 +80,8 @@
#include <qurl.h> #include <qurl.h>
#include <qdebug.h> #include <qdebug.h>
#include <qguiapplication.h> #include <qguiapplication.h>
#include "qt_mac_p.h"
#include <QtGui/QWindowSystemInterface>
QT_USE_NAMESPACE QT_USE_NAMESPACE
@ -217,7 +219,7 @@ static void cleanupCocoaApplicationDelegate()
{ {
Q_UNUSED(filenames); Q_UNUSED(filenames);
Q_UNUSED(sender); Q_UNUSED(sender);
/*
for (NSString *fileName in filenames) { for (NSString *fileName in filenames) {
QString qtFileName = QCFString::toQString(fileName); QString qtFileName = QCFString::toQString(fileName);
if (inLaunch) { if (inLaunch) {
@ -228,14 +230,13 @@ static void cleanupCocoaApplicationDelegate()
if (qApp->arguments().contains(qtFileName)) if (qApp->arguments().contains(qtFileName))
continue; continue;
} }
QFileOpenEvent foe(qtFileName); QWindowSystemInterface::handleFileOpenEvent(qtFileName);
qt_sendSpontaneousEvent(qAppInstance(), &foe);
} }
if (reflectionDelegate && if (reflectionDelegate &&
[reflectionDelegate respondsToSelector:@selector(application:openFiles:)]) [reflectionDelegate respondsToSelector:@selector(application:openFiles:)])
[reflectionDelegate application:sender openFiles:filenames]; [reflectionDelegate application:sender openFiles:filenames];
*/
} }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender