diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfiledialog_mac.mm | 27 | ||||
-rw-r--r-- | src/gui/dialogs/qfontdialog.cpp | 20 | ||||
-rw-r--r-- | src/gui/dialogs/qfontdialog_mac.mm | 395 | ||||
-rw-r--r-- | src/gui/dialogs/qfontdialog_p.h | 12 | ||||
-rw-r--r-- | src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 13 | ||||
-rw-r--r-- | src/gui/kernel/qkeymapper_x11.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 6 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 11 | ||||
-rw-r--r-- | src/gui/painting/qcolormap.qdoc | 10 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 2 | ||||
-rw-r--r-- | src/gui/styles/qstylehelper.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 70 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft_p.h | 16 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 2 | ||||
-rw-r--r-- | src/gui/widgets/qscrollbar.cpp | 1 |
18 files changed, 282 insertions, 324 deletions
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 67daced..14a5f15 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -295,10 +295,14 @@ QT_USE_NAMESPACE if (!mQDirFilterEntryList->contains(info.fileName())) return NO; - // Always accept directories regardless of their names: + // Always accept directories regardless of their names (unless it is a bundle): BOOL isDir; - if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir) - return YES; + if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir) { + if ([mSavePanel treatsFilePackagesAsDirectories] == NO) { + if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO) + return YES; + } + } // No filter means accept everything if (mSelectedNameFilter->isEmpty()) @@ -725,6 +729,7 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void NavFileOrFolderInfo *theInfo = static_cast<NavFileOrFolderInfo *>(info); QString file; + QString path; const QtMacFilterName &fn = fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection); if (theItem->descriptorType == typeFSRef) { @@ -732,10 +737,12 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void AEGetDescData(theItem, &ref, sizeof(ref)); UInt8 str_buffer[1024]; FSRefMakePath(&ref, str_buffer, 1024); - file = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer)); - int slsh = file.lastIndexOf(QLatin1Char('/')); + path = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer)); + int slsh = path.lastIndexOf(QLatin1Char('/')); if (slsh != -1) - file = file.right(file.length() - slsh - 1); + file = path.right(path.length() - slsh - 1); + else + file = path; } QStringList reg = fn.regexp.split(QLatin1String(";")); for (QStringList::const_iterator it = reg.constBegin(); it != reg.constEnd(); ++it) { @@ -747,7 +754,13 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void if (rg.exactMatch(file)) return true; } - return (theInfo->isFolder && !file.endsWith(QLatin1String(".app"))); + + if (theInfo->isFolder) { + if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:qt_mac_QStringToNSString(path)]) + return false; + return true; + } + return false; } void QFileDialogPrivate::qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg, diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index b987611..b159fa7 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -174,6 +174,11 @@ void QFontDialogPrivate::init() { Q_Q(QFontDialog); +#ifdef Q_WS_MAC + nativeDialogInUse = false; + delegate = 0; +#endif + q->setSizeGripEnabled(true); q->setWindowTitle(QFontDialog::tr("Select Font")); @@ -329,10 +334,6 @@ void QFontDialogPrivate::init() familyList->setFocus(); retranslateStrings(); - -#ifdef Q_WS_MAC - delegate = 0; -#endif } /*! @@ -345,8 +346,7 @@ QFontDialog::~QFontDialog() #ifdef Q_WS_MAC Q_D(QFontDialog); if (d->delegate) { - QFontDialogPrivate::closeCocoaFontPanel(d->delegate); - QFontDialogPrivate::sharedFontPanelAvailable = true; + d->closeCocoaFontPanel(); return; } #endif @@ -428,14 +428,6 @@ QFont QFontDialog::getFont(bool *ok, QWidget *parent) QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options) { -#ifdef Q_WS_MAC - if (!(options & QFontDialog::DontUseNativeDialog) - && QFontDialogPrivate::sharedFontPanelAvailable) { - return QFontDialogPrivate::execCocoaFontPanel(ok, initial, parent, - title.isEmpty() ? QFontDialog::tr("Select Font") : title, options); - } -#endif - QFontDialog dlg(parent); dlg.setOptions(options); dlg.setCurrentFont(initial); diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index 67d32b8..919790b 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -58,6 +58,14 @@ typedef float CGFloat; // Should only not be defined on 32-bit platforms #endif +QT_BEGIN_NAMESPACE + +extern void macStartInterceptNSPanelCtor(); +extern void macStopInterceptNSPanelCtor(); +extern NSButton *macCreateButton(const char *text, NSView *superview); +extern bool qt_mac_is_macsheet(const QWidget *w); // qwidget_mac.mm + +QT_END_NAMESPACE QT_USE_NAMESPACE // should a priori be kept in sync with qcolordialog_mac.mm @@ -95,7 +103,8 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin BOOL mPanelHackedWithButtons; CGFloat mDialogExtraWidth; CGFloat mDialogExtraHeight; - NSModalSession mModalSession; + int mReturnCode; + BOOL mAppModal; } - (id)initWithFontPanel:(NSFontPanel *)panel stolenContentView:(NSView *)stolenContentView @@ -104,9 +113,11 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin priv:(QFontDialogPrivate *)priv extraWidth:(CGFloat)extraWidth extraHeight:(CGFloat)extraHeight; +- (void)showModelessPanel; +- (void)showWindowModalSheet:(QWidget *)docWidget; +- (void)runApplicationModalPanel; - (void)changeFont:(id)sender; - (void)changeAttributes:(id)sender; -- (void)setModalSession:(NSModalSession)session; - (BOOL)windowShouldClose:(id)window; - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize; - (void)relayout; @@ -163,7 +174,8 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) mPanelHackedWithButtons = (okButton != 0); mDialogExtraWidth = extraWidth; mDialogExtraHeight = extraHeight; - mModalSession = 0; + mReturnCode = -1; + mAppModal = false; if (mPanelHackedWithButtons) { [self relayout]; @@ -174,6 +186,20 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) [cancelButton setAction:@selector(onCancelClicked)]; [cancelButton setTarget:self]; } + +#ifdef QT_MAC_USE_COCOA + // Stack the native dialog in front of its parent, if any: + QFontDialog *q = mPriv->fontDialog(); + if (!qt_mac_is_macsheet(q)) { + if (QWidget *parent = q->parentWidget()) { + if (parent->isWindow()) { + [qt_mac_window_for(parent) + addChildWindow:[mStolenContentView window] ordered:NSWindowAbove]; + } + } + } +#endif + mQtFont = new QFont(); return self; } @@ -184,6 +210,50 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) [super dealloc]; } +- (void)showModelessPanel +{ + mAppModal = false; + NSWindow *ourPanel = [mStolenContentView window]; + [ourPanel makeKeyAndOrderFront:self]; +} + +- (void)runApplicationModalPanel +{ + QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); + mAppModal = true; + NSWindow *ourPanel = [mStolenContentView window]; + [NSApp runModalForWindow:ourPanel]; + QAbstractEventDispatcher::instance()->interrupt(); + + if (mReturnCode == NSOKButton) + mPriv->fontDialog()->accept(); + else + mPriv->fontDialog()->reject(); +} + +- (void)showWindowModalSheet:(QWidget *)docWidget +{ +#ifdef QT_MAC_USE_COCOA + NSWindow *window = qt_mac_window_for(docWidget); +#else + WindowRef hiwindowRef = qt_mac_window_for(docWidget); + NSWindow *window = [[NSWindow alloc] initWithWindowRef:hiwindowRef]; + CFRetain(hiwindowRef); +#endif + + mAppModal = false; + NSWindow *ourPanel = [mStolenContentView window]; + [NSApp beginSheet:ourPanel + modalForWindow:window + modalDelegate:0 + didEndSelector:0 + contextInfo:0 ]; + +#ifndef QT_MAC_USE_COCOA + CFRelease(hiwindowRef); +#endif +} + - (void)changeFont:(id)sender { NSFont *dummyFont = [NSFont userFontOfSize:12.0]; @@ -216,12 +286,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) mPriv->updateSampleFont(*mQtFont); } -- (void)setModalSession:(NSModalSession)session -{ - Q_ASSERT(!mModalSession); - mModalSession = session; -} - - (BOOL)windowShouldClose:(id)window { Q_UNUSED(window); @@ -282,9 +346,8 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) NSSize cancelSizeHint = [mCancelButton frame].size; const CGFloat ButtonWidth = qMin(qMax(ButtonMinWidth, - qMax(okSizeHint.width, cancelSizeHint.width)), - CGFloat((frameSize.width - 2.0 * ButtonSideMargin - - ButtonSpacing) * 0.5)); + qMax(okSizeHint.width, cancelSizeHint.width)), + CGFloat((frameSize.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5)); const CGFloat ButtonHeight = qMax(ButtonMinHeight, qMax(okSizeHint.height, cancelSizeHint.height)); @@ -317,14 +380,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) NSFontManager *fontManager = [NSFontManager sharedFontManager]; [self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]], *mQtFont)]; - [[mStolenContentView window] close]; [self finishOffWithCode:NSOKButton]; } - (void)onCancelClicked { Q_ASSERT(mPanelHackedWithButtons); - [[mStolenContentView window] close]; [self finishOffWithCode:NSCancelButton]; } @@ -368,20 +429,26 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) - (void)finishOffWithCode:(NSInteger)code { - if (mPriv) { - if (mModalSession) { - [NSApp endModalSession:mModalSession]; - mModalSession = 0; +#ifdef QT_MAC_USE_COCOA + QFontDialog *q = mPriv->fontDialog(); + if (QWidget *parent = q->parentWidget()) { + if (parent->isWindow()) { + [qt_mac_window_for(parent) removeChildWindow:[mStolenContentView window]]; } - // Hack alert! - // Since this code path was never intended to be followed when starting from exec - // we need to force the dialog to communicate the new font, otherwise the signal - // won't get emitted. - if(code == NSOKButton) - mPriv->sampleEdit->setFont([self qtFont]); - mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); - } else { + } +#endif + + if(code == NSOKButton) + mPriv->sampleEdit->setFont([self qtFont]); + + if (mAppModal) { + mReturnCode = code; [NSApp stopModalWithCode:code]; + } else { + if (code == NSOKButton) + mPriv->fontDialog()->accept(); + else + mPriv->fontDialog()->reject(); } } @@ -408,206 +475,16 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) QT_BEGIN_NAMESPACE -extern void macStartInterceptNSPanelCtor(); -extern void macStopInterceptNSPanelCtor(); -extern NSButton *macCreateButton(const char *text, NSView *superview); - -void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial, - QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options, - QFontDialogPrivate *priv) -{ - Q_UNUSED(parent); // we would use the parent if only NSFontPanel could be a sheet - QMacCocoaAutoReleasePool pool; - - /* - The standard Cocoa font panel has no OK or Cancel button and - is created as a utility window. For strange reasons (which seem - to stem from the fact that the font panel is based on a NIB - file), the approach we use for the color panel doesn't work for - the font panel (and, inversely, the approach we use here doesn't - quite work for color panel, and crashed last time I tried). So - instead, we take the following steps: - - 1. Constructs a plain NSPanel that looks the way we want it - to look. Specifically, if the NoButtons option is off, we - construct a panel without the NSUtilityWindowMask flag - and with buttons (OK and Cancel). - - 2. Steal the content view from the shared NSFontPanel and - put it inside our new NSPanel's content view, together - with the OK and Cancel buttons. - - 3. Lay out the original content view and the buttons when - the font panel is shown and whenever it is resized. - - 4. Clean up after ourselves. - - PS. Some customization is also done in QCocoaApplication - validModesForFontPanel:. - */ - - Qt::WindowModality modality = Qt::ApplicationModal; - if (priv) - modality = priv->fontDialog()->windowModality(); - - bool needButtons = !(options & QFontDialog::NoButtons); - // don't need our own panel if the title bar isn't visible anyway (in a sheet) - bool needOwnPanel = (needButtons && modality != Qt::WindowModal); - - bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists]; - NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel]; - [sharedFontPanel setHidesOnDeactivate:false]; - - // hack to ensure that QCocoaApplication's validModesForFontPanel: - // implementation is honored - if (!sharedFontPanelExisted && needOwnPanel) { - [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel]; - [sharedFontPanel close]; - } - - NSPanel *ourPanel = 0; - NSView *stolenContentView = 0; - NSButton *okButton = 0; - NSButton *cancelButton = 0; - - CGFloat dialogExtraWidth = 0.0; - CGFloat dialogExtraHeight = 0.0; - - if (!needOwnPanel) { - // we can reuse the NSFontPanel unchanged - ourPanel = sharedFontPanel; - } else { - // compute dialogExtra{Width,Height} - dialogExtraWidth = 2.0 * DialogSideMargin; - dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight - + ButtonBottomMargin; - - // compute initial contents rectangle - NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]]; - contentRect.size.width += dialogExtraWidth; - contentRect.size.height += dialogExtraHeight; - - // create the new panel - ourPanel = [[NSPanel alloc] initWithContentRect:contentRect - styleMask:StyleMask - backing:NSBackingStoreBuffered - defer:YES]; - [ourPanel setReleasedWhenClosed:YES]; - } - - stolenContentView = [sharedFontPanel contentView]; - - if (needButtons) { - // steal the font panel's contents view - [stolenContentView retain]; - [sharedFontPanel setContentView:0]; - - // create a new content view and add the stolen one as a subview - NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } }; - NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect]; - [ourContentView addSubview:stolenContentView]; - - // create OK and Cancel buttons and add these as subviews - okButton = macCreateButton("&OK", ourContentView); - cancelButton = macCreateButton("Cancel", ourContentView); - - [ourPanel setContentView:ourContentView]; - [ourPanel setDefaultButtonCell:[okButton cell]]; - } - - // create a delegate and set it - QCocoaFontPanelDelegate *delegate = - [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel - stolenContentView:stolenContentView - okButton:okButton - cancelButton:cancelButton - priv:priv - extraWidth:dialogExtraWidth - extraHeight:dialogExtraHeight]; - [ourPanel setDelegate:delegate]; - [[NSFontManager sharedFontManager] setDelegate:delegate]; -#ifdef QT_MAC_USE_COCOA - [[NSFontManager sharedFontManager] setTarget:delegate]; -#endif - setFont(delegate, initial); - - // hack to get correct initial layout - NSRect frameRect = [ourPanel frame]; - frameRect.size.width += 1.0; - [ourPanel setFrame:frameRect display:NO]; - frameRect.size.width -= 1.0; - frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size]; - [ourPanel setFrame:frameRect display:NO]; - [ourPanel center]; - - [ourPanel setTitle:(NSString*)(CFStringRef)QCFString(title)]; - - if (priv) { - switch (modality) { - case Qt::WindowModal: - if (parent) { -#ifndef QT_MAC_USE_COCOA - WindowRef hiwindowRef = qt_mac_window_for(parent); - NSWindow *window = - [[NSWindow alloc] initWithWindowRef:hiwindowRef]; - // Cocoa docs say I should retain the Carbon ref. - CFRetain(hiwindowRef); -#else - NSWindow *window = qt_mac_window_for(parent); -#endif - [NSApp beginSheet:ourPanel - modalForWindow:window - modalDelegate:0 - didEndSelector:0 - contextInfo:0]; -#ifndef QT_MAC_USE_COCOA - [window release]; -#endif - break; - } - // fallthrough - case Qt::ApplicationModal: - [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]]; - break; - default: - [ourPanel makeKeyAndOrderFront:ourPanel]; - } - } - return delegate; -} - -void QFontDialogPrivate::closeCocoaFontPanel(void *delegate) +void QFontDialogPrivate::closeCocoaFontPanel() { QMacCocoaAutoReleasePool pool; QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate); NSWindow *ourPanel = [theDelegate actualPanel]; [ourPanel close]; [theDelegate cleanUpAfterMyself]; - [theDelegate autorelease]; -} - -QFont QFontDialogPrivate::execCocoaFontPanel(bool *ok, const QFont &initial, - QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options) -{ - QMacCocoaAutoReleasePool pool; - QCocoaFontPanelDelegate *delegate = - static_cast<QCocoaFontPanelDelegate *>( - openCocoaFontPanel(initial, parent, title, options)); - NSWindow *ourPanel = [delegate actualPanel]; - [ourPanel retain]; - int rval = [NSApp runModalForWindow:ourPanel]; - QFont font([delegate qtFont]); - [ourPanel release]; - [delegate cleanUpAfterMyself]; - [delegate release]; - bool isOk = ((options & QFontDialog::NoButtons) || rval == NSOKButton); - if (ok) - *ok = isOk; - if (isOk) { - return font; - } else { - return initial; - } + [theDelegate release]; + this->delegate = 0; + sharedFontPanelAvailable = true; } void QFontDialogPrivate::setFont(void *delegate, const QFont &font) @@ -645,10 +522,13 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font) [static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font]; } -void *QFontDialogPrivate::_q_constructNativePanel() +void QFontDialogPrivate::createNSFontPanelDelegate() { - QMacCocoaAutoReleasePool pool; + if (delegate) + return; + sharedFontPanelAvailable = false; + QMacCocoaAutoReleasePool pool; bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists]; NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel]; [sharedFontPanel setHidesOnDeactivate:false]; @@ -670,8 +550,7 @@ void *QFontDialogPrivate::_q_constructNativePanel() // compute dialogExtra{Width,Height} dialogExtraWidth = 2.0 * DialogSideMargin; - dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight - + ButtonBottomMargin; + dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight + ButtonBottomMargin; // compute initial contents rectangle NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]]; @@ -684,7 +563,6 @@ void *QFontDialogPrivate::_q_constructNativePanel() backing:NSBackingStoreBuffered defer:YES]; [ourPanel setReleasedWhenClosed:YES]; - stolenContentView = [sharedFontPanel contentView]; // steal the font panel's contents view @@ -704,21 +582,23 @@ void *QFontDialogPrivate::_q_constructNativePanel() [ourPanel setContentView:ourContentView]; [ourPanel setDefaultButtonCell:[okButton cell]]; } - // create a delegate and set it - QCocoaFontPanelDelegate *delegate = - [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel + + // create the delegate and set it + QCocoaFontPanelDelegate *del = [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel stolenContentView:stolenContentView okButton:okButton cancelButton:cancelButton priv:this extraWidth:dialogExtraWidth extraHeight:dialogExtraHeight]; - [ourPanel setDelegate:delegate]; - [[NSFontManager sharedFontManager] setDelegate:delegate]; + delegate = del; + [ourPanel setDelegate:del]; + + [[NSFontManager sharedFontManager] setDelegate:del]; #ifdef QT_MAC_USE_COCOA - [[NSFontManager sharedFontManager] setTarget:delegate]; + [[NSFontManager sharedFontManager] setTarget:del]; #endif - setFont(delegate, QApplication::font()); + setFont(del, q_func()->currentFont()); { // hack to get correct initial layout @@ -726,15 +606,12 @@ void *QFontDialogPrivate::_q_constructNativePanel() frameRect.size.width += 1.0; [ourPanel setFrame:frameRect display:NO]; frameRect.size.width -= 1.0; - frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size]; + frameRect.size = [del windowWillResize:ourPanel toSize:frameRect.size]; [ourPanel setFrame:frameRect display:NO]; [ourPanel center]; } NSString *title = @"Select font"; [ourPanel setTitle:title]; - - [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]]; - return delegate; } void QFontDialogPrivate::mac_nativeDialogModalHelp() @@ -759,29 +636,47 @@ void QFontDialogPrivate::mac_nativeDialogModalHelp() // and "adding" the buttons. void QFontDialogPrivate::_q_macRunNativeAppModalPanel() { - QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); + createNSFontPanelDelegate(); + QCocoaFontPanelDelegate *del = static_cast<QCocoaFontPanelDelegate *>(delegate); + [del runApplicationModalPanel]; +} + +bool QFontDialogPrivate::showCocoaFontPanel() +{ + if (!sharedFontPanelAvailable) + return false; + Q_Q(QFontDialog); - QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel(); - NSWindow *ourPanel = [delegate actualPanel]; - [ourPanel retain]; - int rval = [NSApp runModalForWindow:ourPanel]; - QAbstractEventDispatcher::instance()->interrupt(); - [ourPanel release]; - [delegate cleanUpAfterMyself]; - [delegate release]; - bool isOk = (rval == NSOKButton); - if(isOk) - rescode = QDialog::Accepted; + QMacCocoaAutoReleasePool pool; + createNSFontPanelDelegate(); + QCocoaFontPanelDelegate *del = static_cast<QCocoaFontPanelDelegate *>(delegate); + if (qt_mac_is_macsheet(q)) + [del showWindowModalSheet:q->parentWidget()]; else - rescode = QDialog::Rejected; + [del showModelessPanel]; + return true; } +bool QFontDialogPrivate::hideCocoaFontPanel() +{ + if (!delegate){ + // Nothing to do. We return false to leave the question + // open regarding whether or not to go native: + return false; + } else { + closeCocoaFontPanel(); + // Even when we hide it, we are still using a + // native dialog, so return true: + return true; + } +} bool QFontDialogPrivate::setVisible_sys(bool visible) { Q_Q(QFontDialog); if (!visible == q->isHidden()) return false; - return visible; + + return visible ? showCocoaFontPanel() : hideCocoaFontPanel(); } QT_END_NAMESPACE diff --git a/src/gui/dialogs/qfontdialog_p.h b/src/gui/dialogs/qfontdialog_p.h index 7654a80..8676be3 100644 --- a/src/gui/dialogs/qfontdialog_p.h +++ b/src/gui/dialogs/qfontdialog_p.h @@ -139,25 +139,21 @@ public: QByteArray memberToDisconnectOnClose; #ifdef Q_WS_MAC - static void *openCocoaFontPanel(const QFont &initial, - QWidget *parent, const QString &title, - QFontDialog::FontDialogOptions options, - QFontDialogPrivate *priv = 0); - static void closeCocoaFontPanel(void *delegate); - static QFont execCocoaFontPanel(bool *ok, const QFont &initial, QWidget *parent, - const QString &title, QFontDialog::FontDialogOptions options); static void setFont(void *delegate, const QFont &font); inline void done(int result) { q_func()->done(result); } inline QFontDialog *fontDialog() { return q_func(); } void *delegate; + void closeCocoaFontPanel(); bool nativeDialogInUse; bool canBeNativeDialog(); bool setVisible_sys(bool visible); - void *_q_constructNativePanel(); + void createNSFontPanelDelegate(); void _q_macRunNativeAppModalPanel(); void mac_nativeDialogModalHelp(); + bool showCocoaFontPanel(); + bool hideCocoaFontPanel(); static bool sharedFontPanelAvailable; #endif diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index ab71a05..5dcf613 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -179,7 +179,7 @@ static void cleanupCocoaApplicationDelegate() } // This function will only be called when NSApp is actually running. Before -// that, the kAEQuitApplication apple event will be sendt to +// that, the kAEQuitApplication Apple event will be sent to // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { @@ -196,21 +196,18 @@ static void cleanupCocoaApplicationDelegate() qAppInstance()->quit(); startedQuit = false; } + return NSTerminateNow; } if (qtPrivate->threadData->eventLoops.size() == 0) { // INVARIANT: No event loop is executing. This probably // means that Qt is used as a plugin, or as a part of a native - // Cocoa application. In any case it should be fine to + // Cocoa application. In any case it should be fine to // terminate now: return NSTerminateNow; - } else { - // Prevent Cocoa from terminating the application, since this simply - // exits the program whithout allowing QApplication::exec() to return. - // The call to QApplication::quit() above will instead quit the - // application from the Qt side. - return NSTerminateCancel; } + + return NSTerminateCancel; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index b32b626..d6d1042 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -1186,6 +1186,8 @@ static const unsigned int KeyTbl[] = { XF86XK_LaunchB, Qt::Key_LaunchD, XF86XK_LaunchC, Qt::Key_LaunchE, XF86XK_LaunchD, Qt::Key_LaunchF, + XF86XK_LaunchE, Qt::Key_LaunchG, + XF86XK_LaunchF, Qt::Key_LaunchH, // Qtopia keys QTOPIAXK_Select, Qt::Key_Select, diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5889589..4b45abd 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3428,8 +3428,10 @@ void QWidgetPrivate::show_sys() // The window is modally shaddowed, so we need to make // sure that we don't pop in front of the modal window: [window orderFront:window]; - if (NSWindow *modalWin = qt_mac_window_for(top)) - [modalWin orderFront:window]; + if (!top->testAttribute(Qt::WA_DontShowOnScreen)) { + if (NSWindow *modalWin = qt_mac_window_for(top)) + [modalWin orderFront:window]; + } } #endif if (q->windowType() == Qt::Popup) { diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index cd448a7..08d5572 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -543,7 +543,8 @@ void QColor::setNamedColor(const QString &name) be used to construct a valid QColor object, otherwise returns false. - The algorithm used is the same as with \a setNamedColor(). + It uses the same algorithm used in setNamedColor(). + \sa setNamedColor() */ bool QColor::isValidColor(const QString &name) @@ -2716,12 +2717,4 @@ QDataStream &operator>>(QDataStream &stream, QColor &color) \sa QColor::rgb(), QColor::rgba() */ -/*! \fn void QColormap::initialize() - \internal -*/ - -/*! \fn void QColormap::cleanup() - \internal -*/ - QT_END_NAMESPACE diff --git a/src/gui/painting/qcolormap.qdoc b/src/gui/painting/qcolormap.qdoc index 56fabf7..22a73fd 100644 --- a/src/gui/painting/qcolormap.qdoc +++ b/src/gui/painting/qcolormap.qdoc @@ -150,3 +150,13 @@ Assigns the given \a colormap to \e this color map and returns a reference to \e this color map. */ + +/*! + \fn void QColormap::initialize() + \internal +*/ + +/*! + \fn void QColormap::cleanup() + \internal +*/ diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index a7c2a0b..bfcf7db 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3390,7 +3390,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte }; for(int i = 0; i < glyphs.size(); i++) { - QFontEngineFT::Glyph *glyph = gset->glyph_data.value(glyphs[i]); + QFontEngineFT::Glyph *glyph = gset->getGlyph(glyphs[i]); if (!glyph || glyph->format != neededFormat) { if (!lockedFace) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index c5ce76c..a1ed8f5 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5758,18 +5758,18 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit /*! \fn void QPainter::drawStaticText(const QPoint &position, const QStaticText &staticText) - \since 4.7 - \overload + + Draws the \a staticText at the \a position. */ /*! \fn void QPainter::drawStaticText(int x, int y, const QStaticText &staticText) - \since 4.7 - \overload + + Draws the \a staticText at coordinates \a x and \a y. */ /*! diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index cf3957b..4418018 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -195,7 +195,7 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform); if (gset && ft->loadGlyphs(gset, &g, 1, format)) { - QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g); + QFontEngineFT::Glyph *glyph = gset->getGlyph(g); const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3 : (glyph->width + 3) & ~3); return QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, imageFormat); diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 359e7e1..296c51c 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -44,7 +44,6 @@ #include <qstyleoption.h> #include <qpainter.h> #include <qpixmapcache.h> -#include <qstringbuilder.h> #include <private/qmath_p.h> #include <private/qstyle_p.h> #include <qmath.h> @@ -55,6 +54,8 @@ #include <private/qt_cocoa_helpers_mac_p.h> #endif +#include <qstringbuilder.h> + QT_BEGIN_NAMESPACE // internal helper. Converts an integer value to an unique string token diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 17ade64..6b40aad 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -746,7 +746,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph) const { - Glyph *g = set->glyph_data.value(glyph); + Glyph *g = set->getGlyph(glyph); if (g) return g; @@ -858,10 +858,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph } } - Glyph *g = set->glyph_data.value(glyph); + Glyph *g = set->getGlyph(glyph); if (g && g->format == format) { if (uploadToServer && !g->uploadedToServer) { - set->glyph_data[glyph] = 0; + set->setGlyph(glyph, 0); delete g; g = 0; } else { @@ -1158,7 +1158,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph uploadGlyphToServer(set, glyph, g, &info, glyph_buffer_size); } - set->glyph_data[glyph] = g; + set->setGlyph(glyph, g); return g; } @@ -1381,8 +1381,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor } gs = &transformedGlyphSets[0]; - qDeleteAll(gs->glyph_data); - gs->glyph_data.clear(); + gs->clear(); gs->id = allocateServerGlyphSet(); @@ -1398,7 +1397,7 @@ bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, G FT_Face face = 0; for (int i = 0; i < num_glyphs; ++i) { - Glyph *glyph = gs->glyph_data.value(glyphs[i]); + Glyph *glyph = gs->getGlyph(glyphs[i]); if (glyph == 0 || glyph->format != format) { if (!face) { face = lockFace(); @@ -1635,7 +1634,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag FT_Face face = 0; if (flags & QTextEngine::DesignMetrics) { for (int i = 0; i < glyphs->numGlyphs; i++) { - Glyph *g = defaultGlyphSet.glyph_data.value(glyphs->glyphs[i]); + Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); if (g) { glyphs->advances_x[i] = QFixed::fromFixed(g->linearAdvance); } else { @@ -1648,7 +1647,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag } } else { for (int i = 0; i < glyphs->numGlyphs; i++) { - Glyph *g = defaultGlyphSet.glyph_data.value(glyphs->glyphs[i]); + Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); if (g) { glyphs->advances_x[i] = QFixed(g->advance); } else { @@ -1677,7 +1676,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) QFixed ymax = 0; QFixed xmax = 0; for (int i = 0; i < glyphs.numGlyphs; i++) { - Glyph *g = defaultGlyphSet.glyph_data.value(glyphs.glyphs[i]); + Glyph *g = defaultGlyphSet.getGlyph(glyphs.glyphs[i]); if (!g) { if (!face) face = lockFace(); @@ -1719,7 +1718,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph) { FT_Face face = 0; glyph_metrics_t overall; - Glyph *g = defaultGlyphSet.glyph_data.value(glyph); + Glyph *g = defaultGlyphSet.getGlyph(glyph); if (!g) { face = lockFace(); g = loadGlyph(glyph, Format_None, true); @@ -1783,8 +1782,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr transformedGlyphSets.prepend(QGlyphSet()); } glyphSet = &transformedGlyphSets[0]; - qDeleteAll(glyphSet->glyph_data); - glyphSet->glyph_data.clear(); + glyphSet->clear(); glyphSet->id = allocateServerGlyphSet(); glyphSet->transformationMatrix = m; } @@ -1792,7 +1790,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr } else { glyphSet = &defaultGlyphSet; } - Glyph * g = glyphSet->glyph_data.value(glyph); + Glyph * g = glyphSet->getGlyph(glyph); if (!g) { face = lockFace(); g = loadGlyphMetrics(glyphSet, glyph); @@ -1881,7 +1879,7 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransfor void QFontEngineFT::removeGlyphFromCache(glyph_t glyph) { - delete defaultGlyphSet.glyph_data.take(glyph); + defaultGlyphSet.removeGlyphFromCache(glyph); } int QFontEngineFT::glyphCount() const @@ -1937,11 +1935,53 @@ QFontEngineFT::QGlyphSet::QGlyphSet() transformationMatrix.yy = 0x10000; transformationMatrix.xy = 0; transformationMatrix.yx = 0; + memset(fast_glyph_data, 0, sizeof(fast_glyph_data)); + fast_glyph_count = 0; } QFontEngineFT::QGlyphSet::~QGlyphSet() { + clear(); +} + +void QFontEngineFT::QGlyphSet::clear() +{ + if (fast_glyph_count > 0) { + for (int i = 0; i < 256; ++i) { + if (fast_glyph_data[i]) { + delete fast_glyph_data[i]; + fast_glyph_data[i] = 0; + } + } + fast_glyph_count = 0; + } qDeleteAll(glyph_data); + glyph_data.clear(); +} + +void QFontEngineFT::QGlyphSet::removeGlyphFromCache(int index) +{ + if (index < 256) { + if (fast_glyph_data[index]) { + delete fast_glyph_data[index]; + fast_glyph_data[index] = 0; + if (fast_glyph_count > 0) + --fast_glyph_count; + } + } else { + delete glyph_data.take(index); + } +} + +void QFontEngineFT::QGlyphSet::setGlyph(int index, Glyph *glyph) +{ + if (index < 256) { + if (!fast_glyph_data[index]) + ++fast_glyph_count; + fast_glyph_data[index] = glyph; + } else { + glyph_data.insert(index, glyph); + } } unsigned long QFontEngineFT::allocateServerGlyphSet() diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 98dd002..12b7da8 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -180,7 +180,21 @@ public: FT_Matrix transformationMatrix; unsigned long id; // server sided id, GlyphSet for X11 bool outline_drawing; + + void removeGlyphFromCache(int index); + void clear(); + inline Glyph *getGlyph(int index) const + { + if (index < 256) + return fast_glyph_data[index]; + return glyph_data.value(index); + } + void setGlyph(int index, Glyph *glyph); + +private: mutable QHash<int, Glyph *> glyph_data; // maps from glyph index to glyph data + mutable Glyph *fast_glyph_data[256]; // for fast lookup of glyphs < 256 + mutable int fast_glyph_count; }; virtual QFontEngine::FaceId faceId() const; @@ -252,7 +266,7 @@ public: QGlyphSet *defaultGlyphs() { return &defaultGlyphSet; } GlyphFormat defaultGlyphFormat() const { return defaultFormat; } - inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.glyph_data.value(g); } + inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.getGlyph(g); } QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix); bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 8fe4c47..1fabf12 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -282,8 +282,10 @@ QString QStaticText::text() const } /*! - Sets the performance hint of the QStaticText. This hint can be used to customize how much - caching is done internally to improve performance. + Sets the performance hint of the QStaticText according to the \a + performanceHint provided. The \a performanceHint is used to + customize how much caching is done internally to improve + performance. The default is QStaticText::ModerateCaching. diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 2570cb5..43722a1 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1935,7 +1935,7 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar) if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) { for (int i=0; i<topLevelWidgets.size(); ++i) { QWidget *top = topLevelWidgets.at(i); - if (w != top && [qt_mac_window_for(top) isVisible]) { + if (w != top && top->isVisible()) { // INVARIANT: we found another visible window // on screen other than our modalWidget. We therefore // disable the menu bar to follow normal modality logic: diff --git a/src/gui/widgets/qscrollbar.cpp b/src/gui/widgets/qscrollbar.cpp index 4eff260..c0eeb2f 100644 --- a/src/gui/widgets/qscrollbar.cpp +++ b/src/gui/widgets/qscrollbar.cpp @@ -523,6 +523,7 @@ bool QScrollBar::event(QEvent *event) break; #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: { + event->ignore(); // override wheel event without adding virtual function override QWheelEvent *ev = static_cast<QWheelEvent *>(event); int delta = ev->delta(); |