diff options
Diffstat (limited to 'src/plugins')
54 files changed, 1053 insertions, 701 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h index 2376b35501..ffb12ea846 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.h +++ b/src/plugins/platforms/cocoa/qcocoaapplication.h @@ -89,8 +89,10 @@ Cocoa Application Categories */ #include "qglobal.h" +#include "private/qcore_mac_p.h" #import <AppKit/AppKit.h> + @class QT_MANGLE_NAMESPACE(QCocoaMenuLoader); @interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration)) @@ -106,6 +108,8 @@ } @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSApplication); + QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent(); diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index d962ef8f75..c293f4cd52 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -87,12 +87,12 @@ QT_USE_NAMESPACE - (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu { - [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu]; + [[QCocoaApplicationDelegate sharedDelegate] setDockMenu:newMenu]; } - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader) { - return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader]; + return [[QCocoaApplicationDelegate sharedDelegate] menuLoader]; } - (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel @@ -155,7 +155,7 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE @end -@implementation QT_MANGLE_NAMESPACE(QNSApplication) +@implementation QNSApplication - (void)qt_sendEvent_original:(NSEvent *)event { @@ -189,7 +189,7 @@ QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent() { - if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) { + if ([NSApp isMemberOfClass:[QNSApplication class]]) { // No need to change implementation since Qt // already controls a subclass of NSApplication return; @@ -202,7 +202,7 @@ void qt_redirectNSApplicationSendEvent() qt_cocoa_change_implementation( [NSApplication class], @selector(sendEvent:), - [QT_MANGLE_NAMESPACE(QNSApplication) class], + [QNSApplication class], @selector(qt_sendEvent_replacement:), @selector(qt_sendEvent_original:)); } diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h index e44b2d1b6d..7f6c4224df 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h @@ -90,6 +90,7 @@ #import <Cocoa/Cocoa.h> #include <qglobal.h> +#include <private/qcore_mac_p.h> @class QT_MANGLE_NAMESPACE(QCocoaMenuLoader); @@ -108,3 +109,5 @@ - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; - (void) removeAppleEventHandlers; @end + +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate); diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index c40ae3d81d..95fe9129d3 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -88,14 +88,14 @@ QT_USE_NAMESPACE -static QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *sharedCocoaApplicationDelegate = nil; +static QCocoaApplicationDelegate *sharedCocoaApplicationDelegate = nil; static void cleanupCocoaApplicationDelegate() { [sharedCocoaApplicationDelegate release]; } -@implementation QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) +@implementation QCocoaApplicationDelegate - (id)init { @@ -143,7 +143,7 @@ static void cleanupCocoaApplicationDelegate() return nil; } -+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate ++ (QCocoaApplicationDelegate *)sharedDelegate { @synchronized(self) { if (sharedCocoaApplicationDelegate == nil) @@ -165,14 +165,14 @@ static void cleanupCocoaApplicationDelegate() return [[dockMenu retain] autorelease]; } -- (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader +- (void)setMenuLoader:(QCocoaMenuLoader *)menuLoader { [menuLoader retain]; [qtMenuLoader release]; qtMenuLoader = menuLoader; } -- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader +- (QCocoaMenuLoader *)menuLoader { return [[qtMenuLoader retain] autorelease]; } @@ -182,7 +182,7 @@ static void cleanupCocoaApplicationDelegate() [[NSApp mainMenu] cancelTracking]; bool handle_quit = true; - NSMenuItem *quitMenuItem = [[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader] quitMenuItem]; + NSMenuItem *quitMenuItem = [[[QCocoaApplicationDelegate sharedDelegate] menuLoader] quitMenuItem]; if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() && [quitMenuItem isEnabled]) { int visible = 0; diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index a0dac445be..4002d61318 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -87,7 +87,9 @@ static NSButton *macCreateButton(const char *text, NSView *superview) - (void)finishOffWithCode:(NSInteger)code; @end -@implementation QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); + +@implementation QNSColorPanelDelegate - (id)initWithDialogHelper:(QCocoaColorDialogHelper *)helper { @@ -290,9 +292,9 @@ static NSButton *macCreateButton(const char *text, NSView *superview) return (mResultCode == NSOKButton); } -- (QT_PREPEND_NAMESPACE(QPlatformDialogHelper::DialogCode))dialogResultCode +- (QPlatformDialogHelper::DialogCode)dialogResultCode { - return (mResultCode == NSOKButton) ? QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Accepted) : QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Rejected); + return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; } - (BOOL)windowShouldClose:(id)window @@ -348,7 +350,7 @@ QCocoaColorDialogHelper::~QCocoaColorDialogHelper() { if (!mDelegate) return; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate) release]; + [reinterpret_cast<QNSColorPanelDelegate *>(mDelegate) release]; mDelegate = 0; } @@ -358,7 +360,7 @@ void QCocoaColorDialogHelper::exec() // QEventLoop has been interrupted, and the second-most event loop has not // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else @@ -378,14 +380,14 @@ void QCocoaColorDialogHelper::hide() { if (!mDelegate) return; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate)->mColorPanel close]; + [reinterpret_cast<QNSColorPanelDelegate *>(mDelegate)->mColorPanel close]; } void QCocoaColorDialogHelper::setCurrentColor(const QColor &color) { if (!mDelegate) createNSColorPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); // make sure that if ShowAlphaChannel option is set then also setShowsAlpha // needs to be set, otherwise alpha value is omitted @@ -413,7 +415,7 @@ QColor QCocoaColorDialogHelper::currentColor() const { if (!mDelegate) return QColor(); - return reinterpret_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate)->mQtColor; + return reinterpret_cast<QNSColorPanelDelegate *>(mDelegate)->mQtColor; } void QCocoaColorDialogHelper::createNSColorPanelDelegate() @@ -421,7 +423,7 @@ void QCocoaColorDialogHelper::createNSColorPanelDelegate() if (mDelegate) return; - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) alloc] + QNSColorPanelDelegate *delegate = [[QNSColorPanelDelegate alloc] initWithDialogHelper:this]; mDelegate = delegate; @@ -431,7 +433,7 @@ bool QCocoaColorDialogHelper::showCocoaColorPanel(Qt::WindowModality windowModal { Q_UNUSED(parent); createNSColorPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; if (windowModality == Qt::NonModal) [delegate showModelessPanel]; @@ -444,7 +446,7 @@ bool QCocoaColorDialogHelper::hideCocoaColorPanel() if (!mDelegate){ return false; } else { - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); [delegate closePanel]; return true; } diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 071edb5b60..e1f8f8c20a 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -139,7 +139,9 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions; @end -@implementation QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); + +@implementation QNSOpenSavePanelDelegate - (id)initWithAcceptMode: (const QString &)selectFile @@ -148,7 +150,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions; { self = [super init]; mOptions = options; - if (mOptions->acceptMode() == QT_PREPEND_NAMESPACE(QFileDialogOptions::AcceptOpen)){ + if (mOptions->acceptMode() == QFileDialogOptions::AcceptOpen){ mOpenPanel = [NSOpenPanel openPanel]; mSavePanel = mOpenPanel; } else { @@ -234,7 +236,7 @@ static QString strippedText(QString s) - (void)closePanel { - *mCurrentSelection = QT_PREPEND_NAMESPACE(QCFString::toQString)([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C); + *mCurrentSelection = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C); if ([mSavePanel respondsToSelector:@selector(close)]) [mSavePanel close]; if ([mSavePanel isSheet]) @@ -244,15 +246,15 @@ static QString strippedText(QString s) - (void)showModelessPanel { if (mOpenPanel){ - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); - NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); + QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QCFString::toQString(mCurrentDir)); + NSString *filepath = QCFString::toNSString(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; [self updateProperties]; [mOpenPanel setAllowedFileTypes:nil]; - [mOpenPanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mOpenPanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QCFString::toNSString(info.filePath())] + : [NSURL fileURLWithPath:QCFString::toNSString(info.path())]]; [mOpenPanel beginWithCompletionHandler:^(NSInteger result){ mReturnCode = result; if (mHelper) @@ -263,14 +265,14 @@ static QString strippedText(QString s) - (BOOL)runApplicationModalPanel { - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); - NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); + QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QCFString::toQString(mCurrentDir)); + NSString *filepath = QCFString::toNSString(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; - [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; - [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""]; + [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QCFString::toNSString(info.filePath())] + : [NSURL fileURLWithPath:QCFString::toNSString(info.path())]]; + [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""]; // Call processEvents in case the event dispatcher has been interrupted, and needs to do // cleanup of modal sessions. Do this before showing the native dialog, otherwise it will @@ -282,22 +284,22 @@ static QString strippedText(QString s) return (mReturnCode == NSOKButton); } -- (QT_PREPEND_NAMESPACE(QPlatformDialogHelper::DialogCode))dialogResultCode +- (QPlatformDialogHelper::DialogCode)dialogResultCode { - return (mReturnCode == NSOKButton) ? QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Accepted) : QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Rejected); + return (mReturnCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; } - (void)showWindowModalSheet:(QWindow *)parent { - QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QT_PREPEND_NAMESPACE(QCFString::toQString)(mCurrentDir)); - NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath()); + QFileInfo info(!mCurrentSelection->isEmpty() ? *mCurrentSelection : QCFString::toQString(mCurrentDir)); + NSString *filepath = QCFString::toNSString(info.filePath()); bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) || [self panel:nil shouldShowFilename:filepath]; [self updateProperties]; - [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] - : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; - [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : @""]; + [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QCFString::toNSString(info.filePath())] + : [NSURL fileURLWithPath:QCFString::toNSString(info.path())]]; + [mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""]; NSWindow *nsparent = static_cast<NSWindow *>(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent)); [mSavePanel beginSheetModalForWindow:nsparent completionHandler:^(NSInteger result){ @@ -323,8 +325,8 @@ static QString strippedText(QString s) } } - QString qtFileName = QT_PREPEND_NAMESPACE(QCFString::toQString)(filename); - QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C))); + QString qtFileName = QCFString::toQString(filename); + QFileInfo info(qtFileName.normalized(QString::NormalizationForm_C)); QString path = info.absolutePath(); if (mCachedEntries->directory() != path) { mCachedEntries->updateDirCache(path); @@ -364,7 +366,7 @@ static QString strippedText(QString s) if (filters.size() > 0){ for (int i=0; i<filters.size(); ++i) { QString filter = hideDetails ? [self removeExtensions:filters.at(i)] : filters.at(i); - [mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(QCFString::toNSString)(filter)]; + [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)]; } [mPopUpButton selectItemAtIndex:0]; [mSavePanel setAccessoryView:mAccessoryView]; @@ -402,7 +404,7 @@ static QString strippedText(QString s) return result; } else { QStringList result; - QString filename = QT_PREPEND_NAMESPACE(QCFString::toQString)([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C); + QString filename = QCFString::toQString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C); result << filename.remove(QLatin1String("___qt_very_unlikely_prefix_")); return result; } @@ -413,18 +415,18 @@ static QString strippedText(QString s) // Call this functions if mFileMode, mFileOptions, // mNameFilterDropDownList or mQDirFilter changes. // The savepanel does not contain the neccessary functions for this. - const QT_PREPEND_NAMESPACE(QFileDialogOptions::FileMode) fileMode = mOptions->fileMode(); - bool chooseFilesOnly = fileMode == QT_PREPEND_NAMESPACE(QFileDialogOptions::ExistingFile) - || fileMode == QT_PREPEND_NAMESPACE(QFileDialogOptions::ExistingFiles); - bool chooseDirsOnly = fileMode == QT_PREPEND_NAMESPACE(QFileDialogOptions::Directory) - || fileMode == QT_PREPEND_NAMESPACE(QFileDialogOptions::DirectoryOnly) - || mOptions->testOption(QT_PREPEND_NAMESPACE(QFileDialogOptions::ShowDirsOnly)); + const QFileDialogOptions::FileMode fileMode = mOptions->fileMode(); + bool chooseFilesOnly = fileMode == QFileDialogOptions::ExistingFile + || fileMode == QFileDialogOptions::ExistingFiles; + bool chooseDirsOnly = fileMode == QFileDialogOptions::Directory + || fileMode == QFileDialogOptions::DirectoryOnly + || mOptions->testOption(QFileDialogOptions::ShowDirsOnly); [mOpenPanel setCanChooseFiles:!chooseDirsOnly]; [mOpenPanel setCanChooseDirectories:!chooseFilesOnly]; - [mSavePanel setCanCreateDirectories:!(mOptions->testOption(QT_PREPEND_NAMESPACE(QFileDialogOptions::ReadOnly)))]; - [mOpenPanel setAllowsMultipleSelection:(fileMode == QT_PREPEND_NAMESPACE(QFileDialogOptions::ExistingFiles))]; - [mOpenPanel setResolvesAliases:!(mOptions->testOption(QT_PREPEND_NAMESPACE(QFileDialogOptions::DontResolveSymlinks)))]; + [mSavePanel setCanCreateDirectories:!(mOptions->testOption(QFileDialogOptions::ReadOnly))]; + [mOpenPanel setAllowsMultipleSelection:(fileMode == QFileDialogOptions::ExistingFiles)]; + [mOpenPanel setResolvesAliases:!(mOptions->testOption(QFileDialogOptions::DontResolveSymlinks))]; [mOpenPanel setTitle:QCFString::toNSString(mOptions->windowTitle())]; [mSavePanel setTitle:QCFString::toNSString(mOptions->windowTitle())]; [mPopUpButton setHidden:chooseDirsOnly]; // TODO hide the whole sunken pane instead? @@ -433,7 +435,7 @@ static QString strippedText(QString s) const QString defaultSuffix = mOptions->defaultSuffix(); if (!ext.isEmpty() && !defaultSuffix.isEmpty()) ext.prepend(defaultSuffix); - [mSavePanel setAllowedFileTypes:ext.isEmpty() ? nil : QT_PREPEND_NAMESPACE(qt_mac_QStringListToNSMutableArray(ext))]; + [mSavePanel setAllowedFileTypes:ext.isEmpty() ? nil : qt_mac_QStringListToNSMutableArray(ext)]; if ([mSavePanel respondsToSelector:@selector(isVisible)] && [mSavePanel isVisible]) { if ([mSavePanel respondsToSelector:@selector(validateVisibleColumns)]) @@ -445,7 +447,7 @@ static QString strippedText(QString s) { Q_UNUSED(sender); if (mHelper) { - QString selection = QT_PREPEND_NAMESPACE(QCFString::toQString([[mSavePanel URL] path])); + QString selection = QCFString::toQString([[mSavePanel URL] path]); if (selection != mCurrentSelection) { *mCurrentSelection = selection; mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection); @@ -463,7 +465,7 @@ static QString strippedText(QString s) [mCurrentDir release]; mCurrentDir = [path retain]; - mHelper->QNSOpenSavePanelDelegate_directoryEntered(QT_PREPEND_NAMESPACE(QCFString::toQString(mCurrentDir))); + mHelper->QNSOpenSavePanelDelegate_directoryEntered(QCFString::toQString(mCurrentDir)); } /* @@ -490,7 +492,7 @@ static QString strippedText(QString s) - (QString)removeExtensions:(const QString &)filter { - QRegExp regExp(QT_PREPEND_NAMESPACE(QString::fromLatin1)(QT_PREPEND_NAMESPACE(QPlatformFileDialogHelper::filterRegExp))); + QRegExp regExp(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp)); if (regExp.indexIn(filter) != -1) return regExp.cap(1).trimmed(); return filter; @@ -526,7 +528,7 @@ static QString strippedText(QString s) (filterToUse == -1 && currentFilter.startsWith(selectedFilter))) filterToUse = i; QString filter = hideDetails ? [self removeExtensions:currentFilter] : currentFilter; - [mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(QCFString::toNSString)(filter)]; + [mPopUpButton addItemWithTitle:QCFString::toNSString(filter)]; } if (filterToUse != -1) [mPopUpButton selectItemAtIndex:filterToUse]; @@ -564,7 +566,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper() if (!mDelegate) return; QCocoaAutoReleasePool pool; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate) release]; + [reinterpret_cast<QNSOpenSavePanelDelegate *>(mDelegate) release]; mDelegate = 0; } @@ -599,14 +601,14 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding void QCocoaFileDialogHelper::setDirectory(const QString &directory) { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (delegate) [delegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory)]]; } QString QCocoaFileDialogHelper::directory() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (delegate) return QCFString::toQString([[delegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C); return QString(); @@ -625,7 +627,7 @@ void QCocoaFileDialogHelper::selectFile(const QString &filename) QStringList QCocoaFileDialogHelper::selectedFiles() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (delegate) return [delegate selectedFiles]; return QStringList(); @@ -633,7 +635,7 @@ QStringList QCocoaFileDialogHelper::selectedFiles() const void QCocoaFileDialogHelper::setFilter() { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (!delegate) return; const SharedPointerFileDialogOptions &opts = options(); @@ -652,7 +654,7 @@ void QCocoaFileDialogHelper::selectNameFilter(const QString &filter) return; const int index = options()->nameFilters().indexOf(filter); if (index != -1) { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (!delegate) return; [delegate->mPopUpButton selectItemAtIndex:index]; @@ -662,7 +664,7 @@ void QCocoaFileDialogHelper::selectNameFilter(const QString &filter) QString QCocoaFileDialogHelper::selectedNameFilter() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (!delegate) return QString(); int index = [delegate->mPopUpButton indexOfSelectedItem]; @@ -700,7 +702,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() const QString directory = opts->initialDirectory(); const bool selectDir = selectedFiles.isEmpty(); QString selection(selectDir ? directory : selectedFiles.front()); - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) alloc] + QNSOpenSavePanelDelegate *delegate = [[QNSOpenSavePanelDelegate alloc] initWithAcceptMode: selection options:opts @@ -712,7 +714,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() bool QCocoaFileDialogHelper::showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent) { createNSOpenSavePanelDelegate(); - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (!delegate) return false; if (windowModality == Qt::NonModal) @@ -730,7 +732,7 @@ bool QCocoaFileDialogHelper::hideCocoaFilePanel() // open regarding whether or not to go native: return false; } else { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); [delegate closePanel]; // Even when we hide it, we are still using a // native dialog, so return true: @@ -745,7 +747,7 @@ void QCocoaFileDialogHelper::exec() // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. QCocoaAutoReleasePool pool; - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index e7cf47395b..b1d9e4ebce 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -128,7 +128,9 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) - (void)finishOffWithCode:(NSInteger)code; @end -@implementation QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); + +@implementation QNSFontPanelDelegate - (id)initWithDialogHelper: (QCocoaFontDialogHelper *)helper @@ -305,9 +307,9 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) return (mResultCode == NSOKButton); } -- (QT_PREPEND_NAMESPACE(QPlatformDialogHelper::DialogCode))dialogResultCode +- (QPlatformDialogHelper::DialogCode)dialogResultCode { - return (mResultCode == NSOKButton) ? QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Accepted) : QT_PREPEND_NAMESPACE(QPlatformDialogHelper::Rejected); + return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; } - (BOOL)windowShouldClose:(id)window @@ -363,7 +365,7 @@ QCocoaFontDialogHelper::~QCocoaFontDialogHelper() { if (!mDelegate) return; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate) release]; + [reinterpret_cast<QNSFontPanelDelegate *>(mDelegate) release]; mDelegate = 0; } @@ -373,7 +375,7 @@ void QCocoaFontDialogHelper::exec() // QEventLoop has been interrupted, and the second-most event loop has not // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate); + QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else @@ -393,7 +395,7 @@ void QCocoaFontDialogHelper::hide() { if (!mDelegate) return; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mFontPanel close]; + [reinterpret_cast<QNSFontPanelDelegate *>(mDelegate)->mFontPanel close]; } void QCocoaFontDialogHelper::setCurrentFont(const QFont &font) @@ -421,14 +423,14 @@ void QCocoaFontDialogHelper::setCurrentFont(const QFont &font) createNSFontPanelDelegate(); [mgr setSelectedFont:const_cast<NSFont *>(nsFont) isMultiple:NO]; - static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mQtFont = font; + static_cast<QNSFontPanelDelegate *>(mDelegate)->mQtFont = font; } QFont QCocoaFontDialogHelper::currentFont() const { if (!mDelegate) return QFont(); - return reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mQtFont; + return reinterpret_cast<QNSFontPanelDelegate *>(mDelegate)->mQtFont; } void QCocoaFontDialogHelper::createNSFontPanelDelegate() @@ -436,7 +438,7 @@ void QCocoaFontDialogHelper::createNSFontPanelDelegate() if (mDelegate) return; - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) alloc] + QNSFontPanelDelegate *delegate = [[QNSFontPanelDelegate alloc] initWithDialogHelper:this]; mDelegate = delegate; @@ -446,7 +448,7 @@ bool QCocoaFontDialogHelper::showCocoaFontPanel(Qt::WindowModality windowModalit { Q_UNUSED(parent); createNSFontPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate); + QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate); if (windowModality == Qt::NonModal) [delegate showModelessPanel]; // no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel() @@ -458,7 +460,7 @@ bool QCocoaFontDialogHelper::hideCocoaFontPanel() if (!mDelegate){ return false; } else { - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate); + QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate); [delegate closePanel]; return true; } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 45038ee578..987520f307 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -232,7 +232,7 @@ QCocoaIntegration::QCocoaIntegration() qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false); - NSApplication *cocoaApplication = [QT_MANGLE_NAMESPACE(QNSApplication) sharedApplication]; + NSApplication *cocoaApplication = [QNSApplication sharedApplication]; qt_redirectNSApplicationSendEvent(); if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { @@ -256,12 +256,12 @@ QCocoaIntegration::QCocoaIntegration() if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { // Set app delegate, link to the current delegate (if any) - QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; + QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate]; [newDelegate setReflectionDelegate:[cocoaApplication delegate]]; [cocoaApplication setDelegate:newDelegate]; // Load the application menu. This menu contains Preferences, Hide, Quit. - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) alloc] init]; + QCocoaMenuLoader *qtMenuLoader = [[QCocoaMenuLoader alloc] init]; qt_mac_loadMenuNib(qtMenuLoader); [cocoaApplication setMenu:[qtMenuLoader menu]]; [newDelegate setMenuLoader:qtMenuLoader]; @@ -279,7 +279,7 @@ QCocoaIntegration::~QCocoaIntegration() QCocoaAutoReleasePool pool; if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { // remove the apple event handlers installed by QCocoaApplicationDelegate - QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *delegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; + QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; [delegate removeAppleEventHandlers]; // reset the application delegate [[NSApplication sharedApplication] setDelegate: 0]; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index d4cf83a380..f6378d126f 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -73,7 +73,7 @@ NSString *qt_mac_removePrivateUnicode(NSString* string) return string; } -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -86,7 +86,9 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() @end -@implementation QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); + +@implementation QCocoaMenuDelegate - (id) initWithMenu:(QCocoaMenu*) m { @@ -218,11 +220,11 @@ QCocoaMenu::QCocoaMenu() : m_tag(0), m_menuBar(0) { - m_delegate = [[QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) alloc] initWithMenu:this]; + m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this]; m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; m_nativeMenu = [[NSMenu alloc] initWithTitle:@"Untitled"]; [m_nativeMenu setAutoenablesItems:YES]; - m_nativeMenu.delegate = (QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) *) m_delegate; + m_nativeMenu.delegate = (QCocoaMenuDelegate *) m_delegate; [m_nativeItem setSubmenu:m_nativeMenu]; } diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 73331db40d..52bfdfa385 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -52,7 +52,7 @@ static QList<QCocoaMenuBar*> static_menubars; -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -233,7 +233,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() } } - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); [loader ensureAppMenuInMenu:mb->nsMenu()]; NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain]; diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 1e2b593a08..4fb79f6c93 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -52,7 +52,7 @@ #include <QtCore/QDebug> -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -199,7 +199,7 @@ NSMenuItem *QCocoaMenuItem::sync() if ((m_role != NoRole && !m_textSynced) || m_merged) { NSMenuItem *mergeItem = nil; - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); switch (m_role) { case ApplicationSpecificRole: mergeItem = [loader appSpecificMenuItem:reinterpret_cast<NSInteger>(this)]; @@ -325,7 +325,7 @@ QT_END_NAMESPACE QString QCocoaMenuItem::mergeText() { - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); if (m_native == [loader aboutMenuItem]) { return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()); } else if (m_native== [loader aboutQtMenuItem]) { @@ -343,7 +343,7 @@ QString QCocoaMenuItem::mergeText() QKeySequence QCocoaMenuItem::mergeAccel() { - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); if (m_native == [loader preferencesMenuItem]) return QKeySequence(QKeySequence::Preferences); else if (m_native == [loader quitMenuItem]) diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h index a45ec0fa89..e07da39995 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.h +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h @@ -92,9 +92,11 @@ - (NSArray *)mergeable; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuLoader); + QT_BEGIN_NAMESPACE -void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader); +void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader); QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index 62b722d2d2..29fc0fb674 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE and written to QDir::temp() before loading. (Earlier Qt versions used to require having the nib file in the Qt GUI framework.) */ -void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader) +void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader) { // Create qt_menu.nib dir in temp. QDir temp = QDir::temp(); @@ -106,7 +106,7 @@ void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader) QT_END_NAMESPACE -@implementation QT_MANGLE_NAMESPACE(QCocoaMenuLoader) +@implementation QCocoaMenuLoader - (void)awakeFromNib { diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index e4cec8c5f8..de4c688b71 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -55,7 +55,7 @@ bool QCocoaServices::openUrl(const QUrl &url) const QString scheme = url.scheme(); if (scheme.isEmpty()) return openDocument(url); - return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toString(QUrl::FullyEncoded))]]; + return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QCFString::toNSString(url.toString(QUrl::FullyEncoded))]]; } bool QCocoaServices::openDocument(const QUrl &url) @@ -63,7 +63,7 @@ bool QCocoaServices::openDocument(const QUrl &url) if (!url.isValid()) return false; - return [[NSWorkspace sharedWorkspace] openFile:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toLocalFile())]; + return [[NSWorkspace sharedWorkspace] openFile:QCFString::toNSString(url.toLocalFile())]; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 99f533b33a..83c960d931 100755 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -135,12 +135,16 @@ QT_USE_NAMESPACE -(id)initWithQMenu:(QPlatformMenu*)qmenu; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSStatusItem); +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSImageView); +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSMenu); + QT_BEGIN_NAMESPACE class QSystemTrayIconSys { public: QSystemTrayIconSys(QCocoaSystemTrayIcon *sys) { - item = [[QT_MANGLE_NAMESPACE(QNSStatusItem) alloc] initWithSysTray:sys]; + item = [[QNSStatusItem alloc] initWithSysTray:sys]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) { [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item]; @@ -156,7 +160,7 @@ public: #endif [item release]; } - QT_MANGLE_NAMESPACE(QNSStatusItem) *item; + QNSStatusItem *item; }; void QCocoaSystemTrayIcon::init() @@ -310,8 +314,8 @@ QT_END_NAMESPACE @implementation NSStatusItem (Qt) @end -@implementation QT_MANGLE_NAMESPACE(QNSImageView) --(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent { +@implementation QNSImageView +-(id)initWithParent:(QNSStatusItem*)myParent { self = [super init]; parent = myParent; down = NO; @@ -406,7 +410,7 @@ QT_END_NAMESPACE } @end -@implementation QT_MANGLE_NAMESPACE(QNSStatusItem) +@implementation QNSStatusItem -(id)initWithSysTray:(QCocoaSystemTrayIcon *)sys { @@ -416,7 +420,7 @@ QT_END_NAMESPACE menu = 0; menuVisible = false; systray = sys; - imageCell = [[QT_MANGLE_NAMESPACE(QNSImageView) alloc] initWithParent:self]; + imageCell = [[QNSImageView alloc] initWithParent:self]; [item setView: imageCell]; } return self; @@ -494,7 +498,7 @@ private: QSystemTrayIconQMenu(); }; -@implementation QT_MANGLE_NAMESPACE(QNSMenu) +@implementation QNSMenu -(id)initWithQMenu:(QPlatformMenu*)qm { self = [super init]; if (self) { diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index cac059763d..e4237c9b3e 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -68,7 +68,9 @@ public: const QPalette *palette(Palette type = SystemPalette) const; const QFont *font(Font type = SystemFont) const; QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; - QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; + QPixmap fileIconPixmap(const QFileInfo &fileInfo, + const QSizeF &size, + QPlatformTheme::IconOptions options = 0) const; QVariant themeHint(ThemeHint hint) const; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 9c10bc26dd..5a5b2bc51f 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -249,8 +249,10 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const return QPlatformTheme::standardPixmap(sp, size); } -QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, + QPlatformTheme::IconOptions iconOptions) const { + Q_UNUSED(iconOptions); QCocoaAutoReleasePool pool; NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())]; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 91eaea21b6..bf7d722b36 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -61,7 +61,7 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow) @end @interface QNSPanel : NSPanel { - @public QT_PREPEND_NAMESPACE(QCocoaWindow) *m_cocoaPlatformWindow; + @public QCocoaWindow *m_cocoaPlatformWindow; } - (void)clearPlatformWindow; - (BOOL)canBecomeKeyWindow; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f8d0eafcb3..b455dd6642 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -155,6 +155,9 @@ static bool isMouseEvent(NSEvent *ev) - (BOOL)canBecomeKeyWindow { + if (!m_cocoaPlatformWindow) + return NO; + // Only tool or dialog windows should become key: if (m_cocoaPlatformWindow && (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog)) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index d43b3d36d2..2ba655b8e3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -901,14 +901,11 @@ static QTouchDevice *touchDevice = 0; Qt::KeyboardModifiers modifiers = [QNSView convertKeyModifiers: nativeModifiers]; NSString *characters = [nsevent characters]; - // [from Qt 4 impl] There is no way to get the scan code from carbon. But we cannot + // There is no way to get the scan code from carbon/cocoa. But we cannot // use the value 0, since it indicates that the event originates from somewhere // else than the keyboard. quint32 nativeScanCode = 1; - - UInt32 nativeVirtualKey = 0; - EventRef eventRef = EventRef([nsevent eventRef]); - GetEventParameter(eventRef, kEventParamKeyCode, typeUInt32, 0, sizeof(nativeVirtualKey), 0, &nativeVirtualKey); + quint32 nativeVirtualKey = [nsevent keyCode]; QChar ch = QChar::ReplacementCharacter; int keyCode = Qt::Key_unknown; diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro index 842ff17f1c..6ce0ca748e 100644 --- a/src/plugins/platforms/ios/ios.pro +++ b/src/plugins/platforms/ios/ios.pro @@ -1,3 +1,38 @@ -TEMPLATE = subdirs +TARGET = qios -SUBDIRS += plugin.pro qtmain.pro +PLUGIN_TYPE = platforms +load(qt_plugin) + +QT += core-private gui-private platformsupport-private +LIBS += -framework Foundation -framework UIKit -framework QuartzCore + +OBJECTIVE_SOURCES = \ + plugin.mm \ + qiosmain_wrapper.mm \ + qiosmain_dummy.mm \ + qiosintegration.mm \ + qioswindow.mm \ + qiosscreen.mm \ + qioseventdispatcher.mm \ + qiosbackingstore.mm \ + qiosapplicationdelegate.mm \ + qiosviewcontroller.mm \ + qioscontext.mm \ + qiosinputcontext.mm \ + qiostheme.mm \ + qiosglobal.mm + +HEADERS = \ + qiosintegration.h \ + qioswindow.h \ + qiosscreen.h \ + qioseventdispatcher.h \ + qiosbackingstore.h \ + qiosapplicationdelegate.h \ + qiosviewcontroller.h \ + qioscontext.h \ + qiosinputcontext.h \ + qiostheme.h \ + qiosglobal.h + +#HEADERS = qiossoftwareinputhandler.h diff --git a/src/plugins/platforms/ios/plugin.mm b/src/plugins/platforms/ios/plugin.mm index a93b6037ad..ca8ec936ae 100644 --- a/src/plugins/platforms/ios/plugin.mm +++ b/src/plugins/platforms/ios/plugin.mm @@ -66,4 +66,8 @@ QT_END_NAMESPACE #include "plugin.moc" +// Dummy function that we explicitly tell the linker to look for, +// so that the plugin's static initializer is included and run. +extern "C" void qt_registerPlatformPlugin() {} + Q_IMPORT_PLUGIN(QIOSIntegrationPlugin) diff --git a/src/plugins/platforms/ios/plugin.pro b/src/plugins/platforms/ios/plugin.pro deleted file mode 100644 index 591a0a67ed..0000000000 --- a/src/plugins/platforms/ios/plugin.pro +++ /dev/null @@ -1,36 +0,0 @@ -TARGET = qios - -PLUGIN_TYPE = platforms -load(qt_plugin) - -QT += core-private gui-private platformsupport-private -LIBS += -framework UIKit -framework QuartzCore - -OBJECTIVE_SOURCES = \ - plugin.mm \ - qiosintegration.mm \ - qioswindow.mm \ - qiosscreen.mm \ - qioseventdispatcher.mm \ - qiosbackingstore.mm \ - qiosapplicationdelegate.mm \ - qiosviewcontroller.mm \ - qioscontext.mm \ - qiosinputcontext.mm \ - qiostheme.mm \ - qiosglobal.mm - -HEADERS = \ - qiosintegration.h \ - qioswindow.h \ - qiosscreen.h \ - qioseventdispatcher.h \ - qiosbackingstore.h \ - qiosapplicationdelegate.h \ - qiosviewcontroller.h \ - qioscontext.h \ - qiosinputcontext.h \ - qiostheme.h \ - qiosglobal.h - -#HEADERS = qiossoftwareinputhandler.h diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index 10cbe529c4..571de9ffda 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -39,8 +39,11 @@ ** ****************************************************************************/ -#import "qiosapplicationdelegate.h" +#include "qiosapplicationdelegate.h" + +#include "qiosviewcontroller.h" #include "qioswindow.h" + #include <QtCore/QtCore> @implementation QIOSApplicationDelegate @@ -93,4 +96,47 @@ @end +extern int qt_user_main(int argc, char *argv[]); + +@implementation QIOSMainWrapperApplicationDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.qiosViewController = [[[QIOSViewController alloc] init] autorelease]; + self.window.rootViewController = self.qiosViewController; + +#ifdef QT_DEBUG + self.window.backgroundColor = [UIColor cyanColor]; +#endif + + [self.window makeKeyAndVisible]; + + // We schedule the main-redirection for the next eventloop pass so that we + // can return from this function and let UIApplicationMain finish its job. + [NSTimer scheduledTimerWithTimeInterval:.01f target:self + selector:@selector(runUserMain) userInfo:nil repeats:NO]; + + if ([QIOSApplicationDelegate instancesRespondToSelector:_cmd]) + return [super application:application didFinishLaunchingWithOptions:launchOptions]; + else + return YES; +} + +- (void)runUserMain +{ + NSArray *arguments = [[NSProcessInfo processInfo] arguments]; + int argc = arguments.count; + char **argv = new char*[argc]; + for (int i = 0; i < argc; ++i) { + NSString *arg = [arguments objectAtIndex:i]; + argv[i] = reinterpret_cast<char *>(malloc([arg lengthOfBytesUsingEncoding:[NSString defaultCStringEncoding]])); + strcpy(argv[i], [arg cStringUsingEncoding:[NSString defaultCStringEncoding]]); + } + + qt_user_main(argc, argv); + delete[] argv; +} + +@end diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 735dd26b6d..07368f6ab6 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -197,7 +197,7 @@ void QIOSContext::windowDestroyed(QObject *object) QFunctionPointer QIOSContext::getProcAddress(const QByteArray& functionName) { - return reinterpret_cast<QFunctionPointer>(dlsym(RTLD_NEXT, functionName.constData())); + return QFunctionPointer(dlsym(RTLD_DEFAULT, functionName.constData())); } #include "moc_qioscontext.cpp" diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 61fd1c3d60..d04864d724 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -49,6 +49,7 @@ #include "qiostheme.h" #include <QtPlatformSupport/private/qcoretextfontdatabase_p.h> +#include <QDir> #include <QtDebug> @@ -71,6 +72,9 @@ QIOSIntegration::QIOSIntegration() exit(-1); } + // Set current directory to app bundle folder + QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String])); + screenAdded(m_screen); m_touchDevice = new QTouchDevice; diff --git a/src/plugins/platforms/kms/qkmsudevhandler.cpp b/src/plugins/platforms/ios/qiosmain_dummy.mm index e32723e78f..28d7e59381 100644 --- a/src/plugins/platforms/kms/qkmsudevhandler.cpp +++ b/src/plugins/platforms/ios/qiosmain_dummy.mm @@ -39,17 +39,18 @@ ** ****************************************************************************/ -#include <qkmsudevhandler.h> +#include <QtCore/qglobal.h> -QT_BEGIN_NAMESPACE +/* + This file provides a dummy implementation of qt_user_main, so that + we don't get an undefined symbol in the hybrid use-case, where we + don't rename main() to qt_user_main(). As long as the linker is not + passed -all_load, this translation unit is only picked up and used + if qt_user_main is not defined by the user's code. +*/ -QKmsUdevHandler::QKmsUdevHandler(QObject *parent) - : QObject(parent) +int qt_user_main(int, char **) { + qFatal("Hit dummy qt_user_main, this should never happen!"); + return 0; } - -QKmsUdevHandler::~QKmsUdevHandler() -{ -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/kms/qkmsudevdrmhandler.cpp b/src/plugins/platforms/ios/qiosmain_wrapper.mm index 68a4aaacdb..4533add424 100644 --- a/src/plugins/platforms/kms/qkmsudevdrmhandler.cpp +++ b/src/plugins/platforms/ios/qiosmain_wrapper.mm @@ -39,28 +39,22 @@ ** ****************************************************************************/ -#include <QtCore/QRegExp> +#include "qiosapplicationdelegate.h" -#include <qkmsintegration.h> -#include <qkmsudevdrmhandler.h> +/* + This file provides a wrapper implementation of main() for the non- + hybrid use-case. The user's main is renamed to qt_user_main by the + build rules, and we'll call out to that main at the appropriate time. -QT_BEGIN_NAMESPACE + This file purposly only exports a single symbol, _main, so that + when the linker considers the translation unit for inclusion it + will discard it when main has already been defined in the user's + application for the hybrid use-case. +*/ -QKmsUdevDRMHandler::QKmsUdevDRMHandler(QKmsIntegration *integration) - : m_integration(integration) +int main(int argc, char *argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([QIOSMainWrapperApplicationDelegate class])); + } } - -QObject *QKmsUdevDRMHandler::create(struct udev_device *device) -{ - if (strcmp(udev_device_get_subsystem(device), "drm")) - return 0; - - QRegExp regexp("^card\\d+$"); - if (!regexp.exactMatch(udev_device_get_sysname(device))) - return 0; - - return m_integration->createDevice(udev_device_get_devnode(device)); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qtmain.mm b/src/plugins/platforms/ios/qtmain.mm deleted file mode 100644 index 19c98f2c59..0000000000 --- a/src/plugins/platforms/ios/qtmain.mm +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qiosapplicationdelegate.h" -#include "qiosviewcontroller.h" - -int main(int argc, char *argv[]) -{ - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([QIOSMainWrapperApplicationDelegate class])); - } -} - -extern int qt_main(int argc, char *argv[]); - -@implementation QIOSMainWrapperApplicationDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; - self.qiosViewController = [[[QIOSViewController alloc] init] autorelease]; - self.window.rootViewController = self.qiosViewController; - -#ifdef QT_DEBUG - self.window.backgroundColor = [UIColor cyanColor]; -#endif - - [self.window makeKeyAndVisible]; - - // We schedule the main-redirection for the next eventloop pass so that we - // can return from this function and let UIApplicationMain finish its job. - [NSTimer scheduledTimerWithTimeInterval:.01f target:self - selector:@selector(runUserMain) userInfo:nil repeats:NO]; - - if ([QIOSApplicationDelegate instancesRespondToSelector:_cmd]) - return [super application:application didFinishLaunchingWithOptions:launchOptions]; - else - return YES; -} - -- (void)runUserMain -{ - NSArray *arguments = [[NSProcessInfo processInfo] arguments]; - int argc = arguments.count; - char **argv = new char*[argc]; - for (int i = 0; i < argc; ++i) { - NSString *arg = [arguments objectAtIndex:i]; - argv[i] = reinterpret_cast<char *>(malloc([arg lengthOfBytesUsingEncoding:[NSString defaultCStringEncoding]])); - strcpy(argv[i], [arg cStringUsingEncoding:[NSString defaultCStringEncoding]]); - } - - qt_main(argc, argv); - delete[] argv; -} - -@end diff --git a/src/plugins/platforms/ios/qtmain.pro b/src/plugins/platforms/ios/qtmain.pro deleted file mode 100644 index cbcb272217..0000000000 --- a/src/plugins/platforms/ios/qtmain.pro +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = qiosmain - -PLUGIN_TYPE = platforms -load(qt_plugin) - -QT += gui-private - -OBJECTIVE_SOURCES = qtmain.mm diff --git a/src/plugins/platforms/kms/kms.pro b/src/plugins/platforms/kms/kms.pro index 711cf9e5c7..612a878736 100644 --- a/src/plugins/platforms/kms/kms.pro +++ b/src/plugins/platforms/kms/kms.pro @@ -22,9 +22,6 @@ SOURCES = main.cpp \ qkmsdevice.cpp \ qkmsbackingstore.cpp \ qkmsnativeinterface.cpp \ - qkmsudevlistener.cpp \ - qkmsudevhandler.cpp \ - qkmsudevdrmhandler.cpp \ qkmsvthandler.cpp HEADERS = qkmsintegration.h \ qkmsscreen.h \ @@ -34,9 +31,6 @@ HEADERS = qkmsintegration.h \ qkmsdevice.h \ qkmsbackingstore.h \ qkmsnativeinterface.h \ - qkmsudevlistener.h \ - qkmsudevhandler.h \ - qkmsudevdrmhandler.h \ qkmsvthandler.h OTHER_FILES += \ diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp index 8210b54535..e0cc33a606 100644 --- a/src/plugins/platforms/kms/qkmsintegration.cpp +++ b/src/plugins/platforms/kms/qkmsintegration.cpp @@ -46,8 +46,6 @@ #include "qkmsbackingstore.h" #include "qkmscontext.h" #include "qkmsnativeinterface.h" -#include "qkmsudevlistener.h" -#include "qkmsudevdrmhandler.h" #include "qkmsvthandler.h" #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> @@ -62,18 +60,26 @@ QKmsIntegration::QKmsIntegration() : QPlatformIntegration(), m_fontDatabase(new QGenericUnixFontDatabase()), m_eventDispatcher(createUnixEventDispatcher()), - m_nativeInterface(new QKmsNativeInterface), - m_udevListener(new QKmsUdevListener) + m_nativeInterface(new QKmsNativeInterface) { QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); setenv("EGL_PLATFORM", "drm",1); m_vtHandler = new QKmsVTHandler; - m_drmHandler = new QKmsUdevDRMHandler(this); - m_udevListener->addHandler(m_drmHandler); + + m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_DRM, 0); + if (m_deviceDiscovery) { + QStringList devices = m_deviceDiscovery->scanConnectedDevices(); + foreach (QString device, devices) + addDevice(device); + + connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); + connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); + } } QKmsIntegration::~QKmsIntegration() { + delete m_deviceDiscovery; foreach (QKmsDevice *device, m_devices) { delete device; } @@ -81,15 +87,18 @@ QKmsIntegration::~QKmsIntegration() delete screen; } delete m_fontDatabase; - delete m_udevListener; delete m_vtHandler; } -QObject *QKmsIntegration::createDevice(const char *path) +void QKmsIntegration::addDevice(const QString &deviceNode) +{ + m_devices.append(new QKmsDevice(deviceNode, this)); +} + +void QKmsIntegration::removeDevice(const QString &deviceNode) { - QKmsDevice *device = new QKmsDevice(path, this); - m_devices.append(device); - return device; + // TODO: support hot-plugging some day? + Q_UNUSED(deviceNode); } bool QKmsIntegration::hasCapability(QPlatformIntegration::Capability cap) const diff --git a/src/plugins/platforms/kms/qkmsintegration.h b/src/plugins/platforms/kms/qkmsintegration.h index c08396ba3f..5069753aa5 100644 --- a/src/plugins/platforms/kms/qkmsintegration.h +++ b/src/plugins/platforms/kms/qkmsintegration.h @@ -44,17 +44,18 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformnativeinterface.h> +#include <QtPlatformSupport/private/qdevicediscovery_p.h> QT_BEGIN_NAMESPACE class QKmsScreen; class QKmsDevice; -class QKmsUdevListener; -class QKmsUdevDRMHandler; class QKmsVTHandler; -class QKmsIntegration : public QPlatformIntegration +class QKmsIntegration : public QObject, public QPlatformIntegration { + Q_OBJECT + public: QKmsIntegration(); ~QKmsIntegration(); @@ -73,6 +74,10 @@ public: void addScreen(QKmsScreen *screen); QObject *createDevice(const char *); +private slots: + void addDevice(const QString &deviceNode); + void removeDevice(const QString &deviceNode); + private: QStringList findDrmDevices(); @@ -81,9 +86,8 @@ private: QPlatformFontDatabase *m_fontDatabase; QAbstractEventDispatcher *m_eventDispatcher; QPlatformNativeInterface *m_nativeInterface; - QKmsUdevListener *m_udevListener; - QKmsUdevDRMHandler *m_drmHandler; QKmsVTHandler *m_vtHandler; + QDeviceDiscovery *m_deviceDiscovery; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/kms/qkmsudevdrmhandler.h b/src/plugins/platforms/kms/qkmsudevdrmhandler.h deleted file mode 100644 index 4ceecb11a8..0000000000 --- a/src/plugins/platforms/kms/qkmsudevdrmhandler.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKMSUDEVDRMHANDLER_H -#define QKMSUDEVDRMHANDLER_H - -#include <QObject> - -#include <qkmsudevhandler.h> - -QT_BEGIN_NAMESPACE - -class QKmsIntegration; - -class QKmsUdevDRMHandler : public QKmsUdevHandler -{ -public: - QKmsUdevDRMHandler(QKmsIntegration *integration); - - QObject *create(struct udev_device *device); - -private: - QKmsIntegration *m_integration; -}; - -QT_END_NAMESPACE - -#endif // QKMSUDEVDRMHANDLER_H diff --git a/src/plugins/platforms/kms/qkmsudevhandler.h b/src/plugins/platforms/kms/qkmsudevhandler.h deleted file mode 100644 index e95960628a..0000000000 --- a/src/plugins/platforms/kms/qkmsudevhandler.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKMSUDEVHANDLER_H -#define QKMSUDEVHANDLER_H - -#include <QObject> - -#include <libudev.h> - -QT_BEGIN_NAMESPACE - -class QKmsUdevHandler : public QObject -{ - Q_OBJECT - -public: - QKmsUdevHandler(QObject *parent = 0); - virtual ~QKmsUdevHandler(); - - virtual QObject *create(struct udev_device *) = 0; -}; - -QT_END_NAMESPACE - -#endif // QKMSUDEVHANDLER_H diff --git a/src/plugins/platforms/kms/qkmsudevlistener.cpp b/src/plugins/platforms/kms/qkmsudevlistener.cpp deleted file mode 100644 index b2fb110479..0000000000 --- a/src/plugins/platforms/kms/qkmsudevlistener.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qkmsudevlistener.h> - -QT_BEGIN_NAMESPACE - -QKmsUdevListener::QKmsUdevListener(QObject *parent) - : QObject(parent) -{ - m_udev = udev_new(); -} - -QKmsUdevListener::~QKmsUdevListener() -{ - udev_unref(m_udev); -} - -void QKmsUdevListener::addHandler(QKmsUdevHandler *handler) -{ - m_handlers.removeAll((QKmsUdevHandler *) 0); - m_handlers.removeAll(handler); - m_handlers.prepend(handler); - - scan(); -} - -bool QKmsUdevListener::create(struct udev_device *device) -{ - foreach (QKmsUdevHandler *handler, m_handlers) { - if (!handler) - continue; - - QObject *obj = handler->create(device); - if (obj) { - m_devices[udev_device_get_syspath(device)] = obj; - return true; - } - } - - return false; -} - -void QKmsUdevListener::scan() -{ - struct udev_enumerate *e; - struct udev_list_entry *entry; - - e = udev_enumerate_new(m_udev); - udev_enumerate_scan_devices(e); - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { - const char *path = udev_list_entry_get_name(entry); - if (m_devices.contains(path)) - continue; - - struct udev_device *device = udev_device_new_from_syspath(m_udev, path); - create(device); - udev_device_unref(device); - } - udev_enumerate_unref(e); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/main.cpp b/src/plugins/platforms/qnx/main.cpp index ea50b12cb3..fb81928625 100644 --- a/src/plugins/platforms/qnx/main.cpp +++ b/src/plugins/platforms/qnx/main.cpp @@ -46,9 +46,8 @@ QT_BEGIN_NAMESPACE QPlatformIntegration *QQnxIntegrationPlugin::create(const QString& system, const QStringList& paramList) { - Q_UNUSED(paramList); if (system.toLower() == QLatin1String("qnx")) - return new QQnxIntegration; + return new QQnxIntegration(paramList); return 0; } diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 398b64640e..7c497b4434 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -11,11 +11,11 @@ QT += platformsupport-private core-private gui-private CONFIG(blackberry) { CONFIG += qqnx_pps - # Unomment this to enable screen event handling - # through a dedicated thread. - # DEFINES += QQNX_SCREENEVENTTHREAD + # Uncomment following line to enable screen event + # handling through a dedicated thread. + # CONFIG += qqnx_screeneventthread } else { - DEFINES += QQNX_SCREENEVENTTHREAD + CONFIG += qqnx_screeneventthread } # Uncomment these to enable debugging output for various aspects of the plugin @@ -40,11 +40,11 @@ CONFIG(blackberry) { #DEFINES += QQNXVIRTUALKEYBOARD_DEBUG #DEFINES += QQNXWINDOW_DEBUG #DEFINES += QQNXCURSOR_DEBUG +#DEFINES += QQNXFILEPICKER_DEBUG SOURCES = main.cpp \ qqnxbuffer.cpp \ - qqnxscreeneventthread.cpp \ qqnxintegration.cpp \ qqnxscreen.cpp \ qqnxwindow.cpp \ @@ -60,7 +60,6 @@ SOURCES = main.cpp \ HEADERS = main.h \ qqnxbuffer.h \ - qqnxscreeneventthread.h \ qqnxkeytranslator.h \ qqnxintegration.h \ qqnxscreen.h \ @@ -75,6 +74,12 @@ HEADERS = main.h \ qqnxservices.h \ qqnxcursor.h +CONFIG(qqnx_screeneventthread) { + DEFINES += QQNX_SCREENEVENTTHREAD + SOURCES += qqnxscreeneventthread.cpp + HEADERS += qqnxscreeneventthread.h +} + LIBS += -lscreen contains(QT_CONFIG, opengles2) { @@ -91,8 +96,7 @@ CONFIG(blackberry) { qqnxbpseventfilter.cpp \ qqnxvirtualkeyboardbps.cpp \ qqnxtheme.cpp \ - qqnxsystemsettings.cpp \ - qqnxfiledialoghelper.cpp + qqnxsystemsettings.cpp HEADERS += qqnxnavigatorbps.h \ qqnxeventdispatcher_blackberry.h \ @@ -105,6 +109,17 @@ CONFIG(blackberry) { LIBS += -lbps } +CONFIG(blackberry-playbook) { + SOURCES += qqnxfiledialoghelper_playbook.cpp +} else { + CONFIG(blackberry) { + SOURCES += qqnxfiledialoghelper_bb10.cpp \ + qqnxfilepicker.cpp + + HEADERS += qqnxfilepicker.h + } +} + CONFIG(qqnx_pps) { DEFINES += QQNX_PPS diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp index d94d3c092a..133bf02fee 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp @@ -41,11 +41,12 @@ #include "qqnxbpseventfilter.h" #include "qqnxnavigatoreventhandler.h" -#include "qqnxfiledialoghelper.h" #include "qqnxscreen.h" #include "qqnxscreeneventhandler.h" #include "qqnxvirtualkeyboardbps.h" +#include "qqnxfiledialoghelper.h" +#include <QCoreApplication> #include <QAbstractEventDispatcher> #include <QDebug> @@ -126,6 +127,7 @@ void QQnxBpsEventFilter::unregisterForScreenEvents(QQnxScreen *screen) qWarning("QQNX: failed to unregister for screen events on screen %p", screen->nativeContext()); } +#if defined(Q_OS_BLACKBERRY_TABLET) void QQnxBpsEventFilter::registerForDialogEvents(QQnxFileDialogHelper *dialog) { if (dialog_request_events(0) != BPS_SUCCESS) @@ -141,6 +143,7 @@ void QQnxBpsEventFilter::unregisterForDialogEvents(QQnxFileDialogHelper *dialog) if (count == 0) qWarning("QQNX: attempting to unregister dialog that was not registered"); } +#endif // Q_OS_BLACKBERRY_TABLET bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) { @@ -160,12 +163,14 @@ bool QQnxBpsEventFilter::nativeEventFilter(const QByteArray &eventType, void *me return m_screenEventHandler->handleEvent(screenEvent); } +#if defined(Q_OS_BLACKBERRY_TABLET) if (eventDomain == dialog_get_domain()) { dialog_instance_t nativeDialog = dialog_event_get_dialog_instance(event); QQnxFileDialogHelper *dialog = m_dialogMapper.value(nativeDialog, 0); if (dialog) return dialog->handleEvent(event); } +#endif if (eventDomain == navigator_get_domain()) return handleNavigatorEvent(event); @@ -244,6 +249,11 @@ bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event) break; } + case NAVIGATOR_LOW_MEMORY: + qWarning() << "QGuiApplication based process" << QCoreApplication::applicationPid() + << "received \"NAVIGATOR_LOW_MEMORY\" event"; + return false; + default: qBpsEventFilterDebug() << Q_FUNC_INFO << "Unhandled navigator event. code=" << bps_event_get_code(event); return false; diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.h b/src/plugins/platforms/qnx/qqnxbpseventfilter.h index e897863efb..f8e36823d5 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.h +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.h @@ -73,8 +73,10 @@ public: void registerForScreenEvents(QQnxScreen *screen); void unregisterForScreenEvents(QQnxScreen *screen); +#ifdef Q_OS_BLACKBERRY_TABLET void registerForDialogEvents(QQnxFileDialogHelper *dialog); void unregisterForDialogEvents(QQnxFileDialogHelper *dialog); +#endif private: bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h index e17ea80501..ad2483365b 100644 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.h +++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper.h @@ -44,12 +44,19 @@ #include <qpa/qplatformdialoghelper.h> -#include <bps/dialog.h> QT_BEGIN_NAMESPACE class QQnxIntegration; +#if defined(Q_OS_BLACKBERRY_TABLET) +#include <bps/dialog.h> +#define NativeDialogPtr dialog_instance_t +#else +class QQnxFilePicker; +#define NativeDialogPtr QQnxFilePicker * +#endif + class QQnxFileDialogHelper : public QPlatformFileDialogHelper { Q_OBJECT @@ -57,7 +64,9 @@ public: explicit QQnxFileDialogHelper(const QQnxIntegration *); ~QQnxFileDialogHelper(); +#if defined(Q_OS_BLACKBERRY_TABLET) bool handleEvent(bps_event_t *event); +#endif void exec(); @@ -73,21 +82,24 @@ public: void selectNameFilter(const QString &filter); QString selectedNameFilter() const; - dialog_instance_t nativeDialog() const { return m_dialog; } + NativeDialogPtr nativeDialog() const { return m_dialog; } Q_SIGNALS: void dialogClosed(); private: void setNameFilter(const QString &filter); + void setNameFilters(const QStringList &filters); const QQnxIntegration *m_integration; - dialog_instance_t m_dialog; + NativeDialogPtr m_dialog; QFileDialogOptions::AcceptMode m_acceptMode; QString m_selectedFilter; QPlatformDialogHelper::DialogCode m_result; +#if defined(Q_OS_BLACKBERRY_TABLET) QStringList m_paths; +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp new file mode 100644 index 0000000000..f4c48610a6 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper_bb10.cpp @@ -0,0 +1,209 @@ +/*************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqnxfiledialoghelper.h" + +#include "qqnxfilepicker.h" +#include "qqnxbpseventfilter.h" +#include "qqnxscreen.h" +#include "qqnxintegration.h" + +#include <QDebug> +#include <QEventLoop> +#include <QScreen> +#include <QTimer> +#include <QWindow> + +#ifdef QQNXFILEDIALOGHELPER_DEBUG +#define qFileDialogHelperDebug qDebug +#else +#define qFileDialogHelperDebug QT_NO_QDEBUG_MACRO +#endif + +QT_BEGIN_NAMESPACE + +QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration) + : QPlatformFileDialogHelper(), + m_integration(integration), + m_dialog(new QQnxFilePicker), + m_acceptMode(QFileDialogOptions::AcceptOpen), + m_selectedFilter(), + m_result(QPlatformDialogHelper::Rejected) +{ +} + +QQnxFileDialogHelper::~QQnxFileDialogHelper() +{ + delete m_dialog; +} + +void QQnxFileDialogHelper::exec() +{ + qFileDialogHelperDebug() << Q_FUNC_INFO; + + // Clear any previous results + m_dialog->setDirectories(QStringList()); + + QEventLoop loop; + connect(m_dialog, SIGNAL(closed()), &loop, SLOT(quit())); + loop.exec(); + + if (m_dialog->selectedFiles().isEmpty()) + Q_EMIT reject(); + else + Q_EMIT accept(); +} + +bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) +{ + Q_UNUSED(flags); + Q_UNUSED(parent); + Q_UNUSED(modality); + + qFileDialogHelperDebug() << Q_FUNC_INFO; + + // Create dialog + const QSharedPointer<QFileDialogOptions> &opts = options(); + if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) { + // Select one or many files? + const QQnxFilePicker::Mode mode = (opts->fileMode() == QFileDialogOptions::ExistingFiles) + ? QQnxFilePicker::PickerMultiple : QQnxFilePicker::Picker; + + m_dialog->setMode(mode); + + // Set the actual list of extensions + if (!opts->nameFilters().isEmpty()) + setNameFilters(opts->nameFilters()); + else + setNameFilter(tr("All files (*.*)")); + } else { + const QQnxFilePicker::Mode mode = (opts->initiallySelectedFiles().count() >= 2) + ? QQnxFilePicker::SaverMultiple : QQnxFilePicker::Saver; + + m_dialog->setMode(mode); + + if (!opts->initiallySelectedFiles().isEmpty()) + m_dialog->setDefaultSaveFileNames(opts->initiallySelectedFiles()); + } + + // Cache the accept mode so we know which functions to use to get the results back + m_acceptMode = opts->acceptMode(); + m_dialog->setTitle(opts->windowTitle()); + m_dialog->open(); + + return true; +} + +void QQnxFileDialogHelper::hide() +{ + qFileDialogHelperDebug() << Q_FUNC_INFO; + m_dialog->close(); +} + +bool QQnxFileDialogHelper::defaultNameFilterDisables() const +{ + qFileDialogHelperDebug() << Q_FUNC_INFO; + return false; +} + +void QQnxFileDialogHelper::setDirectory(const QString &directory) +{ + m_dialog->addDirectory(directory); +} + +QString QQnxFileDialogHelper::directory() const +{ + qFileDialogHelperDebug() << Q_FUNC_INFO; + if (!m_dialog->directories().isEmpty()) + return m_dialog->directories().first(); + + return QString(); +} + +void QQnxFileDialogHelper::selectFile(const QString &fileName) +{ + m_dialog->addDefaultSaveFileName(fileName); +} + +QStringList QQnxFileDialogHelper::selectedFiles() const +{ + qFileDialogHelperDebug() << Q_FUNC_INFO; + return m_dialog->selectedFiles(); +} + +void QQnxFileDialogHelper::setFilter() +{ + // No native api to support setting a filter from QDir::Filters + qFileDialogHelperDebug() << Q_FUNC_INFO; +} + +void QQnxFileDialogHelper::selectNameFilter(const QString &filter) +{ + qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter; + setNameFilter(filter); +} + +QString QQnxFileDialogHelper::selectedNameFilter() const +{ + // For now there is no way for the user to change the selected filter + // so this just reflects what the developer has set programmatically. + qFileDialogHelperDebug() << Q_FUNC_INFO; + return m_selectedFilter; +} + +void QQnxFileDialogHelper::setNameFilter(const QString &filter) +{ + qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter; + + setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter)); +} + +void QQnxFileDialogHelper::setNameFilters(const QStringList &filters) +{ + qFileDialogHelperDebug() << Q_FUNC_INFO << "filters =" << filters; + + Q_ASSERT(!filters.isEmpty()); + + m_dialog->setFilters(filters); + m_selectedFilter = filters.first(); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxfiledialoghelper.cpp b/src/plugins/platforms/qnx/qqnxfiledialoghelper_playbook.cpp index 0325a33268..12e8d8afbf 100644 --- a/src/plugins/platforms/qnx/qqnxfiledialoghelper.cpp +++ b/src/plugins/platforms/qnx/qqnxfiledialoghelper_playbook.cpp @@ -118,7 +118,7 @@ bool QQnxFileDialogHelper::handleEvent(bps_event_t *event) m_result = QPlatformDialogHelper::Rejected; } - emit dialogClosed(); + Q_EMIT dialogClosed(); return true; } @@ -135,9 +135,9 @@ void QQnxFileDialogHelper::exec() loop.exec(); if (m_result == QPlatformDialogHelper::Accepted) - emit accept(); + Q_EMIT accept(); else - emit reject(); + Q_EMIT reject(); } bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) @@ -291,9 +291,15 @@ QString QQnxFileDialogHelper::selectedNameFilter() const void QQnxFileDialogHelper::setNameFilter(const QString &filter) { qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter; + setNameFilters(QPlatformFileDialogHelper::cleanFilterList(filter)); +} + +void QQnxFileDialogHelper::setNameFilters(const QStringList &filters) +{ + qFileDialogHelperDebug() << Q_FUNC_INFO << "filters =" << filters; + + Q_ASSERT(!filters.isEmpty()); - // Extract the globbing expressions - QStringList filters = QPlatformFileDialogHelper::cleanFilterList(filter); char **globs = new char*[filters.size()]; for (int i = 0; i < filters.size(); ++i) { QByteArray glob = filters.at(i).toLocal8Bit(); @@ -303,7 +309,7 @@ void QQnxFileDialogHelper::setNameFilter(const QString &filter) // Set the filters dialog_set_filebrowse_filter(m_dialog, const_cast<const char**>(globs), filters.size()); - m_selectedFilter = filter; + m_selectedFilter = filters.first(); // Cleanup for (int i = 0; i < filters.size(); ++i) diff --git a/src/plugins/platforms/qnx/qqnxfilepicker.cpp b/src/plugins/platforms/qnx/qqnxfilepicker.cpp new file mode 100644 index 0000000000..5229d1f1f5 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxfilepicker.cpp @@ -0,0 +1,289 @@ +/*************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqnxfilepicker.h" + +#include <QAbstractEventDispatcher> +#include <QCoreApplication> +#include <QDebug> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonArray> +#include <QJsonParseError> +#include <QUrl> + +#include <bps/navigator.h> +#include <bps/navigator_invoke.h> + +#include <errno.h> + +#ifdef QQNXFILEPICKER_DEBUG +#define qFilePickerDebug qDebug +#else +#define qFilePickerDebug QT_NO_QDEBUG_MACRO +#endif + +static const char s_filePickerTarget[] = "sys.filepicker.target"; + +QQnxFilePicker::QQnxFilePicker(QObject *parent) + : QObject(parent) + , m_invocationHandle(0) + , m_mode(QQnxFilePicker::Picker) + , m_title(tr("Pick a file")) +{ + QCoreApplication::eventDispatcher()->installNativeEventFilter(this); +} + +QQnxFilePicker::~QQnxFilePicker() +{ + cleanup(); + + QCoreApplication::eventDispatcher()->removeNativeEventFilter(this); +} + +void QQnxFilePicker::open() +{ + if (m_invocationHandle) + return; + + int errorCode = BPS_SUCCESS; + + errorCode = navigator_invoke_invocation_create(&m_invocationHandle); + if (errorCode != BPS_SUCCESS) { + qWarning() << "QQnxFilePicker: unable to create invocation:" << strerror(errno); + return; + } + + errorCode = navigator_invoke_invocation_set_target(m_invocationHandle, s_filePickerTarget); + + if (errorCode != BPS_SUCCESS) { + cleanup(); + qWarning() << "QQnxFilePicker: unable to set target:" << strerror(errno); + return; + } + + errorCode = navigator_invoke_invocation_set_action(m_invocationHandle, "bb.action.OPEN"); + if (errorCode != BPS_SUCCESS) { + cleanup(); + qWarning() << "QQnxFilePicker: unable to set action:" << strerror(errno); + return; + } + + errorCode = navigator_invoke_invocation_set_type(m_invocationHandle, "application/vnd.blackberry.file_picker"); + if (errorCode != BPS_SUCCESS) { + cleanup(); + qWarning() << "QQnxFilePicker: unable to set mime type:" << strerror(errno); + return; + } + + QVariantMap map; + map[QStringLiteral("Type")] = QStringLiteral("Other"); + map[QStringLiteral("Mode")] = modeToString(m_mode); + map[QStringLiteral("Title")] = m_title; + map[QStringLiteral("ViewMode")] = QStringLiteral("Default"); + map[QStringLiteral("SortBy")] = QStringLiteral("Default"); + map[QStringLiteral("SortOrder")] = QStringLiteral("Default"); + map[QStringLiteral("ImageCrop")] = false; + map[QStringLiteral("AllowOverwrite")] = false; + + if (!m_defaultSaveFileNames.isEmpty()) + map[QStringLiteral("DefaultFileNames")] = m_defaultSaveFileNames.join(","); + if (!m_filters.isEmpty()) + map[QStringLiteral("Filter")] = m_filters.join(";"); + + QJsonDocument document; + document.setObject(QJsonObject::fromVariantMap(map)); + const QByteArray jsonData = document.toJson(QJsonDocument::Compact); + + errorCode = navigator_invoke_invocation_set_data(m_invocationHandle, jsonData.constData(), jsonData.size()); + if (errorCode != BPS_SUCCESS) { + cleanup(); + qWarning() << "QQnxFilePicker: unable to set data:" << strerror(errno); + return; + } + + navigator_invoke_invocation_send(m_invocationHandle); +} + +void QQnxFilePicker::close() +{ + navigator_card_close_child(); + cleanup(); +} + +bool QQnxFilePicker::nativeEventFilter(const QByteArray&, void *message, long*) +{ + bps_event_t * const event = static_cast<bps_event_t*>(message); + if (!event) + return false; + + if (bps_event_get_code(event) == NAVIGATOR_INVOKE_TARGET_RESULT) { + const char *id = navigator_event_get_id(event); + const char *err = navigator_event_get_err(event); + qFilePickerDebug("received invocation response: id=%s err=%s", id, err); + } else if (bps_event_get_code(event) == NAVIGATOR_CHILD_CARD_CLOSED) { + const char *data = navigator_event_get_card_closed_data(event); + qFilePickerDebug("received data: data='%s'", data); + handleFilePickerResponse(data); + } + + return false; // do not drop the event +} + +void QQnxFilePicker::setMode(QQnxFilePicker::Mode mode) +{ + m_mode = mode; +} + +void QQnxFilePicker::setDefaultSaveFileNames(const QStringList &fileNames) +{ + m_defaultSaveFileNames = fileNames; +} + +void QQnxFilePicker::addDefaultSaveFileName(const QString &fileName) +{ + m_defaultSaveFileNames.append(fileName); +} + +void QQnxFilePicker::setDirectories(const QStringList &directories) +{ + m_directories = directories; +} + +void QQnxFilePicker::addDirectory(const QString &directory) +{ + m_directories.append(directory); +} + +void QQnxFilePicker::setFilters(const QStringList &filters) +{ + m_filters = filters; +} + +void QQnxFilePicker::setTitle(const QString &title) +{ + m_title = title; +} + +QQnxFilePicker::Mode QQnxFilePicker::mode() const +{ + return m_mode; +} + +QStringList QQnxFilePicker::defaultSaveFileNames() const +{ + return m_defaultSaveFileNames; +} + +QStringList QQnxFilePicker::directories() const +{ + return m_directories; +} + +QStringList QQnxFilePicker::filters() const +{ + return m_filters; +} + +QStringList QQnxFilePicker::selectedFiles() const +{ + return m_selectedFiles; +} + +QString QQnxFilePicker::title() const +{ + return m_title; +} + +void QQnxFilePicker::cleanup() +{ + if (m_invocationHandle) { + navigator_invoke_invocation_destroy(m_invocationHandle); + m_invocationHandle = 0; + } +} + +void QQnxFilePicker::handleFilePickerResponse(const char *data) +{ + QJsonParseError jsonError; + QJsonDocument document = QJsonDocument::fromJson(data, &jsonError); + + if (jsonError.error != QJsonParseError::NoError) { + qFilePickerDebug() << "Error parsing FilePicker response: " + << jsonError.errorString(); + Q_EMIT closed(); + cleanup(); + return; + } + + // The response is a list of Json objects. + const QVariantList array = document.array().toVariantList(); + + foreach (const QVariant &variant, array) { + const QJsonObject object = QJsonObject::fromVariantMap(variant.toMap()); + const QUrl url(object.value(QStringLiteral("uri")).toString()); + const QString localFile = url.toLocalFile(); // strip "file://" + + if (!localFile.isEmpty()) + m_selectedFiles << localFile; + + qFilePickerDebug() << "FilePicker uri response:" << localFile; + } + + Q_EMIT closed(); + cleanup(); +} + +QString QQnxFilePicker::modeToString(QQnxFilePicker::Mode mode) const +{ + switch (mode) { + case Picker: + return QStringLiteral("Picker"); + case Saver: + return QStringLiteral("Saver"); + case PickerMultiple: + return QStringLiteral("PickerMultiple"); + case SaverMultiple: + return QStringLiteral("SaverMultiple"); + } + + return QStringLiteral("Picker"); +} diff --git a/src/plugins/platforms/kms/qkmsudevlistener.h b/src/plugins/platforms/qnx/qqnxfilepicker.h index 7534f0bcd3..5bb8f0969f 100644 --- a/src/plugins/platforms/kms/qkmsudevlistener.h +++ b/src/plugins/platforms/qnx/qqnxfilepicker.h @@ -1,6 +1,6 @@ -/**************************************************************************** +/*************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Research In Motion ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -39,40 +39,72 @@ ** ****************************************************************************/ -#ifndef QKMSUDEVLISTENER_H -#define QKMSUDEVLISTENER_H +#ifndef QQNXFILEPICKER_H +#define QQNXFILEPICKER_H +#include <QAbstractNativeEventFilter> #include <QObject> -#include <QMap> -#include <QList> -#include <QPointer> -#include <QString> +#include <QStringList> -#include <qkmsudevhandler.h> +struct navigator_invoke_invocation_t; -#include <libudev.h> - -QT_BEGIN_NAMESPACE - -class QKmsUdevListener : public QObject +class QQnxFilePicker : public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: - QKmsUdevListener(QObject *parent = 0); - ~QKmsUdevListener(); + explicit QQnxFilePicker(QObject *parent = 0); + ~QQnxFilePicker(); + + enum Mode { + Picker, + Saver, + PickerMultiple, + SaverMultiple + }; + + bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; + + void setMode(Mode mode); + void setDefaultSaveFileNames(const QStringList &fileNames); + void addDefaultSaveFileName(const QString &fileName); + void setDirectories(const QStringList &directories); + void addDirectory(const QString &directory); + void setFilters(const QStringList &filters); + void setTitle(const QString &title); + + Mode mode() const; + + QStringList defaultSaveFileNames() const; + QStringList directories() const; + QStringList filters() const; + QStringList selectedFiles() const; - void addHandler(QKmsUdevHandler *); + QString title() const; + +Q_SIGNALS: + void closed(); + +public Q_SLOTS: + void open(); + void close(); private: - QList<QPointer<QKmsUdevHandler> > m_handlers; - QMap<QString, QPointer<QObject> > m_devices; - struct udev *m_udev; + void cleanup(); + void handleFilePickerResponse(const char *data); - void scan(); - bool create(struct udev_device *); -}; + QString modeToString(Mode mode) const; + + navigator_invoke_invocation_t *m_invocationHandle; -QT_END_NAMESPACE + Mode m_mode; + + QStringList m_defaultSaveFileNames; + QStringList m_directories; + QStringList m_filters; + QStringList m_selectedFiles; + + QString m_title; +}; -#endif // QKMSUDEVLISTENER_H +#endif // QQNXFILEPICKER_H diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index feb05e3093..fa9961ccce 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include "qqnxintegration.h" +#if defined(QQNX_SCREENEVENTTHREAD) #include "qqnxscreeneventthread.h" +#endif #include "qqnxnativeinterface.h" #include "qqnxrasterbackingstore.h" #include "qqnxscreen.h" @@ -84,6 +86,8 @@ #include <qpa/qplatformwindow.h> #include <qpa/qwindowsysteminterface.h> +#include <QtGui/private/qguiapplication_p.h> + #if !defined(QT_NO_OPENGL) #include "qqnxglcontext.h" #include <QtGui/QOpenGLContext> @@ -107,9 +111,20 @@ QT_BEGIN_NAMESPACE QQnxWindowMapper QQnxIntegration::ms_windowMapper; QMutex QQnxIntegration::ms_windowMapperMutex; -QQnxIntegration::QQnxIntegration() +static inline QQnxIntegration::Options parseOptions(const QStringList ¶mList) +{ + QQnxIntegration::Options options = QQnxIntegration::NoOptions; + if (!paramList.contains(QLatin1String("no-fullscreen"))) { + options |= QQnxIntegration::FullScreenApplication; + } + return options; +} + +QQnxIntegration::QQnxIntegration(const QStringList ¶mList) : QPlatformIntegration() +#if defined(QQNX_SCREENEVENTTHREAD) , m_screenEventThread(0) +#endif , m_navigatorEventHandler(new QQnxNavigatorEventHandler()) , m_virtualKeyboard(0) #if defined(QQNX_PPS) @@ -134,6 +149,7 @@ QQnxIntegration::QQnxIntegration() #if !defined(QT_NO_DRAGANDDROP) , m_drag(new QSimpleDrag()) #endif + , m_options(parseOptions(paramList)) { qIntegrationDebug() << Q_FUNC_INFO; // Open connection to QNX composition manager @@ -185,8 +201,13 @@ QQnxIntegration::QQnxIntegration() #if defined(Q_OS_BLACKBERRY) QQnxVirtualKeyboardBps* virtualKeyboardBps = new QQnxVirtualKeyboardBps; - m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, - (m_screenEventThread ? 0 : m_screenEventHandler), virtualKeyboardBps); + +#if defined(QQNX_SCREENEVENTTHREAD) + m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, 0, virtualKeyboardBps); +#else + m_bpsEventFilter = new QQnxBpsEventFilter(m_navigatorEventHandler, m_screenEventHandler, virtualKeyboardBps); +#endif + m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher); m_virtualKeyboard = virtualKeyboardBps; @@ -383,7 +404,7 @@ QPlatformDrag *QQnxIntegration::drag() const QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { qIntegrationDebug() << Q_FUNC_INFO; - if (hint == ShowIsFullScreen) + if ((hint == ShowIsFullScreen) && (m_options & FullScreenApplication)) return true; return QPlatformIntegration::styleHint(hint); @@ -526,6 +547,11 @@ QQnxScreen *QQnxIntegration::primaryDisplay() const return m_screens.first(); } +QQnxIntegration::Options QQnxIntegration::options() const +{ + return m_options; +} + bool QQnxIntegration::supportsNavigatorEvents() const { // If QQNX_PPS or Q_OS_BLACKBERRY is defined then we have navigator diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index e3eb9e06ba..dd8973b767 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -51,7 +51,9 @@ QT_BEGIN_NAMESPACE class QQnxBpsEventFilter; +#if defined(QQNX_SCREENEVENTTHREAD) class QQnxScreenEventThread; +#endif class QQnxFileDialogHelper; class QQnxNativeInterface; class QQnxWindow; @@ -80,7 +82,12 @@ typedef QHash<screen_window_t, QWindow *> QQnxWindowMapper; class QQnxIntegration : public QPlatformIntegration { public: - QQnxIntegration(); + enum Option { // Options to be passed on command line. + NoOptions = 0x0, + FullScreenApplication = 0x1 + }; + Q_DECLARE_FLAGS(Options, Option) + explicit QQnxIntegration(const QStringList ¶mList); ~QQnxIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const; @@ -129,6 +136,8 @@ public: void createDisplay(screen_display_t display, bool isPrimary); void removeDisplay(QQnxScreen *screen); QQnxScreen *primaryDisplay() const; + Options options() const; + private: void createDisplays(); void destroyDisplays(); @@ -137,7 +146,9 @@ private: static void removeWindow(screen_window_t qnxWindow); screen_context_t m_screenContext; +#if defined(QQNX_SCREENEVENTTHREAD) QQnxScreenEventThread *m_screenEventThread; +#endif QQnxNavigatorEventHandler *m_navigatorEventHandler; QQnxAbstractVirtualKeyboard *m_virtualKeyboard; #if defined(QQNX_PPS) @@ -164,6 +175,8 @@ private: static QQnxWindowMapper ms_windowMapper; static QMutex ms_windowMapperMutex; + const Options m_options; + friend class QQnxWindow; }; diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp index 7204e5bce9..17b0d06245 100644 --- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp @@ -85,6 +85,11 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const if (window) targetWindow = static_cast<QQnxWindow *>(window->handle()); + // we only need to flush the platformWindow backing store, since this is + // the buffer where all drawing operations of all windows, including the + // child windows, are performed; conceptually ,child windows have no buffers + // (actually they do have a 1x1 placeholder buffer due to libscreen limitations), + // since Qt will only draw to the backing store of the top-level window. QQnxWindow *platformWindow = this->platformWindow(); if (!targetWindow || targetWindow == platformWindow) { @@ -102,29 +107,6 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion ®ion, const // update the display with newly rendered content platformWindow->post(region); - } else if (targetWindow) { - - // The contents of the backing store should be flushed to a different window than the - // window which owns the buffer. - // This typically happens for child windows, since child windows share a backing store with - // their top-level window (TLW). - // Simply copy the buffer over to the child window, to emulate a painting operation, and - // then post the window. - // - // ### Note that because of the design in the QNX QPA plugin, each window has its own buffers, - // even though they might share a backing store. This is unneeded overhead, but I don't think - // libscreen allows to have windows without buffers, or does it? - - // We assume that the TLW has been flushed previously and that no changes were made to the - // backing store inbetween (### does Qt guarantee this?) - Q_ASSERT(!m_hasUnflushedPaintOperations); - - targetWindow->adjustBufferSize(); - targetWindow->blitFrom(platformWindow, offset, region); - targetWindow->post(region); - - } else { - qWarning() << Q_FUNC_INFO << "flush() called without a valid window!"; } m_hasUnflushedPaintOperations = false; diff --git a/src/plugins/platforms/qnx/qqnxtheme.cpp b/src/plugins/platforms/qnx/qqnxtheme.cpp index 733b7223b6..37c1079441 100644 --- a/src/plugins/platforms/qnx/qqnxtheme.cpp +++ b/src/plugins/platforms/qnx/qqnxtheme.cpp @@ -58,10 +58,8 @@ QQnxTheme::~QQnxTheme() bool QQnxTheme::usePlatformNativeDialog(DialogType type) const { -#if defined(Q_OS_BLACKBERRY_TABLET) if (type == QPlatformTheme::FileDialog) return true; -#endif #if !defined(QT_NO_COLORDIALOG) if (type == QPlatformTheme::ColorDialog) return false; @@ -76,10 +74,8 @@ bool QQnxTheme::usePlatformNativeDialog(DialogType type) const QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) const { switch (type) { -#if defined(Q_OS_BLACKBERRY_TABLET) case QPlatformTheme::FileDialog: return new QQnxFileDialogHelper(m_integration); -#endif #if !defined(QT_NO_COLORDIALOG) case QPlatformTheme::ColorDialog: #endif diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 4c95950a7e..cd79ae73fd 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -335,6 +335,9 @@ QSize QQnxWindow::requestedBufferSize() const void QQnxWindow::adjustBufferSize() { + if (m_parentWindow) + return; + const QSize windowSize = window()->size(); if (windowSize != bufferSize()) setBufferSize(windowSize); @@ -573,8 +576,18 @@ void QQnxWindow::setParent(const QPlatformWindow *window) setScreen(m_parentWindow->m_screen); m_parentWindow->m_childWindows.push_back(this); + + // we don't need any buffers, since + // Qt will draw to the parent TLW + // backing store. + setBufferSize(QSize(1, 1)); } else { m_screen->addWindow(this); + + // recreate buffers, in case the + // window has been reparented and + // becomes a TLW + adjustBufferSize(); } m_screen->updateHierarchy(); diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index c0f1b3a000..7407d88f8b 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -215,7 +215,9 @@ QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *di if (QWindowsContext::verboseFonts) qDebug("%s %g", __FUNCTION__, pixelSize); - d->directWriteFactory->AddRef(); + Q_ASSERT(m_directWriteFontFace); + + m_fontEngineData->directWriteFactory->AddRef(); m_directWriteFontFace->AddRef(); fontDef.pixelSize = pixelSize; @@ -237,19 +239,17 @@ QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite() void QWindowsFontEngineDirectWrite::collectMetrics() { - if (m_directWriteFontFace != 0) { - DWRITE_FONT_METRICS metrics; - - m_directWriteFontFace->GetMetrics(&metrics); - m_unitsPerEm = metrics.designUnitsPerEm; - - m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness); - m_ascent = DESIGN_TO_LOGICAL(metrics.ascent); - m_descent = DESIGN_TO_LOGICAL(metrics.descent); - m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight); - m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap); - m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition); - } + DWRITE_FONT_METRICS metrics; + + m_directWriteFontFace->GetMetrics(&metrics); + m_unitsPerEm = metrics.designUnitsPerEm; + + m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness); + m_ascent = DESIGN_TO_LOGICAL(metrics.ascent); + m_descent = DESIGN_TO_LOGICAL(metrics.descent); + m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight); + m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap); + m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition); } QFixed QWindowsFontEngineDirectWrite::underlinePosition() const @@ -272,31 +272,24 @@ bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, ui { bool ret = false; - if (m_directWriteFontFace) { - DWORD t = qbswap<quint32>(tag); - - const void *tableData = 0; - void *tableContext = 0; - UINT32 tableSize; - BOOL exists; - HRESULT hr = m_directWriteFontFace->TryGetFontTable( - t, &tableData, &tableSize, &tableContext, &exists - ); - - if (SUCCEEDED(hr)) { - if (exists) { - if (!buffer) { - *length = tableSize; - ret = true; - } else if (*length >= tableSize) { - memcpy(buffer, tableData, tableSize); - ret = true; - } - } - m_directWriteFontFace->ReleaseFontTable(tableContext); - } else { - qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__); + const void *tableData = 0; + UINT32 tableSize; + void *tableContext = 0; + BOOL exists; + HRESULT hr = m_directWriteFontFace->TryGetFontTable(qbswap<quint32>(tag) + &tableData, &tableSize, + &tableContext, &exists); + if (SUCCEEDED(hr)) { + if (exists) { + ret = true; + if (buffer && *length >= tableSize) + memcpy(buffer, tableData, tableSize); + else + *length = tableSize; } + m_directWriteFontFace->ReleaseFontTable(tableContext); + } else { + qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__); } return ret; @@ -327,43 +320,43 @@ inline unsigned int getChar(const QChar *str, int &i, const int len) bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const { - if (m_directWriteFontFace != 0) { - QVarLengthArray<UINT32> codePoints(len); - for (int i=0; i<len; ++i) { - codePoints[i] = getChar(str, i, len); - if (flags & QFontEngine::RightToLeft) - codePoints[i] = QChar::mirroredChar(codePoints[i]); - } + if (*nglyphs < len) { + *nglyphs = len; + return false; + } - QVarLengthArray<UINT16> glyphIndices(len); - HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), - len, - glyphIndices.data()); + QVarLengthArray<UINT32> codePoints(len); + int actualLength = 0; + if (flags & QFontEngine::RightToLeft) { + for (int i = 0; i < len; ++i) + codePoints[actualLength++] = QChar::mirroredChar(getChar(str, i, len)); + } else { + for (int i = 0; i < len; ++i) + codePoints[actualLength++] = getChar(str, i, len); + } - if (SUCCEEDED(hr)) { - for (int i=0; i<len; ++i) - glyphs->glyphs[i] = glyphIndices[i]; + QVarLengthArray<UINT16> glyphIndices(actualLength); + HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(), actualLength, + glyphIndices.data()); + if (FAILED(hr)) { + qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__); + return false; + } - *nglyphs = len; - glyphs->numGlyphs = len; + for (int i = 0; i < actualLength; ++i) + glyphs->glyphs[i] = glyphIndices.at(i); - if (!(flags & GlyphIndicesOnly)) - recalcAdvances(glyphs, 0); + *nglyphs = actualLength; + glyphs->numGlyphs = actualLength; - return true; - } else { - qErrnoWarning("%s: GetGlyphIndicesW failed", __FUNCTION__); - } - } + if (!(flags & GlyphIndicesOnly)) + recalcAdvances(glyphs, 0); - return false; + return true; } void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const { - if (m_directWriteFontFace == 0) - return; - QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs); // ### Caching? @@ -391,9 +384,6 @@ void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEn void QWindowsFontEngineDirectWrite::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags) { - if (m_directWriteFontFace == 0) - return; - QVarLengthArray<UINT16> glyphIndices(nglyphs); QVarLengthArray<DWRITE_GLYPH_OFFSET> glyphOffsets(nglyphs); QVarLengthArray<FLOAT> glyphAdvances(nglyphs); @@ -439,9 +429,6 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(const QGlyphLayout &g glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g) { - if (m_directWriteFontFace == 0) - return glyph_metrics_t(); - UINT16 glyphIndex = g; DWRITE_GLYPH_METRICS glyphMetrics; @@ -668,14 +655,14 @@ bool QWindowsFontEngineDirectWrite::canRender(const QChar *string, int len) if (FAILED(hr)) { qErrnoWarning("%s: GetGlyphIndices failed", __FUNCTION__); return false; - } else { - for (int i=0; i<glyphIndices.size(); ++i) { - if (glyphIndices.at(i) == 0) - return false; - } + } - return true; + for (int i = 0; i < actualLength; ++i) { + if (glyphIndices.at(i) == 0) + return false; } + + return true; } QFontEngine::Type QWindowsFontEngineDirectWrite::type() const diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h index 106087f757..ab14cb49eb 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h @@ -107,8 +107,6 @@ public: static QString fontNameSubstitute(const QString &familyName); private: - friend class QRawFontPrivate; - QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform); void collectMetrics(); diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 844e46eec5..2531dc681a 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -595,7 +595,8 @@ public: void operator delete (void *) {} }; -QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, + QPlatformTheme::IconOptions iconOptions) const { /* We don't use the variable, but by storing it statically, we * ensure CoInitialize is only called once. */ @@ -604,6 +605,8 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s static QCache<QString, FakePointer<int> > dirIconEntryCache(1000); static QMutex mx; + static int defaultFolderIIcon = 0; + const bool useDefaultFolderIcon = iconOptions & QPlatformTheme::DontUseCustomDirectoryIcons; QPixmap pixmap; const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); @@ -612,7 +615,8 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot(); if (cacheableDirIcon) { QMutexLocker locker(&mx); - int iIcon = **dirIconEntryCache.object(filePath); + int iIcon = (useDefaultFolderIcon && defaultFolderIIcon) ? defaultFolderIIcon + : **dirIconEntryCache.object(filePath); if (iIcon) { QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize), pixmap); if (pixmap.isNull()) // Let's keep both caches in sync @@ -629,13 +633,24 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s #else iconSize|SHGFI_SYSICONINDEX; #endif // Q_OS_WINCE - unsigned long val = SHGetFileInfo((const wchar_t *)filePath.utf16(), 0, - &info, sizeof(SHFILEINFO), flags); + unsigned long val = 0; + if (cacheableDirIcon && useDefaultFolderIcon) { + flags |= SHGFI_USEFILEATTRIBUTES; + val = SHGetFileInfo(L"dummy", + FILE_ATTRIBUTE_DIRECTORY, + &info, sizeof(SHFILEINFO), flags); + } else { + val = SHGetFileInfo(reinterpret_cast<const wchar_t *>(filePath.utf16()), 0, + &info, sizeof(SHFILEINFO), flags); + } // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases if (val && info.hIcon) { QString key; if (cacheableDirIcon) { + if (useDefaultFolderIcon && !defaultFolderIIcon) + defaultFolderIIcon = info.iIcon; + //using the unique icon index provided by windows save us from duplicate keys key = dirIconPixmapCacheKey(info.iIcon, iconSize); QPixmapCache::find(key, pixmap); diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index bbd7f4623f..9346621d59 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -68,7 +68,8 @@ public: { return m_fonts[type]; } virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; - virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; + virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, + QPlatformTheme::IconOptions iconOptions = 0) const; void windowsThemeChanged(QWindow *window); |