Clean-up a macro for Cocoa
Remove the usage of Q_MAC_USE_COCOA and Carbon code paths. Change-Id: Ib569ad8c6d9ffe258f454b3c3b06e95294a10112 Reviewed-on: http://codereview.qt-project.org/5100 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com> Sanity-Review: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
parent
33233ca3e3
commit
9fa6e8f627
@ -40,16 +40,11 @@
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtGui/qmacnativewidget_mac.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
//![0]
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()->height() - 200, 239, 200)
|
||||
@ -85,50 +80,5 @@ int main(int argc, char **argv)
|
||||
[window makeKeyAndOrderFront:window];
|
||||
[pool release];
|
||||
//![0]
|
||||
#else
|
||||
//![1]
|
||||
Rect contentRect;
|
||||
SetRect(&contentRect, 200, 200, 400, 400);
|
||||
HIWindowRef windowRef;
|
||||
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowCompositingAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute, &contentRect, &windowRef);
|
||||
HIViewRef contentView = 0;
|
||||
GetRootControl(windowRef, &contentView);
|
||||
|
||||
QMacNativeWidget *nativeWidget = new QMacNativeWidget();
|
||||
nativeWidget->move(0, 0);
|
||||
nativeWidget->setPalette(QPalette(Qt::red));
|
||||
nativeWidget->setAutoFillBackground(true);
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
|
||||
pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
|
||||
layout->addWidget(pushButton);
|
||||
nativeWidget->setLayout(layout);
|
||||
HIViewRef nativeWidgetView = reinterpret_cast<HIViewRef>(nativeWidget->winId());
|
||||
// Add the nativeWidget to the window.
|
||||
HIViewAddSubview(contentView, nativeWidgetView);
|
||||
|
||||
// Adjust Carbon layouts
|
||||
HILayoutInfo layoutInfo;
|
||||
layoutInfo.version = kHILayoutInfoVersionZero;
|
||||
HIViewGetLayoutInfo(nativeWidgetView, &layoutInfo);
|
||||
|
||||
layoutInfo.binding.top.toView = contentView;
|
||||
layoutInfo.binding.top.kind = kHILayoutBindTop;
|
||||
layoutInfo.binding.left.toView = contentView;
|
||||
layoutInfo.binding.left.kind = kHILayoutBindLeft;
|
||||
layoutInfo.binding.right.toView = contentView;
|
||||
layoutInfo.binding.right.kind = kHILayoutBindRight;
|
||||
layoutInfo.binding.bottom.toView = contentView;
|
||||
layoutInfo.binding.bottom.kind = kHILayoutBindBottom;
|
||||
|
||||
HIViewSetLayoutInfo(nativeWidgetView, &layoutInfo);
|
||||
HIViewApplyLayout(nativeWidgetView);
|
||||
|
||||
pushButton->show();
|
||||
nativeWidget->show();
|
||||
// Show the window.
|
||||
ShowWindow(windowRef);
|
||||
//![1]
|
||||
#endif
|
||||
return app.exec(); // gives us the same behavior in both
|
||||
}
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#import <qmaccocoaviewcontainer_mac.h>
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
class SearchWidget : public QMacCocoaViewContainer
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -59,24 +58,6 @@ public:
|
||||
private:
|
||||
};
|
||||
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
// The SearchWidget class wraps a native HISearchField.
|
||||
class SearchWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
HIViewRef searchField;
|
||||
CFStringRef searchFieldText;
|
||||
|
||||
public:
|
||||
QSize sizeHint() const;
|
||||
SearchWidget(QWidget *parent = 0);
|
||||
~SearchWidget();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
QMenu *createMenu(QWidget *parent);
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
//![0]
|
||||
SearchWidget::SearchWidget(QWidget *parent)
|
||||
@ -84,56 +83,6 @@ QSize SearchWidget::sizeHint() const
|
||||
return QSize(150, 40);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// The SearchWidget class wraps a native HISearchField.
|
||||
SearchWidget::SearchWidget(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
|
||||
// Create a native search field and pass its window id to QWidget::create.
|
||||
searchFieldText = CFStringCreateWithCString(0, "search", 0);
|
||||
HISearchFieldCreate(NULL/*bounds*/, kHISearchFieldAttributesSearchIcon | kHISearchFieldAttributesCancel,
|
||||
NULL/*menu ref*/, searchFieldText, &searchField);
|
||||
create(reinterpret_cast<WId>(searchField));
|
||||
|
||||
// Use a Qt menu for the search field menu.
|
||||
QMenu *searchMenu = createMenu(this);
|
||||
MenuRef menuRef = searchMenu->macMenu(0);
|
||||
HISearchFieldSetSearchMenu(searchField, menuRef);
|
||||
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
}
|
||||
|
||||
SearchWidget::~SearchWidget()
|
||||
{
|
||||
CFRelease(searchField);
|
||||
CFRelease(searchFieldText);
|
||||
}
|
||||
|
||||
// Get the size hint from the search field.
|
||||
QSize SearchWidget::sizeHint() const
|
||||
{
|
||||
EventRef event;
|
||||
HIRect optimalBounds;
|
||||
CreateEvent(0, kEventClassControl,
|
||||
kEventControlGetOptimalBounds,
|
||||
GetCurrentEventTime(),
|
||||
kEventAttributeUserEvent, &event);
|
||||
|
||||
SendEventToEventTargetWithOptions(event,
|
||||
HIObjectGetEventTarget(HIObjectRef(winId())),
|
||||
kEventTargetDontPropagate);
|
||||
|
||||
GetEventParameter(event,
|
||||
kEventParamControlOptimalBounds, typeHIRect,
|
||||
0, sizeof(HIRect), 0, &optimalBounds);
|
||||
|
||||
ReleaseEvent(event);
|
||||
return QSize(optimalBounds.size.width + 100, // make it a bit wider.
|
||||
optimalBounds.size.height);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QMenu *createMenu(QWidget *parent)
|
||||
{
|
||||
|
@ -298,10 +298,6 @@ namespace QT_NAMESPACE {}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) && !defined(QT_BOOTSTRAPPED)
|
||||
#error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN)
|
||||
# undef Q_OS_UNIX
|
||||
#elif !defined(Q_OS_UNIX)
|
||||
@ -2740,7 +2736,6 @@ QT_LICENSED_MODULE(Sensors)
|
||||
#endif
|
||||
|
||||
#if !(defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) \
|
||||
&& !(defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) \
|
||||
&& !(defined(Q_WS_X11) && !defined(QT_NO_FREETYPE)) \
|
||||
&& !(defined(Q_WS_QPA))
|
||||
# define QT_NO_RAWFONT
|
||||
|
@ -152,13 +152,8 @@ public:
|
||||
RgnHandle toQDRgnForUpdate_sys() const;
|
||||
static QRegion fromQDRgn(RgnHandle shape);
|
||||
#endif
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
inline HIMutableShapeRef handle(bool unused = false) const
|
||||
{ Q_UNUSED(unused); return toHIMutableShape(); }
|
||||
#else
|
||||
inline RgnHandle handle() const { return handle(false); }
|
||||
inline RgnHandle handle(bool) const { return toQDRgn(); }
|
||||
#endif
|
||||
HIMutableShapeRef toHIMutableShape() const;
|
||||
static QRegion fromHIShapeRef(HIShapeRef shape);
|
||||
#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
|
||||
@ -201,8 +196,6 @@ Q_GUI_EXPORT
|
||||
#elif defined(Q_WS_X11)
|
||||
Region rgn;
|
||||
void *xrectangles;
|
||||
#elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
mutable RgnHandle unused; // Here for binary compatibility reasons. ### Qt 5 remove.
|
||||
#endif
|
||||
#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
|
||||
QRegionPrivate *qt_rgn;
|
||||
|
@ -367,7 +367,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
|
||||
|
||||
int QImageTextureGlyphCache::glyphMargin() const
|
||||
{
|
||||
#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
|
||||
#if defined(Q_WS_MAC) || defined(Q_WS_X11)
|
||||
return 0;
|
||||
#else
|
||||
return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
|
||||
|
@ -1489,12 +1489,8 @@ void QTextEngine::itemize() const
|
||||
int length = layoutData->string.length();
|
||||
if (!length)
|
||||
return;
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
// ATSUI requires RTL flags to correctly identify the character stops.
|
||||
bool ignore = false;
|
||||
#else
|
||||
|
||||
bool ignore = ignoreBidi;
|
||||
#endif
|
||||
|
||||
bool rtl = isRightToLeft();
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
|
||||
&& (p->transform().type() > QTransform::TxTranslate);
|
||||
if (toggleAntialiasing)
|
||||
p->setRenderHint(QPainter::Antialiasing);
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
// Always draw the cursor aligned to pixel boundary.
|
||||
x = qRound(x);
|
||||
#endif
|
||||
|
@ -78,9 +78,6 @@ class QPixmap;
|
||||
# undef qDebug
|
||||
# endif
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
# include <AGL/agl.h>
|
||||
#endif
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
# ifdef old_qDebug
|
||||
# undef qDebug
|
||||
|
@ -96,110 +96,19 @@ class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
|
||||
|
||||
public:
|
||||
QPageSetupDialogPrivate() : ep(0)
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
,upp(0)
|
||||
#else
|
||||
,pageLayout(0)
|
||||
#endif
|
||||
{}
|
||||
|
||||
~QPageSetupDialogPrivate() {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (upp) {
|
||||
DisposePMSheetDoneUPP(upp);
|
||||
upp = 0;
|
||||
}
|
||||
QHash<PMPrintSession, QPageSetupDialogPrivate *>::iterator it = sheetCallbackMap.begin();
|
||||
while (it != sheetCallbackMap.end()) {
|
||||
if (it.value() == this) {
|
||||
it = sheetCallbackMap.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
void openCarbonPageLayout(Qt::WindowModality modality);
|
||||
void closeCarbonPageLayout();
|
||||
static void pageSetupDialogSheetDoneCallback(PMPrintSession printSession, WindowRef /*documentWindow*/, Boolean accepted) {
|
||||
QPageSetupDialogPrivate *priv = sheetCallbackMap.value(printSession);
|
||||
if (!priv) {
|
||||
qWarning("%s:%d: QPageSetupDialog::exec: Could not retrieve data structure, "
|
||||
"you most likely now have an infinite modal loop", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
priv->q_func()->done(accepted ? QDialog::Accepted : QDialog::Rejected);
|
||||
}
|
||||
#else
|
||||
void openCocoaPageLayout(Qt::WindowModality modality);
|
||||
void closeCocoaPageLayout();
|
||||
#endif
|
||||
|
||||
QMacPrintEnginePrivate *ep;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
PMSheetDoneUPP upp;
|
||||
static QHash<PMPrintSession, QPageSetupDialogPrivate*> sheetCallbackMap;
|
||||
#else
|
||||
NSPageLayout *pageLayout;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QHash<PMPrintSession, QPageSetupDialogPrivate*> QPageSetupDialogPrivate::sheetCallbackMap;
|
||||
void QPageSetupDialogPrivate::openCarbonPageLayout(Qt::WindowModality modality)
|
||||
{
|
||||
Q_Q(QPageSetupDialog);
|
||||
// If someone is reusing a QPrinter object, the end released all our old
|
||||
// information. In this case, we must reinitialize.
|
||||
if (ep->session == 0)
|
||||
ep->initialize();
|
||||
|
||||
sheetCallbackMap.insert(ep->session, this);
|
||||
if (modality == Qt::ApplicationModal) {
|
||||
QWidget modal_widg(0, Qt::Window);
|
||||
modal_widg.setObjectName(QLatin1String(__FILE__ "__modal_dlg"));
|
||||
modal_widg.createWinId();
|
||||
QApplicationPrivate::enterModal(&modal_widg);
|
||||
QApplicationPrivate::native_modal_dialog_active = true;
|
||||
Boolean accepted;
|
||||
PMSessionPageSetupDialog(ep->session, ep->format, &accepted);
|
||||
QApplicationPrivate::leaveModal(&modal_widg);
|
||||
QApplicationPrivate::native_modal_dialog_active = false;
|
||||
pageSetupDialogSheetDoneCallback(ep->session, 0, accepted);
|
||||
} else {
|
||||
// Window Modal means that we use a sheet at the moment, there's no other way to do it correctly.
|
||||
if (!upp)
|
||||
upp = NewPMSheetDoneUPP(QPageSetupDialogPrivate::pageSetupDialogSheetDoneCallback);
|
||||
PMSessionUseSheets(ep->session, qt_mac_window_for(q->parentWidget()), upp);
|
||||
Boolean unused;
|
||||
PMSessionPageSetupDialog(ep->session, ep->format, &unused);
|
||||
}
|
||||
}
|
||||
|
||||
void QPageSetupDialogPrivate::closeCarbonPageLayout()
|
||||
{
|
||||
// if the margins have changed, we have to use the margins from the new
|
||||
// PMFormat object
|
||||
if (q_func()->result() == QDialog::Accepted) {
|
||||
PMPaper paper;
|
||||
PMPaperMargins margins;
|
||||
PMGetPageFormatPaper(ep->format, &paper);
|
||||
PMPaperGetMargins(paper, &margins);
|
||||
ep->leftMargin = margins.left;
|
||||
ep->topMargin = margins.top;
|
||||
ep->rightMargin = margins.right;
|
||||
ep->bottomMargin = margins.bottom;
|
||||
|
||||
PMRect paperRect;
|
||||
PMGetUnadjustedPaperRect(ep->format, &paperRect);
|
||||
ep->customSize = QSizeF(paperRect.right - paperRect.left,
|
||||
paperRect.bottom - paperRect.top);
|
||||
}
|
||||
sheetCallbackMap.remove(ep->session);
|
||||
}
|
||||
#else
|
||||
void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
|
||||
{
|
||||
Q_Q(QPageSetupDialog);
|
||||
@ -240,7 +149,6 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout()
|
||||
[pageLayout release];
|
||||
pageLayout = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
|
||||
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
|
||||
@ -263,32 +171,19 @@ void QPageSetupDialog::setVisible(bool visible)
|
||||
if (d->printer->outputFormat() != QPrinter::NativeFormat)
|
||||
return;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
bool isCurrentlyVisible = d->sheetCallbackMap.contains(d->ep->session);
|
||||
#else
|
||||
bool isCurrentlyVisible = (d->pageLayout != 0);
|
||||
#endif
|
||||
if (!visible == !isCurrentlyVisible)
|
||||
return;
|
||||
|
||||
if (visible) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->openCarbonPageLayout(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
#else
|
||||
d->openCocoaPageLayout(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->closeCarbonPageLayout();
|
||||
#else
|
||||
if (d->pageLayout) {
|
||||
d->closeCocoaPageLayout();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,14 +194,9 @@ int QPageSetupDialog::exec()
|
||||
if (d->printer->outputFormat() != QPrinter::NativeFormat)
|
||||
return Rejected;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->openCarbonPageLayout(Qt::ApplicationModal);
|
||||
d->closeCarbonPageLayout();
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
d->openCocoaPageLayout(Qt::ApplicationModal);
|
||||
d->closeCocoaPageLayout();
|
||||
#endif
|
||||
return result();
|
||||
}
|
||||
|
||||
|
@ -57,44 +57,10 @@ class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
|
||||
|
||||
public:
|
||||
QPrintDialogPrivate() : ep(0), printPanel(0)
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
,upp(0)
|
||||
#endif
|
||||
{}
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
~QPrintDialogPrivate() {
|
||||
if (upp) {
|
||||
DisposePMSheetDoneUPP(upp);
|
||||
upp = 0;
|
||||
}
|
||||
QHash<PMPrintSession, QPrintDialogPrivate *>::iterator it = sheetCallbackMap.begin();
|
||||
while (it != sheetCallbackMap.end()) {
|
||||
if (it.value() == this) {
|
||||
it = sheetCallbackMap.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
void openCarbonPrintPanel(Qt::WindowModality modality);
|
||||
void closeCarbonPrintPanel();
|
||||
static void printDialogSheetDoneCallback(PMPrintSession printSession, WindowRef /*documentWindow*/, Boolean accepted) {
|
||||
QPrintDialogPrivate *priv = sheetCallbackMap.value(printSession);
|
||||
if (!priv) {
|
||||
qWarning("%s:%d: QPrintDialog::exec: Could not retrieve data structure, "
|
||||
"you most likely now have an infinite loop", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
priv->q_func()->done(accepted ? QDialog::Accepted : QDialog::Rejected);
|
||||
priv->closeCarbonPrintPanel();
|
||||
}
|
||||
#else
|
||||
void openCocoaPrintPanel(Qt::WindowModality modality);
|
||||
void closeCocoaPrintPanel();
|
||||
#endif
|
||||
void initBeforeRun();
|
||||
|
||||
inline QPrintDialog *printDialog() { return q_func(); }
|
||||
@ -112,17 +78,12 @@ public:
|
||||
|
||||
QMacPrintEnginePrivate *ep;
|
||||
NSPrintPanel *printPanel;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
PMSheetDoneUPP upp;
|
||||
static QHash<PMPrintSession, QPrintDialogPrivate *> sheetCallbackMap;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
@class QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate);
|
||||
|
||||
@ -190,7 +151,6 @@ QT_USE_NAMESPACE
|
||||
}
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -218,76 +178,6 @@ void QPrintDialogPrivate::initBeforeRun()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QHash<PMPrintSession, QPrintDialogPrivate *> QPrintDialogPrivate::sheetCallbackMap;
|
||||
void QPrintDialogPrivate::openCarbonPrintPanel(Qt::WindowModality modality)
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
initBeforeRun();
|
||||
sheetCallbackMap.insert(ep->session, this);
|
||||
if (modality == Qt::ApplicationModal) {
|
||||
QWidget modal_widg(0, Qt::Window);
|
||||
modal_widg.setObjectName(QLatin1String(__FILE__ "__modal_dlg"));
|
||||
modal_widg.createWinId();
|
||||
QApplicationPrivate::enterModal(&modal_widg);
|
||||
QApplicationPrivate::native_modal_dialog_active = true;
|
||||
Boolean acceptStatus;
|
||||
PMSessionPrintDialog(ep->session, ep->settings, ep->format, &acceptStatus);
|
||||
QApplicationPrivate::leaveModal(&modal_widg);
|
||||
QApplicationPrivate::native_modal_dialog_active = false;
|
||||
printDialogSheetDoneCallback(ep->session, 0, acceptStatus);
|
||||
} else {
|
||||
// Window Modal means that we use a sheet at the moment, there's no other way to do it correctly.
|
||||
if (!upp)
|
||||
upp = NewPMSheetDoneUPP(QPrintDialogPrivate::printDialogSheetDoneCallback);
|
||||
PMSessionUseSheets(ep->session, qt_mac_window_for(q->parentWidget()), upp);
|
||||
QApplicationPrivate::native_modal_dialog_active = true;
|
||||
Boolean unused;
|
||||
PMSessionPrintDialog(ep->session, ep->settings, ep->format, &unused);
|
||||
}
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::closeCarbonPrintPanel()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
QApplicationPrivate::native_modal_dialog_active = false;
|
||||
if (q->result() == QDialog::Accepted) {
|
||||
UInt32 frompage, topage;
|
||||
PMGetFirstPage(ep->settings, &frompage);
|
||||
PMGetLastPage(ep->settings, &topage);
|
||||
topage = qMin(UInt32(INT_MAX), topage);
|
||||
q->setFromTo(frompage, topage);
|
||||
|
||||
// OK, I need to map these values back let's see
|
||||
// If from is 1 and to is INT_MAX, then print it all
|
||||
// (Apologies to the folks with more than INT_MAX pages)
|
||||
// ...that's a joke.
|
||||
if (q->fromPage() == 1 && q->toPage() == INT_MAX) {
|
||||
q->setPrintRange(QAbstractPrintDialog::AllPages);
|
||||
q->setFromTo(0,0);
|
||||
} else {
|
||||
q->setPrintRange(QAbstractPrintDialog::PageRange); // In a way a lie, but it shouldn't hurt.
|
||||
// Carbon hands us back a very large number here even for ALL, set it to max
|
||||
// in that case to follow the behavior of the other print dialogs.
|
||||
if (q->maxPage() < q->toPage())
|
||||
q->setFromTo(q->fromPage(), q->maxPage());
|
||||
}
|
||||
// Keep us in sync with file output
|
||||
PMDestinationType dest;
|
||||
PMSessionGetDestinationType(ep->session, ep->settings, &dest);
|
||||
if (dest == kPMDestinationFile) {
|
||||
QCFType<CFURLRef> file;
|
||||
PMSessionCopyDestinationLocation(ep->session, ep->settings, &file);
|
||||
UInt8 localFile[2048]; // Assuming there's a POSIX file system here.
|
||||
CFURLGetFileSystemRepresentation(file, true, localFile, sizeof(localFile));
|
||||
ep->outputFilename = QString::fromUtf8(reinterpret_cast<const char *>(localFile));
|
||||
} else {
|
||||
ep->outputFilename = QString();
|
||||
}
|
||||
}
|
||||
sheetCallbackMap.remove(ep->session);
|
||||
}
|
||||
#else
|
||||
void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
@ -327,7 +217,6 @@ void QPrintDialogPrivate::closeCocoaPrintPanel()
|
||||
{
|
||||
// ###
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool warnIfNotNative(QPrinter *printer)
|
||||
{
|
||||
@ -367,14 +256,10 @@ int QPrintDialog::exec()
|
||||
if (!warnIfNotNative(d->printer))
|
||||
return QDialog::Rejected;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->openCarbonPrintPanel(Qt::ApplicationModal);
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
|
||||
d->openCocoaPrintPanel(Qt::ApplicationModal);
|
||||
d->closeCocoaPrintPanel();
|
||||
#endif
|
||||
return result();
|
||||
}
|
||||
|
||||
@ -395,21 +280,12 @@ void QPrintDialog::setVisible(bool visible)
|
||||
return;
|
||||
|
||||
if (visible) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->openCarbonPrintPanel(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
#else
|
||||
d->openCocoaPrintPanel(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
if (d->printPanel) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->closeCarbonPrintPanel();
|
||||
#else
|
||||
d->closeCocoaPrintPanel();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -208,9 +208,6 @@ public:
|
||||
QActionGroup *printerGroup;
|
||||
QAction *printAction;
|
||||
QAction *pageSetupAction;
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
QAction *closeAction;
|
||||
#endif
|
||||
|
||||
QPointer<QObject> receiverToDisconnectOnClose;
|
||||
QByteArray memberToDisconnectOnClose;
|
||||
@ -304,9 +301,6 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
|
||||
toolbar->addSeparator();
|
||||
toolbar->addAction(pageSetupAction);
|
||||
toolbar->addAction(printAction);
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
toolbar->addAction(closeAction);
|
||||
#endif
|
||||
|
||||
// Cannot use the actions' triggered signal here, since it doesn't autorepeat
|
||||
QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
|
||||
@ -426,10 +420,6 @@ void QPrintPreviewDialogPrivate::setupActions()
|
||||
qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
|
||||
QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
|
||||
QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));
|
||||
QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));
|
||||
#endif
|
||||
|
||||
// Initial state:
|
||||
fitPageAction->setChecked(true);
|
||||
|
@ -78,11 +78,7 @@
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#include <Carbon/Carbon.h> // for SetFrontProcess
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#else
|
||||
#include <Security/AuthSession.h>
|
||||
#endif
|
||||
#undef verify
|
||||
#endif
|
||||
|
||||
@ -1797,10 +1793,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
IOPMAssertionID powerID;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef QT_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
@ -1816,13 +1810,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
||||
if (macNeedsActivate) {
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
SetFrontProcess(&psn);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
|
||||
if (ok != kIOReturnSuccess)
|
||||
macNeedsActivate = false; // no need to release the assertion on exit.
|
||||
#else
|
||||
UpdateSystemActivity(1); // Wake the display.
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1873,7 +1863,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
||||
}
|
||||
|
||||
QTestLog::stopLogging();
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (macNeedsActivate) {
|
||||
IOPMAssertionRelease(powerID);
|
||||
}
|
||||
@ -1887,7 +1877,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
||||
#endif
|
||||
|
||||
currentTestObject = 0;
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (macNeedsActivate) {
|
||||
IOPMAssertionRelease(powerID);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace QTest
|
||||
case MouseMove:
|
||||
QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton);
|
||||
//QCursor::setPos(window->mapToGlobal(pos));
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_OS_MAC
|
||||
QTest::qWait(20);
|
||||
#else
|
||||
qApp->processEvents();
|
||||
@ -183,7 +183,7 @@ namespace QTest
|
||||
break;
|
||||
case MouseMove:
|
||||
QCursor::setPos(widget->mapToGlobal(pos));
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_OS_MAC
|
||||
QTest::qWait(20);
|
||||
#else
|
||||
qApp->processEvents();
|
||||
|
@ -517,11 +517,6 @@ QFileDialogPrivate::QFileDialogPrivate()
|
||||
nativeDialogInUse(false),
|
||||
#ifdef Q_WS_MAC
|
||||
mDelegate(0),
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
mDialog(0),
|
||||
mDialogStarted(false),
|
||||
mDialogClosed(true),
|
||||
#endif
|
||||
#endif
|
||||
qFileDialogUi(0)
|
||||
{
|
||||
|
@ -276,11 +276,7 @@ QT_USE_NAMESPACE
|
||||
[mSavePanel
|
||||
beginSheetForDirectory:mCurrentDir
|
||||
file:selectable ? filename : nil
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
modalForWindow:QT_PREPEND_NAMESPACE(qt_mac_window_for)(docWidget)
|
||||
#else
|
||||
modalForWindow:nil
|
||||
#endif
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:nil];
|
||||
@ -558,34 +554,16 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding
|
||||
|
||||
void QFileDialogPrivate::setDirectory_sys(const QString &directory)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (directory == mCurrentLocation)
|
||||
return;
|
||||
mCurrentLocation = directory;
|
||||
emit q_func()->directoryEntered(mCurrentLocation);
|
||||
|
||||
FSRef fsRef;
|
||||
if (qt_mac_create_fsref(directory, &fsRef) == noErr) {
|
||||
AEDesc desc;
|
||||
if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr)
|
||||
NavCustomControl(mDialog, kNavCtlSetLocation, (void*)&desc);
|
||||
}
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
[delegate->mSavePanel setDirectory:qt_mac_QStringToNSString(directory)];
|
||||
#endif
|
||||
}
|
||||
|
||||
QString QFileDialogPrivate::directory_sys() const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return mCurrentLocation;
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
return qt_mac_NSStringToQString([delegate->mSavePanel directory]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::selectFile_sys(const QString &filename)
|
||||
@ -594,73 +572,28 @@ void QFileDialogPrivate::selectFile_sys(const QString &filename)
|
||||
if (QDir::isRelativePath(filePath))
|
||||
filePath = QFileInfo(directory_sys(), filePath).filePath();
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
// Update the selection list immidiatly, so
|
||||
// subsequent calls to selectedFiles() gets correct:
|
||||
mCurrentSelectionList.clear();
|
||||
mCurrentSelectionList << filename;
|
||||
if (mCurrentSelection != filename){
|
||||
mCurrentSelection = filename;
|
||||
emit q_func()->currentChanged(mCurrentSelection);
|
||||
}
|
||||
|
||||
AEDescList descList;
|
||||
if (AECreateList(0, 0, false, &descList) != noErr)
|
||||
return;
|
||||
|
||||
FSRef fsRef;
|
||||
if (qt_mac_create_fsref(filePath, &fsRef) == noErr) {
|
||||
AEDesc desc;
|
||||
if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr){
|
||||
if (AEPutDesc(&descList, 0, &desc) == noErr)
|
||||
NavCustomControl(mDialog, kNavCtlSetSelection, (void*)&descList);
|
||||
}
|
||||
}
|
||||
|
||||
// Type the file name into the save dialog's text field:
|
||||
UInt8 *strBuffer = (UInt8 *)malloc(1024);
|
||||
qt_mac_to_pascal_string(QFileInfo(filename).fileName(), strBuffer);
|
||||
NavCustomControl(mDialog, kNavCtlSetEditFileName, strBuffer);
|
||||
free(strBuffer);
|
||||
#else
|
||||
// There seems to no way to select a file once the dialog is running.
|
||||
// So do the next best thing, set the file's directory:
|
||||
setDirectory_sys(QFileInfo(filePath).absolutePath());
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList QFileDialogPrivate::selectedFiles_sys() const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (q_func()->acceptMode() == QFileDialog::AcceptOpen){
|
||||
return mCurrentSelectionList;
|
||||
} else {
|
||||
return QStringList() << mCurrentLocation + QLatin1Char('/')
|
||||
+ QCFString::toQString(NavDialogGetSaveFileName(mDialog));
|
||||
}
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
return [delegate selectedFiles];
|
||||
#endif
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_UNUSED(filters);
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
bool hideDetails = q_func()->testOption(QFileDialog::HideNameFilterDetails);
|
||||
[delegate setNameFilters:filters hideDetails:hideDetails];
|
||||
#endif
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::setFilter_sys()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#else
|
||||
Q_Q(QFileDialog);
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
@ -672,51 +605,32 @@ void QFileDialogPrivate::setFilter_sys()
|
||||
[delegate->mSavePanel setNameFieldLabel:[delegate strip:qFileDialogUi->fileNameLabel->text()]];
|
||||
|
||||
[delegate updateProperties];
|
||||
#endif
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::selectNameFilter_sys(const QString &filter)
|
||||
{
|
||||
int index = nameFilters.indexOf(filter);
|
||||
if (index != -1) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
NavMenuItemSpec navSpec;
|
||||
bzero(&navSpec, sizeof(NavMenuItemSpec));
|
||||
navSpec.menuType = index;
|
||||
NavCustomControl(mDialog, kNavCtlSelectCustomType, &navSpec);
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
[delegate->mPopUpButton selectItemAtIndex:index];
|
||||
[delegate filterChanged:nil];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QString QFileDialogPrivate::selectedNameFilter_sys() const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
int index = filterInfo.currentSelection;
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
int index = [delegate->mPopUpButton indexOfSelectedItem];
|
||||
#endif
|
||||
return index != -1 ? nameFilters.at(index) : QString();
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::deleteNativeDialog_sys()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (mDialog)
|
||||
NavDialogDispose(mDialog);
|
||||
mDialog = 0;
|
||||
mDialogStarted = false;
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
[reinterpret_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate) release];
|
||||
mDelegate = 0;
|
||||
#endif
|
||||
nativeDialogInUse = false;
|
||||
}
|
||||
|
||||
@ -734,326 +648,9 @@ bool QFileDialogPrivate::setVisible_sys(bool visible)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return visible ? showCarbonNavServicesDialog() : hideCarbonNavServicesDialog();
|
||||
#else
|
||||
return visible ? showCocoaFilePanel() : hideCocoaFilePanel();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void *info,
|
||||
void *data, NavFilterModes)
|
||||
{
|
||||
QFileDialogPrivate *fileDialogPrivate = static_cast<QFileDialogPrivate *>(data);
|
||||
|
||||
if (!fileDialogPrivate || fileDialogPrivate->filterInfo.filters.isEmpty()
|
||||
|| (fileDialogPrivate->filterInfo.currentSelection < 0
|
||||
&& fileDialogPrivate->filterInfo.currentSelection
|
||||
>= fileDialogPrivate->filterInfo.filters.size()))
|
||||
return true;
|
||||
|
||||
NavFileOrFolderInfo *theInfo = static_cast<NavFileOrFolderInfo *>(info);
|
||||
QString file;
|
||||
QString path;
|
||||
const QtMacFilterName &fn
|
||||
= fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection);
|
||||
if (theItem->descriptorType == typeFSRef) {
|
||||
FSRef ref;
|
||||
AEGetDescData(theItem, &ref, sizeof(ref));
|
||||
UInt8 str_buffer[1024];
|
||||
FSRefMakePath(&ref, str_buffer, 1024);
|
||||
path = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
|
||||
int slsh = path.lastIndexOf(QLatin1Char('/'));
|
||||
if (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) {
|
||||
QRegExp rg(*it, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
#ifdef DEBUG_FILEDIALOG_FILTERS
|
||||
qDebug("QFileDialogPrivate::qt_mac_filedialog_filter_proc:%d, asked to filter.. %s (%s)", __LINE__,
|
||||
qPrintable(file), qPrintable(*it));
|
||||
#endif
|
||||
if (rg.exactMatch(file))
|
||||
return true;
|
||||
}
|
||||
|
||||
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,
|
||||
NavCBRecPtr p, NavCallBackUserData data)
|
||||
{
|
||||
QFileDialogPrivate *fileDialogPrivate = static_cast<QFileDialogPrivate *>(data);
|
||||
|
||||
switch(msg) {
|
||||
case kNavCBPopupMenuSelect: {
|
||||
NavMenuItemSpec *s = static_cast<NavMenuItemSpec *>(p->eventData.eventDataParms.param);
|
||||
if (int(s->menuType) != fileDialogPrivate->filterInfo.currentSelection) {
|
||||
fileDialogPrivate->filterInfo.currentSelection = s->menuType;
|
||||
emit fileDialogPrivate->q_func()->filterSelected(fileDialogPrivate->nameFilters.at(s->menuType));
|
||||
}
|
||||
if (fileDialogPrivate->acceptMode == QFileDialog::AcceptSave) {
|
||||
QString base = QCFString::toQString(NavDialogGetSaveFileName(p->context));
|
||||
QFileInfo fi(base);
|
||||
base = fi.completeBaseName();
|
||||
const QtMacFilterName &fn = fileDialogPrivate->filterInfo.filters.at(
|
||||
fileDialogPrivate->filterInfo.currentSelection);
|
||||
QStringList reg = fn.regexp.split(QLatin1String(";"), QString::SkipEmptyParts);
|
||||
if (reg.count()) {
|
||||
QString r = reg.first();
|
||||
r = r.right(r.length()-1); // Strip the *
|
||||
base += r; //"." + QString::number(s->menuType);
|
||||
}
|
||||
NavDialogSetSaveFileName(p->context, QCFString::toCFStringRef(base));
|
||||
}
|
||||
#ifdef DEBUG_FILEDIALOG_FILTERS
|
||||
qDebug("QFileDialogPrivate::qt_mac_filedialog_event_proc:%d - Selected a filter: %ld", __LINE__, s->menuType);
|
||||
#endif
|
||||
break; }
|
||||
case kNavCBStart:{
|
||||
fileDialogPrivate->mDialogStarted = true;
|
||||
// Set selected file:
|
||||
QModelIndexList indexes = fileDialogPrivate->qFileDialogUi->listView->selectionModel()->selectedRows();
|
||||
QString selected;
|
||||
if (!indexes.isEmpty())
|
||||
selected = indexes.at(0).data(QFileSystemModel::FilePathRole).toString();
|
||||
else
|
||||
selected = fileDialogPrivate->typedFiles().value(0);
|
||||
fileDialogPrivate->selectFile_sys(selected);
|
||||
fileDialogPrivate->selectNameFilter_sys(fileDialogPrivate->qFileDialogUi->fileTypeCombo->currentText());
|
||||
break; }
|
||||
case kNavCBSelectEntry:{
|
||||
// Event: Current selection has changed.
|
||||
QStringList prevSelectionList = fileDialogPrivate->mCurrentSelectionList;
|
||||
fileDialogPrivate->mCurrentSelectionList.clear();
|
||||
QString fileNameToEmit;
|
||||
|
||||
AEDescList *descList = (AEDescList *)p->eventData.eventDataParms.param;
|
||||
// Get the number of files selected:
|
||||
UInt8 strBuffer[1024];
|
||||
long count;
|
||||
OSErr err = AECountItems(descList, &count);
|
||||
if (err != noErr || !count)
|
||||
break;
|
||||
|
||||
for (long index=1; index<=count; ++index) {
|
||||
FSRef ref;
|
||||
err = AEGetNthPtr(descList, index, typeFSRef, 0, 0, &ref, sizeof(ref), 0);
|
||||
if (err != noErr)
|
||||
break;
|
||||
FSRefMakePath(&ref, strBuffer, 1024);
|
||||
QString selected = QString::fromUtf8((const char *)strBuffer);
|
||||
fileDialogPrivate->mCurrentSelectionList << selected;
|
||||
if (!prevSelectionList.contains(selected))
|
||||
fileNameToEmit = selected;
|
||||
}
|
||||
|
||||
if (!fileNameToEmit.isEmpty() && fileNameToEmit != fileDialogPrivate->mCurrentSelection)
|
||||
emit fileDialogPrivate->q_func()->currentChanged(fileNameToEmit);
|
||||
fileDialogPrivate->mCurrentSelection = fileNameToEmit;
|
||||
break; }
|
||||
case kNavCBShowDesktop:
|
||||
case kNavCBNewLocation:{
|
||||
// Event: Current directory has changed.
|
||||
AEDesc *desc = (AEDesc *)p->eventData.eventDataParms.param;
|
||||
FSRef ref;
|
||||
AEGetDescData(desc, &ref, sizeof(ref));
|
||||
UInt8 *strBuffer = (UInt8 *)malloc(1024);
|
||||
FSRefMakePath(&ref, strBuffer, 1024);
|
||||
QString newLocation = QString::fromUtf8((const char *)strBuffer);
|
||||
free(strBuffer);
|
||||
if (fileDialogPrivate->mCurrentLocation != newLocation){
|
||||
fileDialogPrivate->mCurrentLocation = newLocation;
|
||||
QFileDialog::FileMode mode = fileDialogPrivate->fileMode;
|
||||
if (mode == QFileDialog::AnyFile || mode == QFileDialog::ExistingFile
|
||||
|| mode == QFileDialog::ExistingFiles){
|
||||
// When changing directory, the current selection is cleared if
|
||||
// we are supposed to be selecting files only:
|
||||
if (!fileDialogPrivate->mCurrentSelection.isEmpty()){
|
||||
fileDialogPrivate->mCurrentSelectionList.clear();
|
||||
fileDialogPrivate->mCurrentSelection.clear();
|
||||
emit fileDialogPrivate->q_func()->currentChanged(fileDialogPrivate->mCurrentSelection);
|
||||
}
|
||||
}
|
||||
fileDialogPrivate->setLastVisitedDirectory(newLocation);
|
||||
emit fileDialogPrivate->q_func()->directoryEntered(newLocation);
|
||||
}
|
||||
break; }
|
||||
case kNavCBAccept:
|
||||
fileDialogPrivate->mDialogClosed = true;
|
||||
fileDialogPrivate->q_func()->accept();
|
||||
break;
|
||||
case kNavCBCancel:
|
||||
fileDialogPrivate->mDialogClosed = true;
|
||||
fileDialogPrivate->q_func()->reject();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static QFileDialogPrivate::QtMacFilterName qt_mac_extract_filter(const QString &rawFilter, bool showDetails)
|
||||
{
|
||||
QFileDialogPrivate::QtMacFilterName ret;
|
||||
ret.filter = rawFilter;
|
||||
QString result = rawFilter;
|
||||
QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
|
||||
int index = r.indexIn(result);
|
||||
if (index >= 0)
|
||||
result = r.cap(2);
|
||||
|
||||
if (showDetails) {
|
||||
ret.description = rawFilter;
|
||||
} else {
|
||||
if (index >= 0)
|
||||
ret.description = r.cap(1).trimmed();
|
||||
if (ret.description.isEmpty())
|
||||
ret.description = result;
|
||||
}
|
||||
ret.regexp = result.replace(QLatin1Char(' '), QLatin1Char(';'));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static QList<QFileDialogPrivate::QtMacFilterName> qt_mac_make_filters_list(const QString &filter, bool showDetails)
|
||||
{
|
||||
#ifdef DEBUG_FILEDIALOG_FILTERS
|
||||
qDebug("QFileDialog:%d - Got filter (%s)", __LINE__, filter.latin1());
|
||||
#endif
|
||||
|
||||
QList<QFileDialogPrivate::QtMacFilterName> ret;
|
||||
QString f(filter);
|
||||
if (f.isEmpty())
|
||||
f = QFileDialog::tr("All Files (*)");
|
||||
if (f.isEmpty())
|
||||
return ret;
|
||||
QStringList filts = qt_make_filter_list(f);
|
||||
for (QStringList::const_iterator it = filts.constBegin(); it != filts.constEnd(); ++it) {
|
||||
QFileDialogPrivate::QtMacFilterName filter = qt_mac_extract_filter(*it, showDetails);
|
||||
#ifdef DEBUG_FILEDIALOG_FILTERS
|
||||
qDebug("QFileDialog:%d Split out filter (%d) '%s' '%s' [%s]", __LINE__, ret.count(),
|
||||
filter->regxp.latin1(), filter->description.latin1(), (*it).latin1());
|
||||
#endif
|
||||
ret.append(filter);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QFileDialogPrivate::createNavServicesDialog()
|
||||
{
|
||||
Q_Q(QFileDialog);
|
||||
if (mDialog)
|
||||
deleteNativeDialog_sys();
|
||||
|
||||
NavDialogCreationOptions navOptions;
|
||||
NavGetDefaultDialogCreationOptions(&navOptions);
|
||||
|
||||
// Translate QFileDialog settings into NavDialog options:
|
||||
if (qt_mac_is_macsheet(q)) {
|
||||
navOptions.modality = kWindowModalityWindowModal;
|
||||
navOptions.parentWindow = qt_mac_window_for(q->parentWidget());
|
||||
} else if (q->windowModality() == Qt::ApplicationModal)
|
||||
navOptions.modality = kWindowModalityAppModal;
|
||||
else
|
||||
navOptions.modality = kWindowModalityNone;
|
||||
navOptions.optionFlags |= kNavSupportPackages;
|
||||
if (q->testOption(QFileDialog::DontConfirmOverwrite))
|
||||
navOptions.optionFlags |= kNavDontConfirmReplacement;
|
||||
if (fileMode != QFileDialog::ExistingFiles)
|
||||
navOptions.optionFlags &= ~kNavAllowMultipleFiles;
|
||||
|
||||
navOptions.windowTitle = QCFString::toCFStringRef(q->windowTitle());
|
||||
|
||||
navOptions.location.h = -1;
|
||||
navOptions.location.v = -1;
|
||||
|
||||
QWidget *parent = q->parentWidget();
|
||||
if (parent && parent->isVisible()) {
|
||||
WindowClass wclass;
|
||||
GetWindowClass(qt_mac_window_for(parent), &wclass);
|
||||
parent = parent->window();
|
||||
QString s = parent->windowTitle();
|
||||
navOptions.clientName = QCFString::toCFStringRef(s);
|
||||
}
|
||||
|
||||
filterInfo.currentSelection = 0;
|
||||
filterInfo.filters = qt_mac_make_filters_list(nameFilters.join(QLatin1String(";;")), q->isNameFilterDetailsVisible());
|
||||
QCFType<CFArrayRef> filterArray;
|
||||
if (filterInfo.filters.size() > 1) {
|
||||
int i = 0;
|
||||
CFStringRef *cfstringArray = static_cast<CFStringRef *>(malloc(sizeof(CFStringRef)
|
||||
* filterInfo.filters.size()));
|
||||
for (i = 0; i < filterInfo.filters.size(); ++i) {
|
||||
cfstringArray[i] = QCFString::toCFStringRef(filterInfo.filters.at(i).description);
|
||||
}
|
||||
filterArray = CFArrayCreate(kCFAllocatorDefault,
|
||||
reinterpret_cast<const void **>(cfstringArray), filterInfo.filters.size(),
|
||||
&kCFTypeArrayCallBacks);
|
||||
navOptions.popupExtension = filterArray;
|
||||
free(cfstringArray);
|
||||
}
|
||||
|
||||
if (q->acceptMode() == QFileDialog::AcceptSave) {
|
||||
if (NavCreatePutFileDialog(&navOptions, 'cute', kNavGenericSignature,
|
||||
QFileDialogPrivate::qt_mac_filedialog_event_proc, this, &mDialog)) {
|
||||
qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
} else if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory) {
|
||||
if (NavCreateChooseFolderDialog(&navOptions,
|
||||
QFileDialogPrivate::qt_mac_filedialog_event_proc, 0, this, &mDialog)) {
|
||||
qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (NavCreateGetFileDialog(&navOptions, 0,
|
||||
QFileDialogPrivate::qt_mac_filedialog_event_proc, 0,
|
||||
QFileDialogPrivate::qt_mac_filedialog_filter_proc, this, &mDialog)) {
|
||||
qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Set start-up directory:
|
||||
if (mCurrentLocation.isEmpty())
|
||||
mCurrentLocation = rootPath();
|
||||
FSRef fsRef;
|
||||
if (qt_mac_create_fsref(mCurrentLocation, &fsRef) == noErr) {
|
||||
AEDesc desc;
|
||||
if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr)
|
||||
NavCustomControl(mDialog, kNavCtlSetLocation, (void*)&desc);
|
||||
}
|
||||
}
|
||||
|
||||
bool QFileDialogPrivate::showCarbonNavServicesDialog()
|
||||
{
|
||||
Q_Q(QFileDialog);
|
||||
if (q->acceptMode() == QFileDialog::AcceptSave && q->windowModality() == Qt::NonModal)
|
||||
return false; // cannot do native no-modal save dialogs.
|
||||
createNavServicesDialog();
|
||||
mDialogClosed = false;
|
||||
if (q->windowModality() != Qt::ApplicationModal)
|
||||
NavDialogRun(mDialog);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QFileDialogPrivate::hideCarbonNavServicesDialog()
|
||||
{
|
||||
if (!mDialogClosed){
|
||||
mDialogClosed = true;
|
||||
NavCustomControl(mDialog, kNavCtlCancel, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // Cocoa
|
||||
|
||||
void QFileDialogPrivate::createNSOpenSavePanelDelegate()
|
||||
{
|
||||
Q_Q(QFileDialog);
|
||||
@ -1105,7 +702,6 @@ bool QFileDialogPrivate::hideCocoaFilePanel()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void QFileDialogPrivate::mac_nativeDialogModalHelp()
|
||||
{
|
||||
@ -1125,29 +721,17 @@ void QFileDialogPrivate::mac_nativeDialogModalHelp()
|
||||
void QFileDialogPrivate::_q_macRunNativeAppModalPanel()
|
||||
{
|
||||
QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
NavDialogRun(mDialog);
|
||||
#else
|
||||
Q_Q(QFileDialog);
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
[delegate runApplicationModalPanel];
|
||||
dialogResultCode_sys() == QDialog::Accepted ? q->accept() : q->reject();
|
||||
#endif
|
||||
}
|
||||
|
||||
QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
NavUserAction result = NavDialogGetUserAction(mDialog);
|
||||
if (result == kNavUserActionCancel || result == kNavUserActionNone)
|
||||
return QDialog::Rejected;
|
||||
else
|
||||
return QDialog::Accepted;
|
||||
#else
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
return [delegate dialogResultCode];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,36 +279,8 @@ public:
|
||||
|
||||
#if defined(Q_WS_MAC)
|
||||
void *mDelegate;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
NavDialogRef mDialog;
|
||||
bool mDialogStarted;
|
||||
bool mDialogClosed;
|
||||
QString mCurrentLocation;
|
||||
QString mCurrentSelection;
|
||||
QStringList mCurrentSelectionList;
|
||||
|
||||
struct QtMacFilterName {
|
||||
QString description;
|
||||
QString regexp;
|
||||
QString filter;
|
||||
};
|
||||
struct QtMacNavFilterInfo {
|
||||
QtMacNavFilterInfo() : currentSelection(-1) {}
|
||||
int currentSelection;
|
||||
QList<QtMacFilterName> filters;
|
||||
} filterInfo;
|
||||
|
||||
static void qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg, NavCBRecPtr p,
|
||||
NavCallBackUserData data);
|
||||
static Boolean qt_mac_filedialog_filter_proc(AEDesc *theItem, void *info, void *data,
|
||||
NavFilterModes);
|
||||
bool showCarbonNavServicesDialog();
|
||||
bool hideCarbonNavServicesDialog();
|
||||
void createNavServicesDialog();
|
||||
#else
|
||||
bool showCocoaFilePanel();
|
||||
bool hideCocoaFilePanel();
|
||||
#endif
|
||||
void createNSOpenSavePanelDelegate();
|
||||
void QNSOpenSavePanelDelegate_selectionChanged(const QString &newPath);
|
||||
void QNSOpenSavePanelDelegate_panelClosed(bool accepted);
|
||||
|
@ -196,7 +196,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
|
||||
- (void)setSubwindowStacking
|
||||
{
|
||||
#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)) {
|
||||
@ -207,7 +206,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
@ -245,13 +243,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
|
||||
- (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];
|
||||
@ -261,9 +253,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
didEndSelector:0
|
||||
contextInfo:0 ];
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
CFRelease(hiwindowRef);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)changeFont:(id)sender
|
||||
@ -279,13 +268,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
NSDictionary *dummyAttribs = [NSDictionary dictionary];
|
||||
NSDictionary *attribs = [sender convertAttributes:dummyAttribs];
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
for (id key in attribs) {
|
||||
#else
|
||||
NSEnumerator *enumerator = [attribs keyEnumerator];
|
||||
id key;
|
||||
while((key = [enumerator nextObject])) {
|
||||
#endif
|
||||
NSNumber *number = static_cast<NSNumber *>([attribs objectForKey:key]);
|
||||
if ([key isEqual:NSUnderlineStyleAttributeName]) {
|
||||
mQtFont->setUnderline([number intValue] != NSUnderlineStyleNone);
|
||||
@ -441,14 +424,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
|
||||
- (void)finishOffWithCode:(NSInteger)code
|
||||
{
|
||||
#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]];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(code == NSOKButton)
|
||||
mPriv->sampleEdit->setFont([self qtFont]);
|
||||
@ -479,9 +460,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
||||
}
|
||||
[mFontPanel setDelegate:nil];
|
||||
[[NSFontManager sharedFontManager] setDelegate:nil];
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
[[NSFontManager sharedFontManager] setTarget:nil];
|
||||
#endif
|
||||
}
|
||||
@end
|
||||
|
||||
@ -609,9 +588,7 @@ void QFontDialogPrivate::createNSFontPanelDelegate()
|
||||
[ourPanel setDelegate:del];
|
||||
|
||||
[[NSFontManager sharedFontManager] setDelegate:del];
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
[[NSFontManager sharedFontManager] setTarget:del];
|
||||
#endif
|
||||
setFont(del, q_func()->currentFont());
|
||||
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
|
||||
|
||||
#include "qdatetime.h"
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#endif
|
||||
|
||||
@ -2306,7 +2306,7 @@ bool QApplication::event(QEvent *e)
|
||||
}
|
||||
|
||||
if(e->type() == QEvent::LanguageChange) {
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
qt_mac_post_retranslateAppMenu();
|
||||
#endif
|
||||
QWidgetList list = topLevelWidgets();
|
||||
@ -2430,7 +2430,7 @@ void QApplication::setActiveWindow(QWidget* act)
|
||||
sendSpontaneousEvent(w, &activationChange);
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
// In case the user clicked on a child window, we need to
|
||||
// reestablish the stacking order of the window so
|
||||
// it pops in front of other child windows in cocoa:
|
||||
@ -2852,7 +2852,7 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
|
||||
if (QApplication::activePopupWidget())
|
||||
return true;
|
||||
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_MAC)
|
||||
top = QApplicationPrivate::tryModalHelper_sys(top);
|
||||
if (rettop)
|
||||
*rettop = top;
|
||||
@ -4136,7 +4136,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
break;
|
||||
}
|
||||
#endif // QT_NO_GESTURES
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
case QEvent::Enter:
|
||||
if (receiver->isWidgetType()) {
|
||||
QWidget *w = static_cast<QWidget *>(receiver);
|
||||
|
@ -127,7 +127,7 @@ struct QTabletDeviceData
|
||||
int outOriginY, int outExtentY) const;
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_X11) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
|
||||
#ifdef Q_WS_X11
|
||||
QPointer<QWidget> widgetToGetPress;
|
||||
#endif
|
||||
|
||||
@ -438,10 +438,8 @@ public:
|
||||
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
|
||||
static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
|
||||
static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
static void qt_initAfterNSAppStarted();
|
||||
static void setupAppleEvents();
|
||||
#endif
|
||||
static bool qt_mac_apply_settings();
|
||||
#endif
|
||||
|
||||
|
@ -78,9 +78,7 @@ QGestureManager::QGestureManager(QObject *parent)
|
||||
#if defined(Q_WS_MAC)
|
||||
registerGestureRecognizer(new QMacSwipeGestureRecognizer);
|
||||
registerGestureRecognizer(new QMacPinchGestureRecognizer);
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
registerGestureRecognizer(new QMacPanGestureRecognizer);
|
||||
#endif
|
||||
#else
|
||||
registerGestureRecognizer(new QPanGestureRecognizer);
|
||||
registerGestureRecognizer(new QPinchGestureRecognizer);
|
||||
|
@ -132,7 +132,7 @@ Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
|
||||
#endif
|
||||
|
||||
@ -306,7 +306,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
|
||||
|
||||
isWidget = true;
|
||||
memset(high_attributes, 0, sizeof(high_attributes));
|
||||
#if QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
drawRectOriginalAdded = false;
|
||||
originalDrawMethod = true;
|
||||
changeMethods = false;
|
||||
@ -315,7 +315,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
|
||||
toolbar_ancestor = 0;
|
||||
flushRequested = false;
|
||||
touchEventsEnabled = false;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
#ifdef QWIDGET_EXTRA_DEBUG
|
||||
static int count = 0;
|
||||
qDebug() << "widgets" << ++count;
|
||||
@ -1272,7 +1272,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
|
||||
|
||||
extraPaintEngine = 0;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
// If we add a child to the unified toolbar, we have to redirect the painting.
|
||||
if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
|
||||
if (parentWidget->d_func()->unifiedSurface) {
|
||||
@ -1280,7 +1280,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
|
||||
parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
|
||||
}
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
}
|
||||
|
||||
|
||||
@ -1527,7 +1527,7 @@ QWidget::~QWidget()
|
||||
d->declarativeData = 0; // don't activate again in ~QObject
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
// QCocoaView holds a pointer back to this widget. Clear it now
|
||||
// to make sure it's not followed later on. The lifetime of the
|
||||
// QCocoaView might exceed the lifetime of this widget in cases
|
||||
@ -1613,9 +1613,7 @@ void QWidgetPrivate::createTLExtra()
|
||||
x->inRepaint = false;
|
||||
x->embedded = 0;
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
x->wasMaximized = false;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
createTLSysExtra();
|
||||
#ifdef QWIDGET_EXTRA_DEBUG
|
||||
@ -1963,10 +1961,10 @@ void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirt
|
||||
if (disableSubtractOpaqueSiblings || q->isWindow())
|
||||
return;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (q->d_func()->isInUnifiedToolbar)
|
||||
return;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
|
||||
QRect clipBoundingRect;
|
||||
bool dirtyClipBoundingRect = true;
|
||||
@ -5097,7 +5095,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
if (rgn.isEmpty())
|
||||
return;
|
||||
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
if (qt_mac_clearDirtyOnWidgetInsideDrawWidget)
|
||||
dirtyOnWidget = QRegion();
|
||||
|
||||
@ -5105,7 +5103,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
|
||||
// it's supposed to be in the unified toolbar on Mac OS X.
|
||||
if (backingStore && isInUnifiedToolbar)
|
||||
return;
|
||||
#endif // Q_WS_MAC && QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
|
||||
|
||||
Q_Q(QWidget);
|
||||
@ -6597,7 +6595,7 @@ void QWidget::setGeometry(const QRect &r)
|
||||
*/
|
||||
QByteArray QWidget::saveGeometry() const
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
// We check if the window was maximized during this invocation. If so, we need to record the
|
||||
// starting position as 0,0.
|
||||
Q_D(const QWidget);
|
||||
@ -6608,7 +6606,7 @@ QByteArray QWidget::saveGeometry() const
|
||||
newFramePosition.moveTo(0, 0);
|
||||
newNormalPosition.moveTo(0, 0);
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
QByteArray array;
|
||||
QDataStream stream(&array, QIODevice::WriteOnly);
|
||||
stream.setVersion(QDataStream::Qt_4_0);
|
||||
@ -6618,13 +6616,10 @@ QByteArray QWidget::saveGeometry() const
|
||||
stream << magicNumber
|
||||
<< majorVersion
|
||||
<< minorVersion
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
<< newFramePosition
|
||||
<< newNormalPosition
|
||||
#else
|
||||
<< frameGeometry()
|
||||
<< normalGeometry()
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
<< qint32(QApplication::desktop()->screenNumber(this))
|
||||
<< quint8(windowState() & Qt::WindowMaximized)
|
||||
<< quint8(windowState() & Qt::WindowFullScreen);
|
||||
@ -7452,7 +7447,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
|
||||
QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
|
||||
if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
|
||||
continue;
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
// Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
|
||||
// When hiding a widget we need to make sure that no mouse_down events are active, because
|
||||
// the mouse_up event will never be received by a hidden widget or one of its descendants.
|
||||
@ -7468,7 +7463,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
|
||||
// supposed to trigger because it is not visible.
|
||||
if(widget == qt_button_down)
|
||||
qt_button_down = 0;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
if (spontaneous)
|
||||
widget->setAttribute(Qt::WA_Mapped, false);
|
||||
else
|
||||
@ -9700,11 +9695,11 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
|
||||
if (newParent && parent && !desktopWidget) {
|
||||
if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
// On Mac, toolbars inside the unified title bar will never overlap with
|
||||
// siblings in the content view. So we skip enforce native siblings in that case
|
||||
&& !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
|
||||
#endif // Q_WS_MAC && QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
)
|
||||
parent->d_func()->enforceNativeChildren();
|
||||
else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
|
||||
@ -9966,12 +9961,12 @@ void QWidget::repaint(const QRect &rect)
|
||||
return;
|
||||
|
||||
if (hasBackingStoreSupport()) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (qt_widget_private(this)->isInUnifiedToolbar) {
|
||||
qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
|
||||
return;
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
|
||||
tlwExtra->inRepaint = true;
|
||||
@ -10001,12 +9996,12 @@ void QWidget::repaint(const QRegion &rgn)
|
||||
return;
|
||||
|
||||
if (hasBackingStoreSupport()) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (qt_widget_private(this)->isInUnifiedToolbar) {
|
||||
qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
|
||||
return;
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
|
||||
tlwExtra->inRepaint = true;
|
||||
@ -10064,12 +10059,12 @@ void QWidget::update(const QRect &rect)
|
||||
}
|
||||
|
||||
if (hasBackingStoreSupport()) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (qt_widget_private(this)->isInUnifiedToolbar) {
|
||||
qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
|
||||
return;
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
|
||||
tlwExtra->backingStoreTracker->markDirty(rect, this);
|
||||
@ -10094,12 +10089,12 @@ void QWidget::update(const QRegion &rgn)
|
||||
}
|
||||
|
||||
if (hasBackingStoreSupport()) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
if (qt_widget_private(this)->isInUnifiedToolbar) {
|
||||
qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
|
||||
return;
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
|
||||
tlwExtra->backingStoreTracker->markDirty(rgn, this);
|
||||
@ -10274,11 +10269,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
|
||||
qApp->inputPanel()->setInputItem(0);
|
||||
}
|
||||
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#ifdef Q_WS_MAC
|
||||
// On Mac, toolbars inside the unified title bar will never overlap with
|
||||
// siblings in the content view. So we skip enforce native siblings in that case
|
||||
&& !d->isInUnifiedToolbar && parentWidget()->isWindow()
|
||||
#endif // Q_WS_MAC && QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
)
|
||||
parentWidget()->d_func()->enforceNativeChildren();
|
||||
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
|
||||
@ -11997,7 +11992,7 @@ void QWidget::setMask(const QRegion &newMask)
|
||||
d->extra->mask = newMask;
|
||||
d->extra->hasMask = !newMask.isEmpty();
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef Q_WS_MAC
|
||||
if (!testAttribute(Qt::WA_WState_Created))
|
||||
return;
|
||||
#endif
|
||||
@ -12100,7 +12095,7 @@ void QWidgetPrivate::_q_delayedDestroy(WId winId)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if QT_MAC_USE_COCOA
|
||||
#ifdef Q_WS_MAC
|
||||
void QWidgetPrivate::syncUnifiedMode() {
|
||||
// The whole purpose of this method is to keep the unifiedToolbar in sync.
|
||||
// That means making sure we either exchange the drawing methods or we let
|
||||
@ -12120,7 +12115,7 @@ void QWidgetPrivate::syncUnifiedMode() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -218,13 +218,11 @@ struct QTLWExtra {
|
||||
WindowGroupRef group;
|
||||
IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
|
||||
quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
|
||||
// manually resized.
|
||||
// The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
|
||||
// starting position as 0,0 instead of the normal starting position.
|
||||
bool wasMaximized;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
|
||||
#ifndef QT_NO_QWS_MANAGER
|
||||
@ -285,11 +283,9 @@ struct QWExtra {
|
||||
uint compress_events : 1;
|
||||
WId xDndProxy; // XDND forwarding to embedded windows
|
||||
#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// Cocoa Mask stuff
|
||||
QImage maskBits;
|
||||
CGImageRef imageMask;
|
||||
#endif
|
||||
#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
|
||||
uint activated : 1; // RWindowBase::Activated has been called
|
||||
|
||||
@ -844,10 +840,6 @@ public:
|
||||
void setWindowFilePath_sys(const QString &filePath);
|
||||
void createWindow_sys();
|
||||
void recreateMacWindow();
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
void initWindowPtr();
|
||||
void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
|
||||
#else
|
||||
void setSubWindowStacking(bool set);
|
||||
void setWindowLevel();
|
||||
void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
|
||||
@ -868,7 +860,6 @@ public:
|
||||
QWidget *toolbar_ancestor;
|
||||
bool flushRequested;
|
||||
bool touchEventsEnabled;
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
void determineWindowClass();
|
||||
void transferChildren();
|
||||
bool qt_mac_dnd_event(uint, DragRef);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -388,7 +388,6 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// QMimeData sub classes reimplementing the formats() might not expose the
|
||||
// temporary "application/x-qt-mime-type-name" mimetype. So check the existence
|
||||
// of this mime type while doing drag and drop.
|
||||
@ -399,7 +398,6 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
|
||||
formats.append(dummyMimeType);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for(int f = 0; f < formats.size(); ++f) {
|
||||
QString mimeType = formats.at(f);
|
||||
for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
|
||||
|
@ -79,9 +79,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
|
||||
#endif
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
// The following code replaces the _implementation_ for the selector we want to hack
|
||||
@ -110,9 +107,6 @@ void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class prox
|
||||
|
||||
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
|
||||
#endif
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
||||
|
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <private/qcocoapanel_mac_p.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <private/qt_cocoa_helpers_mac_p.h>
|
||||
#import <private/qcocoawindow_mac_p.h>
|
||||
#import <private/qcocoawindowdelegate_mac_p.h>
|
||||
@ -67,4 +66,3 @@ QT_USE_NAMESPACE
|
||||
#include "qcocoasharedwindowmethods_mac_p.h"
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
@ -54,7 +54,6 @@
|
||||
#define QCOCOAPANEL_MAC_P
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||
@ -78,6 +77,5 @@ QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
|
||||
- (void)drawRectOriginal:(NSRect)rect;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <private/qcocoaview_mac_p.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qt_mac_p.h>
|
||||
@ -1385,4 +1384,3 @@ Qt::DropAction QDragManager::drag(QDrag *o)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
@ -51,7 +51,6 @@
|
||||
//
|
||||
|
||||
#include <qevent.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class QT_MANGLE_NAMESPACE(QCocoaView);
|
||||
@ -84,4 +83,3 @@ Q_WIDGETS_EXPORT
|
||||
- (void) qt_clearQWidget;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <private/qcocoawindow_mac_p.h>
|
||||
#import <private/qcocoawindowdelegate_mac_p.h>
|
||||
#import <private/qcocoaview_mac_p.h>
|
||||
@ -87,4 +86,3 @@ QT_USE_NAMESPACE
|
||||
#include "qcocoasharedwindowmethods_mac_p.h"
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
@ -53,7 +53,6 @@
|
||||
#ifndef QCOCOAWINDOW_MAC_P
|
||||
#define QCOCOAWINDOW_MAC_P
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#include "qmacdefines_mac.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <private/qapplication_p.h>
|
||||
@ -92,6 +91,5 @@ QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
|
||||
- (void)drawRectOriginal:(NSRect)rect;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
#import "private/qcocoawindowcustomthemeframe_mac_p.h"
|
||||
#import "private/qcocoawindow_mac_p.h"
|
||||
@ -59,4 +58,3 @@
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import "private/qcocoawindowdelegate_mac_p.h"
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
@ -436,4 +435,3 @@ static void cleanupCocoaWindowDelegate()
|
||||
}
|
||||
|
||||
@end
|
||||
#endif// QT_MAC_USE_COCOA
|
||||
|
@ -52,7 +52,6 @@
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -107,4 +106,3 @@ QT_FORWARD_DECLARE_CLASS(QWidgetData)
|
||||
- (QWidget *)qt_qwidgetForWindow:(NSWindow *)window;
|
||||
- (void)syncContentViewFrame: (NSNotification *)notification;
|
||||
@end
|
||||
#endif
|
||||
|
@ -107,33 +107,8 @@ static QCursorData *currentCursor = 0; //current cursor
|
||||
|
||||
void qt_mac_set_cursor(const QCursor *c)
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
[static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*c)) set];
|
||||
#else
|
||||
if (!c) {
|
||||
currentCursor = 0;
|
||||
return;
|
||||
}
|
||||
c->handle(); //force the cursor to get loaded, if it's not
|
||||
|
||||
if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor
|
||||
&& currentCursor->curs.tc.anim)
|
||||
currentCursor->curs.tc.anim->stop();
|
||||
if(c->d->type == QCursorData::TYPE_ImageCursor) {
|
||||
[static_cast<NSCursor *>(c->d->curs.cp.nscursor) set];
|
||||
} else if(c->d->type == QCursorData::TYPE_ThemeCursor) {
|
||||
if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) {
|
||||
SetThemeCursor(c->d->curs.tc.curs);
|
||||
} else {
|
||||
if(!c->d->curs.tc.anim)
|
||||
c->d->curs.tc.anim = new QMacAnimateCursor;
|
||||
c->d->curs.tc.anim->start(c->d->curs.tc.curs);
|
||||
}
|
||||
}
|
||||
|
||||
currentCursor = c->d;
|
||||
#endif
|
||||
}
|
||||
|
||||
static QPointer<QWidget> lastWidgetUnderMouse = 0;
|
||||
@ -186,16 +161,12 @@ void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
cursor.d->update();
|
||||
NSCursor *nsCursor = static_cast<NSCursor *>(cursor.d->curs.cp.nscursor);
|
||||
if ([NSCursor currentCursor] != nsCursor) {
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
[nsCursor set];
|
||||
}
|
||||
#else
|
||||
qt_mac_set_cursor(&cursor);
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_mac_update_cursor()
|
||||
@ -206,7 +177,6 @@ void qt_mac_update_cursor()
|
||||
// application has been deactivated/activated etc.
|
||||
// NB: since we dont have any true native widget, the call to
|
||||
// qt_mac_getTargetForMouseEvent will fail when the mouse is over QMacNativeWidgets.
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
lastWidgetUnderMouse = 0;
|
||||
lastMouseCursorWidget = 0;
|
||||
QWidget *widgetUnderMouse = 0;
|
||||
@ -219,9 +189,6 @@ void qt_mac_update_cursor()
|
||||
qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, 0, &widgetUnderMouse);
|
||||
}
|
||||
qt_mac_updateCursorWithWidgetUnderMouse(widgetUnderMouse);
|
||||
#else
|
||||
qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(QCursor::pos()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_mac_setMouseGrabCursor(bool set, QCursor *const cursor = 0)
|
||||
@ -241,12 +208,6 @@ void qt_mac_setMouseGrabCursor(bool set, QCursor *const cursor = 0)
|
||||
qt_mac_update_cursor();
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
|
||||
{
|
||||
qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(globalPos));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int nextCursorId = Qt::BitmapCursor;
|
||||
|
||||
@ -314,7 +275,6 @@ QPoint QCursor::pos()
|
||||
|
||||
void QCursor::setPos(int x, int y)
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
CGPoint pos;
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
@ -322,24 +282,6 @@ void QCursor::setPos(int x, int y)
|
||||
CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
|
||||
CGEventPost(kCGHIDEventTap, e);
|
||||
CFRelease(e);
|
||||
#else
|
||||
CGWarpMouseCursorPosition(CGPointMake(x, y));
|
||||
|
||||
/* I'm not too keen on doing this, but this makes it a lot easier, so I just
|
||||
send the event back through the event system and let it get propagated correctly
|
||||
ideally this would not really need to be faked --Sam
|
||||
*/
|
||||
QWidget *widget = 0;
|
||||
if(QWidget *grb = QWidget::mouseGrabber())
|
||||
widget = grb;
|
||||
else
|
||||
widget = QApplication::widgetAt(QPoint(x, y));
|
||||
if(widget) {
|
||||
QMouseEvent me(QMouseEvent::MouseMove, widget->mapFromGlobal(QPoint(x, y)), Qt::NoButton,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
qt_sendSpontaneousEvent(widget, &me);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QCursorData::initCursorFromBitmap()
|
||||
@ -453,7 +395,6 @@ void QCursorData::update()
|
||||
#endif
|
||||
const uchar *cursorData = 0;
|
||||
const uchar *cursorMaskData = 0;
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
switch (cshape) { // map Q cursor to MAC cursor
|
||||
case Qt::BitmapCursor: {
|
||||
if (pixmap.isNull())
|
||||
@ -561,114 +502,6 @@ void QCursorData::update()
|
||||
qWarning("Qt: QCursor::update: Invalid cursor shape %d", cshape);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// Carbon
|
||||
switch (cshape) { // map Q cursor to MAC cursor
|
||||
case Qt::BitmapCursor: {
|
||||
if (pixmap.isNull())
|
||||
initCursorFromBitmap();
|
||||
else
|
||||
initCursorFromPixmap();
|
||||
break; }
|
||||
case Qt::BlankCursor: {
|
||||
pixmap = QPixmap(16, 16);
|
||||
pixmap.fill(Qt::transparent);
|
||||
initCursorFromPixmap();
|
||||
break; }
|
||||
case Qt::ArrowCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeArrowCursor;
|
||||
break; }
|
||||
case Qt::CrossCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeCrossCursor;
|
||||
break; }
|
||||
case Qt::WaitCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeWatchCursor;
|
||||
break; }
|
||||
case Qt::IBeamCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeIBeamCursor;
|
||||
break; }
|
||||
case Qt::SizeAllCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemePlusCursor;
|
||||
break; }
|
||||
case Qt::WhatsThisCursor: { //for now just use the pointing hand
|
||||
case Qt::PointingHandCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemePointingHandCursor;
|
||||
break; }
|
||||
case Qt::BusyCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeSpinningCursor;
|
||||
break; }
|
||||
case Qt::SplitVCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeResizeUpDownCursor;
|
||||
break; }
|
||||
case Qt::SplitHCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeResizeLeftRightCursor;
|
||||
break; }
|
||||
case Qt::ForbiddenCursor: {
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeNotAllowedCursor;
|
||||
break; }
|
||||
case Qt::OpenHandCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeOpenHandCursor;
|
||||
break;
|
||||
case Qt::ClosedHandCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeClosedHandCursor;
|
||||
break;
|
||||
case Qt::DragMoveCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeArrowCursor;
|
||||
break;
|
||||
case Qt::DragCopyCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeCopyArrowCursor;
|
||||
break;
|
||||
case Qt::DragLinkCursor:
|
||||
type = QCursorData::TYPE_ThemeCursor;
|
||||
curs.tc.curs = kThemeAliasArrowCursor;
|
||||
break;
|
||||
#define QT_USE_APPROXIMATE_CURSORS
|
||||
#ifdef QT_USE_APPROXIMATE_CURSORS
|
||||
case Qt::SizeVerCursor:
|
||||
cursorData = cur_ver_bits;
|
||||
cursorMaskData = mcur_ver_bits;
|
||||
hx = hy = 8;
|
||||
break;
|
||||
case Qt::SizeHorCursor:
|
||||
cursorData = cur_hor_bits;
|
||||
cursorMaskData = mcur_hor_bits;
|
||||
hx = hy = 8;
|
||||
break;
|
||||
case Qt::SizeBDiagCursor:
|
||||
cursorData = cur_fdiag_bits;
|
||||
cursorMaskData = mcur_fdiag_bits;
|
||||
hx = hy = 8;
|
||||
break;
|
||||
case Qt::SizeFDiagCursor:
|
||||
cursorData = cur_bdiag_bits;
|
||||
cursorMaskData = mcur_bdiag_bits;
|
||||
hx = hy = 8;
|
||||
break;
|
||||
case Qt::UpArrowCursor:
|
||||
cursorData = cur_up_arrow_bits;
|
||||
cursorMaskData = mcur_up_arrow_bits;
|
||||
hx = 8;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
qWarning("Qt: QCursor::update: Invalid cursor shape %d", cshape);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cursorData) {
|
||||
bm = new QBitmap(QBitmap::fromData(QSize(16, 16), cursorData,
|
||||
|
@ -76,9 +76,6 @@ QMacDndAnswerRecord qt_mac_dnd_answer_rec;
|
||||
QDnD globals
|
||||
*****************************************************************************/
|
||||
bool qt_mac_in_drag = false;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static DragReference qt_mac_current_dragRef = 0;
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
Externals
|
||||
@ -91,27 +88,6 @@ extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp
|
||||
QDnD utility functions
|
||||
*****************************************************************************/
|
||||
|
||||
//default pixmap
|
||||
static const int default_pm_hotx = -2;
|
||||
static const int default_pm_hoty = -16;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static const char * const default_pm[] = {
|
||||
"13 9 3 1",
|
||||
". c None",
|
||||
" c #000000",
|
||||
"X c #FFFFFF",
|
||||
"X X X X X X X",
|
||||
" X X X X X X ",
|
||||
"X ......... X",
|
||||
" X.........X ",
|
||||
"X ......... X",
|
||||
" X.........X ",
|
||||
"X ......... X",
|
||||
" X X X X X X ",
|
||||
"X X X X X X X",
|
||||
};
|
||||
#endif
|
||||
|
||||
//action management
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
# define MAP_MAC_ENUM(x) x, #x
|
||||
@ -126,134 +102,26 @@ struct mac_enum_mapper
|
||||
char *qt_desc;
|
||||
#endif
|
||||
};
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static mac_enum_mapper dnd_action_symbols[] = {
|
||||
{ kDragActionAlias, MAP_MAC_ENUM(Qt::LinkAction) },
|
||||
{ kDragActionMove, MAP_MAC_ENUM(Qt::MoveAction) },
|
||||
{ kDragActionGeneric, MAP_MAC_ENUM(Qt::CopyAction) },
|
||||
{ kDragActionCopy, MAP_MAC_ENUM(Qt::CopyAction) },
|
||||
{ 0, MAP_MAC_ENUM(0) }
|
||||
};
|
||||
static DragActions qt_mac_dnd_map_qt_actions(Qt::DropActions qActions)
|
||||
{
|
||||
DragActions ret = kDragActionNothing;
|
||||
for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
|
||||
if(qActions & dnd_action_symbols[i].qt_code)
|
||||
ret |= dnd_action_symbols[i].mac_code;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static Qt::DropActions qt_mac_dnd_map_mac_actions(DragActions macActions)
|
||||
{
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
qDebug("Converting DND ActionList: 0x%lx", macActions);
|
||||
#endif
|
||||
Qt::DropActions ret = Qt::IgnoreAction;
|
||||
for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
qDebug(" %d) [%s] : %s", i, dnd_action_symbols[i].qt_desc,
|
||||
(macActions & dnd_action_symbols[i].mac_code) ? "true" : "false");
|
||||
#endif
|
||||
if(macActions & dnd_action_symbols[i].mac_code)
|
||||
ret |= Qt::DropAction(dnd_action_symbols[i].qt_code);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static Qt::DropAction qt_mac_dnd_map_mac_default_action(DragActions macActions)
|
||||
{
|
||||
static Qt::DropAction preferred_actions[] = { Qt::CopyAction, Qt::LinkAction, //in order
|
||||
Qt::MoveAction, Qt::IgnoreAction };
|
||||
Qt::DropAction ret = Qt::IgnoreAction;
|
||||
const Qt::DropActions qtActions = qt_mac_dnd_map_mac_actions(macActions);
|
||||
for(int i = 0; preferred_actions[i] != Qt::IgnoreAction; ++i) {
|
||||
if(qtActions & preferred_actions[i]) {
|
||||
ret = preferred_actions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
|
||||
if(dnd_action_symbols[i].qt_code == ret) {
|
||||
qDebug("Got default action: %s [0x%lx]", dnd_action_symbols[i].qt_desc, macActions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
static void qt_mac_dnd_update_action(DragReference dragRef) {
|
||||
SInt16 modifiers;
|
||||
GetDragModifiers(dragRef, &modifiers, 0, 0);
|
||||
qt_mac_send_modifiers_changed(modifiers, qApp);
|
||||
|
||||
Qt::DropAction qtAction = Qt::IgnoreAction;
|
||||
{
|
||||
DragActions macAllowed = kDragActionNothing;
|
||||
GetDragDropAction(dragRef, &macAllowed);
|
||||
Qt::DropActions qtAllowed = qt_mac_dnd_map_mac_actions(macAllowed);
|
||||
qtAction = QDragManager::self()->defaultAction(qtAllowed, QApplication::keyboardModifiers());
|
||||
#if 1
|
||||
if(!(qtAllowed & qtAction))
|
||||
qtAction = qt_mac_dnd_map_mac_default_action(macAllowed);
|
||||
#endif
|
||||
}
|
||||
DragActions macAction = qt_mac_dnd_map_qt_actions(qtAction);
|
||||
|
||||
DragActions currentActions;
|
||||
GetDragDropAction(dragRef, ¤tActions);
|
||||
if(currentActions != macAction) {
|
||||
SetDragDropAction(dragRef, macAction);
|
||||
QDragManager::self()->emitActionChanged(qtAction);
|
||||
}
|
||||
}
|
||||
#endif // !QT_MAC_USE_COCOA
|
||||
|
||||
/*****************************************************************************
|
||||
DnD functions
|
||||
*****************************************************************************/
|
||||
bool QDropData::hasFormat_sys(const QString &mime) const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
OSPasteboardRef board;
|
||||
if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return false;
|
||||
}
|
||||
return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).hasFormat(mime);
|
||||
#else
|
||||
Q_UNUSED(mime);
|
||||
return false;
|
||||
#endif // !QT_MAC_USE_COCOA
|
||||
}
|
||||
|
||||
QVariant QDropData::retrieveData_sys(const QString &mime, QVariant::Type type) const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
OSPasteboardRef board;
|
||||
if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return QVariant();
|
||||
}
|
||||
return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).retrieveData(mime, type);
|
||||
#else
|
||||
Q_UNUSED(mime);
|
||||
Q_UNUSED(type);
|
||||
return QVariant();
|
||||
#endif // !QT_MAC_USE_COCOA
|
||||
}
|
||||
|
||||
QStringList QDropData::formats_sys() const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
OSPasteboardRef board;
|
||||
if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return QStringList();
|
||||
}
|
||||
return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).formats();
|
||||
#else
|
||||
return QStringList();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QDragManager::timerEvent(QTimerEvent*)
|
||||
@ -295,18 +163,8 @@ void QDragManager::drop()
|
||||
*/
|
||||
static inline bool qt_mac_set_existing_drop_action(const DragRef &dragRef, QDropEvent &event)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
DragActions currentAction = kDragActionNothing;
|
||||
OSStatus err = GetDragDropAction(dragRef, ¤tAction);
|
||||
if (err == noErr && currentAction != kDragActionNothing) {
|
||||
// This looks a bit evil, but we only ever set one action, so it's OK.
|
||||
event.setDropAction(Qt::DropAction(int(qt_mac_dnd_map_mac_actions(currentAction))));
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(dragRef);
|
||||
Q_UNUSED(event);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -338,361 +196,11 @@ bool qt_mac_mouse_inside_answer_rect(QPoint mouse)
|
||||
|
||||
bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_Q(QWidget);
|
||||
qt_mac_current_dragRef = dragRef;
|
||||
if (kind != kEventControlDragLeave)
|
||||
qt_mac_dnd_update_action(dragRef);
|
||||
|
||||
Point mouse;
|
||||
GetDragMouse(dragRef, &mouse, 0L);
|
||||
if(!mouse.h && !mouse.v)
|
||||
GetGlobalMouse(&mouse);
|
||||
|
||||
if(QApplicationPrivate::modalState()) {
|
||||
for(QWidget *modal = q; modal; modal = modal->parentWidget()) {
|
||||
if(modal->isWindow()) {
|
||||
if(modal != QApplication::activeModalWidget())
|
||||
return noErr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//lookup the possible actions
|
||||
DragActions allowed = kDragActionNothing;
|
||||
GetDragAllowableActions(dragRef, &allowed);
|
||||
Qt::DropActions qtAllowed = qt_mac_dnd_map_mac_actions(allowed);
|
||||
|
||||
//lookup the source dragAccepted
|
||||
QMimeData *dropdata = QDragManager::self()->dropData;
|
||||
if(QDragManager::self()->source())
|
||||
dropdata = QDragManager::self()->dragPrivate()->data;
|
||||
|
||||
// 'interrestedInDrag' should end up being 'true' if a later drop
|
||||
// will be accepted by the widget for the current mouse position
|
||||
bool interrestedInDrag = true;
|
||||
|
||||
//Dispatch events
|
||||
if (kind == kEventControlDragWithin) {
|
||||
if (qt_mac_mouse_inside_answer_rect(q->mapFromGlobal(QPoint(mouse.h, mouse.v))))
|
||||
return qt_mac_dnd_answer_rec.lastAction == Qt::IgnoreAction;
|
||||
else
|
||||
qt_mac_dnd_answer_rec.clear();
|
||||
|
||||
QDragMoveEvent qDMEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
|
||||
// Accept the event by default if a
|
||||
// drag action exists on the carbon event
|
||||
if (qt_mac_set_existing_drop_action(dragRef, qDMEvent))
|
||||
qDMEvent.accept();
|
||||
|
||||
QApplication::sendEvent(q, &qDMEvent);
|
||||
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction)
|
||||
interrestedInDrag = false;
|
||||
|
||||
qt_mac_copy_answer_rect(qDMEvent);
|
||||
SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDMEvent.dropAction()));
|
||||
|
||||
} else if (kind == kEventControlDragEnter) {
|
||||
qt_mac_dnd_answer_rec.clear();
|
||||
|
||||
QDragEnterEvent qDEEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
qt_mac_set_existing_drop_action(dragRef, qDEEvent);
|
||||
QApplication::sendEvent(q, &qDEEvent);
|
||||
SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDEEvent.dropAction()));
|
||||
|
||||
if (!qDEEvent.isAccepted())
|
||||
// The widget is simply not interested in this
|
||||
// drag. So tell carbon this by returning 'false'. We will then
|
||||
// not receive any further move, drop or leave events for this widget.
|
||||
return false;
|
||||
else {
|
||||
// Documentation states that a drag move event is sent immediately after
|
||||
// a drag enter event. So we do that. This will honor widgets overriding
|
||||
// 'dragMoveEvent' only, and not 'dragEnterEvent'
|
||||
QDragMoveEvent qDMEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
qDMEvent.accept(); // accept by default, since enter event was accepted.
|
||||
qDMEvent.setDropAction(qDEEvent.dropAction());
|
||||
QApplication::sendEvent(q, &qDMEvent);
|
||||
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction)
|
||||
interrestedInDrag = false;
|
||||
|
||||
qt_mac_copy_answer_rect(qDMEvent);
|
||||
SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDMEvent.dropAction()));
|
||||
}
|
||||
|
||||
} else if(kind == kEventControlDragLeave) {
|
||||
QDragLeaveEvent de;
|
||||
QApplication::sendEvent(q, &de);
|
||||
} else if(kind == kEventControlDragReceive) {
|
||||
QDropEvent de(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
if(QDragManager::self()->object)
|
||||
QDragManager::self()->dragPrivate()->target = q;
|
||||
QApplication::sendEvent(q, &de);
|
||||
if(!de.isAccepted()) {
|
||||
interrestedInDrag = false;
|
||||
SetDragDropAction(dragRef, kDragActionNothing);
|
||||
} else {
|
||||
if(QDragManager::self()->object)
|
||||
QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
|
||||
SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(de.dropAction()));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
{
|
||||
const char *desc = 0;
|
||||
switch(kind) {
|
||||
case kEventControlDragWithin: desc = "DragMove"; break;
|
||||
case kEventControlDragEnter: desc = "DragEnter"; break;
|
||||
case kEventControlDragLeave: desc = "DragLeave"; break;
|
||||
case kEventControlDragReceive: desc = "DragDrop"; break;
|
||||
}
|
||||
if(desc) {
|
||||
QPoint pos(q->mapFromGlobal(QPoint(mouse.h, mouse.v)));
|
||||
qDebug("Sending <%s>(%d, %d) event to %p(%s::%s) [%d] (%p)",
|
||||
desc, pos.x(), pos.y(), q, q->metaObject()->className(),
|
||||
q->objectName().toLocal8Bit().constData(), ret, dragRef);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//set the cursor
|
||||
bool found_cursor = false;
|
||||
if(kind == kEventControlDragWithin || kind == kEventControlDragEnter) {
|
||||
ThemeCursor cursor = kThemeNotAllowedCursor;
|
||||
found_cursor = true;
|
||||
if (interrestedInDrag) {
|
||||
DragActions action = kDragActionNothing;
|
||||
GetDragDropAction(dragRef, &action);
|
||||
switch(qt_mac_dnd_map_mac_default_action(action)) {
|
||||
case Qt::IgnoreAction:
|
||||
cursor = kThemeNotAllowedCursor;
|
||||
break;
|
||||
case Qt::MoveAction:
|
||||
cursor = kThemeArrowCursor;
|
||||
break;
|
||||
case Qt::CopyAction:
|
||||
cursor = kThemeCopyArrowCursor;
|
||||
break;
|
||||
case Qt::LinkAction:
|
||||
cursor = kThemeAliasArrowCursor;
|
||||
break;
|
||||
default:
|
||||
cursor = kThemeNotAllowedCursor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetThemeCursor(cursor);
|
||||
}
|
||||
if(found_cursor) {
|
||||
qt_mac_set_cursor(0); //just use our's
|
||||
} else {
|
||||
QCursor cursor(Qt::ArrowCursor);
|
||||
if(qApp && qApp->overrideCursor()) {
|
||||
cursor = *qApp->overrideCursor();
|
||||
} else if(q) {
|
||||
for(QWidget *p = q; p; p = p->parentWidget()) {
|
||||
if(p->isEnabled() && p->testAttribute(Qt::WA_SetCursor)) {
|
||||
cursor = p->cursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
qt_mac_set_cursor(&cursor);
|
||||
}
|
||||
|
||||
//idle things
|
||||
if(qGlobalPostedEventsCount()) {
|
||||
QApplication::sendPostedEvents();
|
||||
QApplication::flush();
|
||||
}
|
||||
|
||||
// If this was not a drop, tell carbon that we will be interresed in receiving more
|
||||
// events for the current drag. We do that by returning true.
|
||||
if (kind == kEventControlDragReceive)
|
||||
return interrestedInDrag;
|
||||
else
|
||||
return true;
|
||||
#else
|
||||
Q_UNUSED(kind);
|
||||
Q_UNUSED(dragRef);
|
||||
return false;
|
||||
#endif // !QT_MAC_USE_COCOA
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Qt::DropAction QDragManager::drag(QDrag *o)
|
||||
{
|
||||
|
||||
if(qt_mac_in_drag) { //just make sure..
|
||||
qWarning("Qt: Internal error: WH0A, unexpected condition reached");
|
||||
return Qt::IgnoreAction;
|
||||
}
|
||||
if(object == o)
|
||||
return Qt::IgnoreAction;
|
||||
/* At the moment it seems clear that Mac OS X does not want to drag with a non-left button
|
||||
so we just bail early to prevent it */
|
||||
if(!(GetCurrentEventButtonState() & kEventMouseButtonPrimary))
|
||||
return Qt::IgnoreAction;
|
||||
|
||||
if(object) {
|
||||
dragPrivate()->source->removeEventFilter(this);
|
||||
cancel();
|
||||
beingCancelled = false;
|
||||
}
|
||||
|
||||
object = o;
|
||||
dragPrivate()->target = 0;
|
||||
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
QAccessible::updateAccessibility(this, 0, QAccessible::DragDropStart);
|
||||
#endif
|
||||
|
||||
//setup the data
|
||||
QMacPasteboard dragBoard(QMacPasteboardMime::MIME_DND);
|
||||
dragBoard.setMimeData(dragPrivate()->data);
|
||||
|
||||
//create the drag
|
||||
OSErr result;
|
||||
DragRef dragRef;
|
||||
if((result = NewDragWithPasteboard(dragBoard.pasteBoard(), &dragRef)))
|
||||
return Qt::IgnoreAction;
|
||||
//setup the actions
|
||||
DragActions possibleActions = qt_mac_dnd_map_qt_actions(dragPrivate()->possible_actions);
|
||||
SetDragAllowableActions(dragRef, //local
|
||||
possibleActions,
|
||||
true);
|
||||
SetDragAllowableActions(dragRef, //remote (same as local)
|
||||
possibleActions,
|
||||
false);
|
||||
|
||||
|
||||
QPoint hotspot;
|
||||
QPixmap pix = dragPrivate()->pixmap;
|
||||
if(pix.isNull()) {
|
||||
if(dragPrivate()->data->hasText() || dragPrivate()->data->hasUrls()) {
|
||||
//get the string
|
||||
QString s = dragPrivate()->data->hasText() ? dragPrivate()->data->text()
|
||||
: dragPrivate()->data->urls().first().toString();
|
||||
if(s.length() > 26)
|
||||
s = s.left(23) + QChar(0x2026);
|
||||
if(!s.isEmpty()) {
|
||||
//draw it
|
||||
QFont f(qApp->font());
|
||||
f.setPointSize(12);
|
||||
QFontMetrics fm(f);
|
||||
const int width = fm.width(s);
|
||||
const int height = fm.height();
|
||||
if(width > 0 && height > 0) {
|
||||
QPixmap tmp(width, height);
|
||||
QPainter p(&tmp);
|
||||
p.fillRect(0, 0, tmp.width(), tmp.height(), Qt::color0);
|
||||
p.setPen(Qt::color1);
|
||||
p.setFont(f);
|
||||
p.drawText(0, fm.ascent(), s);
|
||||
p.end();
|
||||
//save it
|
||||
pix = tmp;
|
||||
hotspot = QPoint(tmp.width() / 2, tmp.height() / 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pix = QPixmap(default_pm);
|
||||
hotspot = QPoint(default_pm_hotx, default_pm_hoty);
|
||||
}
|
||||
} else {
|
||||
hotspot = dragPrivate()->hotspot;
|
||||
}
|
||||
|
||||
//so we must fake an event
|
||||
EventRecord fakeEvent;
|
||||
GetGlobalMouse(&(fakeEvent.where));
|
||||
fakeEvent.message = 0;
|
||||
fakeEvent.what = mouseDown;
|
||||
fakeEvent.when = EventTimeToTicks(GetCurrentEventTime());
|
||||
fakeEvent.modifiers = GetCurrentKeyModifiers();
|
||||
if(GetCurrentEventButtonState() & 2)
|
||||
fakeEvent.modifiers |= controlKey;
|
||||
|
||||
//find the hotspot in relation to the pixmap
|
||||
Point boundsPoint;
|
||||
boundsPoint.h = fakeEvent.where.h - hotspot.x();
|
||||
boundsPoint.v = fakeEvent.where.v - hotspot.y();
|
||||
Rect boundsRect;
|
||||
SetRect(&boundsRect, boundsPoint.h, boundsPoint.v, boundsPoint.h + pix.width(), boundsPoint.v + pix.height());
|
||||
|
||||
//set the drag image
|
||||
QRegion dragRegion(boundsPoint.h, boundsPoint.v, pix.width(), pix.height()), pixRegion;
|
||||
if(!pix.isNull()) {
|
||||
HIPoint hipoint = { -hotspot.x(), -hotspot.y() };
|
||||
CGImageRef img = (CGImageRef)pix.macCGHandle();
|
||||
SetDragImageWithCGImage(dragRef, img, &hipoint, 0);
|
||||
CGImageRelease(img);
|
||||
}
|
||||
|
||||
SetDragItemBounds(dragRef, (ItemReference)1 , &boundsRect);
|
||||
{ //do the drag
|
||||
qt_mac_in_drag = true;
|
||||
qt_mac_dnd_update_action(dragRef);
|
||||
result = TrackDrag(dragRef, &fakeEvent, QMacSmartQuickDrawRegion(dragRegion.toQDRgn()));
|
||||
qt_mac_in_drag = false;
|
||||
}
|
||||
object = 0;
|
||||
if(result == noErr) {
|
||||
// Check if the receiver points us to
|
||||
// a file location. If so, we need to do
|
||||
// the file copy/move ourselves:
|
||||
QCFType<CFURLRef> pasteLocation = 0;
|
||||
PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation);
|
||||
if (pasteLocation){
|
||||
Qt::DropAction action = o->d_func()->defaultDropAction;
|
||||
if (action == Qt::IgnoreAction){
|
||||
if (o->d_func()->possible_actions & Qt::MoveAction)
|
||||
action = Qt::MoveAction;
|
||||
else if (o->d_func()->possible_actions & Qt::CopyAction)
|
||||
action = Qt::CopyAction;
|
||||
|
||||
}
|
||||
bool atleastOne = false;
|
||||
QList<QUrl> urls = o->mimeData()->urls();
|
||||
for (int i = 0; i < urls.size(); ++i){
|
||||
QUrl fromUrl = urls.at(i);
|
||||
QString filename = QFileInfo(fromUrl.path()).fileName();
|
||||
QUrl toUrl(QCFString::toQString(CFURLGetString(pasteLocation)) + filename);
|
||||
if (action == Qt::MoveAction){
|
||||
if (QFile::rename(fromUrl.path(), toUrl.path()))
|
||||
atleastOne = true;
|
||||
} else if (action == Qt::CopyAction){
|
||||
if (QFile::copy(fromUrl.path(), toUrl.path()))
|
||||
atleastOne = true;
|
||||
}
|
||||
}
|
||||
if (atleastOne){
|
||||
DisposeDrag(dragRef);
|
||||
o->setMimeData(0);
|
||||
o->deleteLater();
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
DragActions ret = kDragActionNothing;
|
||||
GetDragDropAction(dragRef, &ret);
|
||||
DisposeDrag(dragRef); //cleanup
|
||||
o->setMimeData(0);
|
||||
o->deleteLater();
|
||||
return qt_mac_dnd_map_mac_default_action(ret);
|
||||
}
|
||||
DisposeDrag(dragRef); //cleanup
|
||||
return Qt::IgnoreAction;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QDragManager::updatePixmap()
|
||||
{
|
||||
}
|
||||
|
@ -110,11 +110,7 @@ extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp
|
||||
|
||||
static inline CFRunLoopRef mainRunLoop()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return reinterpret_cast<CFRunLoopRef>(const_cast<void *>(GetCFRunLoopFromEventLoop(GetMainEventLoop())));
|
||||
#else
|
||||
return CFRunLoopGetMain();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@ -453,20 +449,13 @@ bool QEventDispatcherMac::hasPendingEvents()
|
||||
|
||||
static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event, OSWindowRef pt)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(pt && SendEventToWindow(event, pt) != eventNotHandledErr)
|
||||
return true;
|
||||
return !SendEventToEventTarget(event, GetEventDispatcherTarget());
|
||||
#else // QT_MAC_USE_COCOA
|
||||
if (pt)
|
||||
[pt sendEvent:event];
|
||||
else
|
||||
[NSApp sendEvent:event];
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
static bool IsMouseOrKeyEvent( NSEvent* event )
|
||||
{
|
||||
bool result = false;
|
||||
@ -510,13 +499,9 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void qt_mac_waitForMoreEvents()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut) ;
|
||||
#else
|
||||
// If no event exist in the cocoa event que, wait
|
||||
// (and free up cpu time) until at least one event occur.
|
||||
// This implementation is a bit on the edge, but seems to
|
||||
@ -527,10 +512,8 @@ static inline void qt_mac_waitForMoreEvents()
|
||||
dequeue:YES];
|
||||
if (event)
|
||||
[NSApp postEvent:event atStart:YES];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
static inline void qt_mac_waitForMoreModalSessionEvents()
|
||||
{
|
||||
// If no event exist in the cocoa event que, wait
|
||||
@ -544,17 +527,14 @@ static inline void qt_mac_waitForMoreModalSessionEvents()
|
||||
if (event)
|
||||
[NSApp postEvent:event atStart:YES];
|
||||
}
|
||||
#endif
|
||||
|
||||
bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
{
|
||||
Q_D(QEventDispatcherMac);
|
||||
d->interrupt = false;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
bool interruptLater = false;
|
||||
QtMacInterruptDispatcherHelp::cancelInterruptLater();
|
||||
#endif
|
||||
|
||||
// In case we end up recursing while we now process events, make sure
|
||||
// that we send remaining posted Qt events before this call returns:
|
||||
@ -567,7 +547,6 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
if (d->interrupt)
|
||||
break;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSEvent* event = 0;
|
||||
|
||||
@ -685,40 +664,6 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
// disturb the 'wait for more events' below (as deleteLater will post an event):
|
||||
interruptLater = true;
|
||||
}
|
||||
#else
|
||||
do {
|
||||
EventRef event;
|
||||
if (!(flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& !d->queuedUserInputEvents.isEmpty()) {
|
||||
// process a pending user input event
|
||||
event = static_cast<EventRef>(d->queuedUserInputEvents.takeFirst());
|
||||
} else {
|
||||
OSStatus err = ReceiveNextEvent(0,0, kEventDurationNoWait, true, &event);
|
||||
if(err != noErr)
|
||||
continue;
|
||||
// else
|
||||
if (flags & QEventLoop::ExcludeUserInputEvents) {
|
||||
UInt32 ekind = GetEventKind(event),
|
||||
eclass = GetEventClass(event);
|
||||
switch(eclass) {
|
||||
case kEventClassQt:
|
||||
if(ekind != kEventQtRequestContext)
|
||||
break;
|
||||
// fall through
|
||||
case kEventClassMouse:
|
||||
case kEventClassKeyboard:
|
||||
d->queuedUserInputEvents.append(event);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!filterEvent(&event) && qt_mac_send_event(flags, event, 0))
|
||||
retVal = true;
|
||||
ReleaseEvent(event);
|
||||
} while(!d->interrupt && GetNumEventsInQueue(GetMainEventQueue()) > 0);
|
||||
|
||||
#endif
|
||||
|
||||
bool canWait = (d->threadData->canWait
|
||||
&& !retVal
|
||||
@ -744,10 +689,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
if (d->interrupt)
|
||||
interrupt();
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (interruptLater)
|
||||
QtMacInterruptDispatcherHelp::interruptLater();
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@ -779,7 +722,6 @@ MacTimerHash QEventDispatcherMacPrivate::macTimerHash;
|
||||
bool QEventDispatcherMacPrivate::blockSendPostedEvents = false;
|
||||
bool QEventDispatcherMacPrivate::interrupt = false;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
|
||||
bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
|
||||
bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
|
||||
@ -973,7 +915,6 @@ void QEventDispatcherMacPrivate::endModalSession(QWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QEventDispatcherMacPrivate::QEventDispatcherMacPrivate()
|
||||
{
|
||||
@ -1043,13 +984,10 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (d->cleanupModalSessionsNeeded)
|
||||
d->cleanupModalSessions();
|
||||
#endif
|
||||
|
||||
if (d->interrupt) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (d->currentExecIsNSAppRun) {
|
||||
// The event dispatcher has been interrupted. But since
|
||||
// [NSApplication run] is running the event loop, we
|
||||
@ -1060,7 +998,6 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
|
||||
[NSApp stop:NSApp];
|
||||
d->cancelWaitForMoreEvents();
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1076,9 +1013,7 @@ void QEventDispatcherMacPrivate::firstLoopEntry(CFRunLoopObserverRef ref,
|
||||
{
|
||||
Q_UNUSED(ref);
|
||||
Q_UNUSED(activity);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QApplicationPrivate::qt_initAfterNSAppStarted();
|
||||
#endif
|
||||
processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
|
||||
}
|
||||
|
||||
@ -1087,7 +1022,6 @@ void QEventDispatcherMacPrivate::postedEventsSourcePerformCallback(void *info)
|
||||
processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
|
||||
{
|
||||
// In case the event dispatcher is waiting for more
|
||||
@ -1097,7 +1031,6 @@ void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
|
||||
modifierFlags:0 timestamp:0. windowNumber:0 context:0
|
||||
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
|
||||
}
|
||||
#endif
|
||||
|
||||
void QEventDispatcherMac::interrupt()
|
||||
{
|
||||
@ -1105,9 +1038,6 @@ void QEventDispatcherMac::interrupt()
|
||||
d->interrupt = true;
|
||||
wakeUp();
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
CFRunLoopStop(mainRunLoop());
|
||||
#else
|
||||
// We do nothing more here than setting d->interrupt = true, and
|
||||
// poke the event loop if it is sleeping. Actually stopping
|
||||
// NSApp, or the current modal session, is done inside the send
|
||||
@ -1116,7 +1046,6 @@ void QEventDispatcherMac::interrupt()
|
||||
// the last event loop recursion, cocoa will just drop pending posted
|
||||
// events on the floor before we get a chance to reestablish a new session.
|
||||
d->cancelWaitForMoreEvents();
|
||||
#endif
|
||||
}
|
||||
|
||||
QEventDispatcherMac::~QEventDispatcherMac()
|
||||
@ -1156,7 +1085,6 @@ QEventDispatcherMac::~QEventDispatcherMac()
|
||||
CFRelease(d->firstTimeObserver);
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
QtMacInterruptDispatcherHelp* QtMacInterruptDispatcherHelp::instance = 0;
|
||||
|
||||
@ -1194,7 +1122,6 @@ void QtMacInterruptDispatcherHelp::interruptLater()
|
||||
instance = new QtMacInterruptDispatcherHelp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -95,14 +95,12 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
typedef struct _NSModalSession *NSModalSession;
|
||||
typedef struct _QCocoaModalSessionInfo {
|
||||
QPointer<QWidget> widget;
|
||||
NSModalSession session;
|
||||
void *nswindow;
|
||||
} QCocoaModalSessionInfo;
|
||||
#endif
|
||||
|
||||
class QEventDispatcherMacPrivate;
|
||||
|
||||
@ -170,7 +168,6 @@ public:
|
||||
// low-level cocoa functions (like beginModalForWindow). And
|
||||
// use a QBoolBlocker to be safe:
|
||||
static bool blockSendPostedEvents;
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// The following variables help organizing modal sessions:
|
||||
static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
|
||||
static bool currentExecIsNSAppRun;
|
||||
@ -185,7 +182,6 @@ public:
|
||||
static void cancelWaitForMoreEvents();
|
||||
static void cleanupModalSessions();
|
||||
static void ensureNSAppInitialized();
|
||||
#endif
|
||||
|
||||
MacSocketHash macSockets;
|
||||
QList<void *> queuedUserInputEvents; // List of EventRef in Carbon, and NSEvent * in Cocoa
|
||||
@ -204,7 +200,6 @@ private:
|
||||
static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
|
||||
};
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
class QtMacInterruptDispatcherHelp : public QObject
|
||||
{
|
||||
static QtMacInterruptDispatcherHelp *instance;
|
||||
@ -217,7 +212,6 @@ class QtMacInterruptDispatcherHelp : public QObject
|
||||
static void interruptLater();
|
||||
static void cancelInterruptLater();
|
||||
};
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -100,31 +100,20 @@ void QFont::cleanup()
|
||||
*/
|
||||
quint32 QFont::macFontID() const // ### need 64-bit version
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
return 0;
|
||||
#elif 1
|
||||
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
|
||||
if (fe && fe->type() == QFontEngine::Multi)
|
||||
return static_cast<QFontEngineMacMulti*>(fe)->macFontID();
|
||||
#else
|
||||
Str255 name;
|
||||
if(FMGetFontFamilyName((FMFontFamily)((UInt32)handle()), name) == noErr) {
|
||||
short fnum;
|
||||
GetFNum(name, &fnum);
|
||||
return fnum;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns an ATSUFonFamilyRef
|
||||
Qt::HANDLE QFont::handle() const
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
|
||||
if (fe && fe->type() == QFontEngine::Multi)
|
||||
return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -53,38 +53,6 @@ QT_BEGIN_NAMESPACE
|
||||
int qt_mac_pixelsize(const QFontDef &def, int dpi); //qfont_mac.cpp
|
||||
int qt_mac_pointsize(const QFontDef &def, int dpi); //qfont_mac.cpp
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
|
||||
{
|
||||
ByteCount length = 0;
|
||||
if (ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, 0, 0, &length) != noErr)
|
||||
return;
|
||||
QVarLengthArray<uchar> os2Table(length);
|
||||
if (length < 86
|
||||
|| ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, length, os2Table.data(), &length) != noErr)
|
||||
return;
|
||||
|
||||
// See also qfontdatabase_win.cpp, offsets taken from OS/2 table in the TrueType spec
|
||||
quint32 unicodeRange[4] = {
|
||||
qFromBigEndian<quint32>(os2Table.data() + 42),
|
||||
qFromBigEndian<quint32>(os2Table.data() + 46),
|
||||
qFromBigEndian<quint32>(os2Table.data() + 50),
|
||||
qFromBigEndian<quint32>(os2Table.data() + 54)
|
||||
};
|
||||
quint32 codePageRange[2] = { qFromBigEndian<quint32>(os2Table.data() + 78), qFromBigEndian<quint32>(os2Table.data() + 82) };
|
||||
QList<QFontDatabase::WritingSystem> systems = qt_determine_writing_systems_from_truetype_bits(unicodeRange, codePageRange);
|
||||
#if 0
|
||||
QCFString name;
|
||||
ATSFontGetName(atsFont, kATSOptionFlagsDefault, &name);
|
||||
qDebug() << systems.count() << "writing systems for" << QString(name);
|
||||
qDebug() << "first char" << hex << unicodeRange[0];
|
||||
for (int i = 0; i < systems.count(); ++i)
|
||||
qDebug() << QFontDatabase::writingSystemName(systems.at(i));
|
||||
#endif
|
||||
for (int i = 0; i < systems.count(); ++i)
|
||||
family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void initializeDb()
|
||||
{
|
||||
@ -92,7 +60,7 @@ static void initializeDb()
|
||||
if(!db || db->count)
|
||||
return;
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
||||
QCFType<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
|
||||
if(!collection)
|
||||
@ -156,66 +124,6 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
FMFontIterator it;
|
||||
if (!FMCreateFontIterator(0, 0, kFMUseGlobalScopeOption, &it)) {
|
||||
while (true) {
|
||||
FMFont fmFont;
|
||||
if (FMGetNextFont(&it, &fmFont) != noErr)
|
||||
break;
|
||||
|
||||
FMFontFamily fmFamily;
|
||||
FMFontStyle fmStyle;
|
||||
QString familyName;
|
||||
|
||||
QtFontStyle::Key styleKey;
|
||||
|
||||
ATSFontRef atsFont = FMGetATSFontRefFromFont(fmFont);
|
||||
|
||||
if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) {
|
||||
{ //sanity check the font, and see if we can use it at all! --Sam
|
||||
ATSUFontID fontID;
|
||||
if(ATSUFONDtoFontID(fmFamily, 0, &fontID) != noErr)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fmStyle & ::italic)
|
||||
styleKey.style = QFont::StyleItalic;
|
||||
if (fmStyle & ::bold)
|
||||
styleKey.weight = QFont::Bold;
|
||||
|
||||
ATSFontFamilyRef familyRef = FMGetATSFontFamilyRefFromFontFamily(fmFamily);
|
||||
QCFString cfFamilyName;;
|
||||
ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &cfFamilyName);
|
||||
familyName = cfFamilyName;
|
||||
} else {
|
||||
QCFString cfFontName;
|
||||
ATSFontGetName(atsFont, kATSOptionFlagsDefault, &cfFontName);
|
||||
familyName = cfFontName;
|
||||
quint16 macStyle = 0;
|
||||
{
|
||||
uchar data[4];
|
||||
ByteCount len = 4;
|
||||
if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 44, 4, &data, &len) == noErr)
|
||||
macStyle = qFromBigEndian<quint16>(data);
|
||||
}
|
||||
if (macStyle & 1)
|
||||
styleKey.weight = QFont::Bold;
|
||||
if (macStyle & 2)
|
||||
styleKey.style = QFont::StyleItalic;
|
||||
}
|
||||
|
||||
QtFontFamily *family = db->family(familyName, true);
|
||||
QtFontFoundry *foundry = family->foundry(QString(), true);
|
||||
QtFontStyle *style = foundry->style(styleKey, QString(), true);
|
||||
style->pixelSize(0, true);
|
||||
style->smoothScalable = true;
|
||||
|
||||
initWritingSystems(family, atsFont);
|
||||
}
|
||||
FMDisposeFontIterator(&it);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@ -253,12 +161,7 @@ static inline float weightToFloat(unsigned int weight)
|
||||
|
||||
static QFontEngine *loadFromDatabase(const QFontDef &req, const QFontPrivate *d)
|
||||
{
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
QCFString fontName = NULL;
|
||||
#else
|
||||
ATSFontFamilyRef familyRef = 0;
|
||||
ATSFontRef fontRef = 0;
|
||||
#endif
|
||||
|
||||
QStringList family_list = familyList(req);
|
||||
|
||||
@ -277,34 +180,17 @@ static QFontEngine *loadFromDatabase(const QFontDef &req, const QFontPrivate *d)
|
||||
for (int k = 0; k < db->count; ++k) {
|
||||
if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
|
||||
QByteArray family_name = db->families[k]->name.toUtf8();
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL);
|
||||
if (ctFont) {
|
||||
fontName = CTFontCopyFullName(ctFont);
|
||||
goto found;
|
||||
}
|
||||
#else
|
||||
familyRef = ATSFontFamilyFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
|
||||
if (familyRef) {
|
||||
fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
|
||||
goto found;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
found:
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (fontName)
|
||||
return new QCoreTextFontEngineMulti(fontName, req, d->kerning);
|
||||
#else
|
||||
if (familyRef) {
|
||||
QCFString actualName;
|
||||
if (ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr)
|
||||
req.family = actualName;
|
||||
return new QFontEngineMacMulti(familyRef, req, fontDef, d->kerning);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -349,7 +235,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
|
||||
}
|
||||
|
||||
QFontEngine *engine = NULL;
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
// Shortcut to get the font directly without going through the font database
|
||||
if (!req.family.isEmpty() && !req.styleName.isEmpty()) {
|
||||
QCFString expectedFamily = QCFString(req.family);
|
||||
@ -371,7 +256,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!engine)
|
||||
engine = loadFromDatabase(req, d);
|
||||
|
||||
@ -430,7 +314,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
|
||||
return;
|
||||
|
||||
fnt->families.clear();
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
// Make sure that the family name set on the font matches what
|
||||
// kCTFontFamilyNameAttribute returns in initializeDb().
|
||||
// So far the best solution seems find the installed font
|
||||
@ -444,13 +327,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
|
||||
QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
|
||||
fnt->families.append(familyName);
|
||||
}
|
||||
#else
|
||||
for(int i = 0; i < containedFonts.size(); ++i) {
|
||||
QCFString family;
|
||||
ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
|
||||
fnt->families.append(family);
|
||||
}
|
||||
#endif
|
||||
|
||||
fnt->handle = handle;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,122 +44,5 @@
|
||||
|
||||
#include <private/qfontengine_p.h>
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
class QFontEngineMacMulti;
|
||||
class QFontEngineMac : public QFontEngine
|
||||
{
|
||||
friend class QFontEngineMacMulti;
|
||||
public:
|
||||
QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine = 0);
|
||||
virtual ~QFontEngineMac();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph);
|
||||
|
||||
virtual QFixed ascent() const;
|
||||
virtual QFixed descent() const;
|
||||
virtual QFixed leading() const;
|
||||
virtual QFixed xHeight() const;
|
||||
virtual qreal maxCharWidth() const;
|
||||
virtual QFixed averageCharWidth() const;
|
||||
|
||||
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
|
||||
QPainterPath *path, QTextItem::RenderFlags);
|
||||
|
||||
virtual const char *name() const { return "QFontEngineMac"; }
|
||||
|
||||
virtual bool canRender(const QChar *string, int len);
|
||||
|
||||
virtual int synthesized() const { return synthesisFlags; }
|
||||
|
||||
virtual Type type() const { return QFontEngine::Mac; }
|
||||
|
||||
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
|
||||
|
||||
virtual FaceId faceId() const;
|
||||
virtual QByteArray getSfntTable(uint tag) const;
|
||||
virtual Properties properties() const;
|
||||
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
|
||||
virtual QImage alphaMapForGlyph(glyph_t);
|
||||
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
|
||||
|
||||
private:
|
||||
QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
|
||||
|
||||
ATSUFontID fontID;
|
||||
QCFType<CGFontRef> cgFont;
|
||||
ATSUStyle style;
|
||||
int synthesisFlags;
|
||||
mutable QGlyphLayout kashidaGlyph;
|
||||
QFontEngineMacMulti *multiEngine;
|
||||
mutable const unsigned char *cmap;
|
||||
mutable bool symbolCMap;
|
||||
mutable QByteArray cmapTable;
|
||||
CGAffineTransform transform;
|
||||
QFixed m_ascent;
|
||||
QFixed m_descent;
|
||||
QFixed m_leading;
|
||||
qreal m_maxCharWidth;
|
||||
QFixed m_xHeight;
|
||||
QFixed m_averageCharWidth;
|
||||
};
|
||||
|
||||
class QFontEngineMacMulti : public QFontEngineMulti
|
||||
{
|
||||
friend class QFontEngineMac;
|
||||
public:
|
||||
// internal
|
||||
struct ShaperItem
|
||||
{
|
||||
inline ShaperItem() : string(0), from(0), length(0),
|
||||
log_clusters(0), charAttributes(0) {}
|
||||
|
||||
const QChar *string;
|
||||
int from;
|
||||
int length;
|
||||
QGlyphLayout glyphs;
|
||||
unsigned short *log_clusters;
|
||||
const HB_CharAttributes *charAttributes;
|
||||
QTextEngine::ShaperFlags flags;
|
||||
};
|
||||
|
||||
QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning);
|
||||
virtual ~QFontEngineMacMulti();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
|
||||
unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const;
|
||||
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
|
||||
virtual const char *name() const { return "ATSUI"; }
|
||||
|
||||
virtual bool canRender(const QChar *string, int len);
|
||||
|
||||
inline ATSUFontID macFontID() const { return fontID; }
|
||||
|
||||
protected:
|
||||
virtual void loadEngine(int at);
|
||||
|
||||
private:
|
||||
inline const QFontEngineMac *engineAt(int i) const
|
||||
{ return static_cast<const QFontEngineMac *>(engines.at(i)); }
|
||||
|
||||
bool stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags, ShaperItem *item) const;
|
||||
|
||||
int fontIndexForFontID(ATSUFontID id) const;
|
||||
|
||||
ATSUFontID fontID;
|
||||
uint kerning : 1;
|
||||
|
||||
mutable ATSUTextLayout textLayout;
|
||||
mutable ATSUStyle style;
|
||||
CGAffineTransform transform;
|
||||
};
|
||||
#endif //!QT_MAC_USE_COCOA
|
||||
|
||||
#endif // QFONTENGINE_MAC_P_H
|
||||
|
@ -435,10 +435,6 @@ static Boolean qt_KeyEventComparatorProc(EventRef inEvent, void *data)
|
||||
static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey,
|
||||
QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
|
||||
{
|
||||
#if !defined(QT_MAC_USE_COCOA) || defined(Q_OS_MAC64)
|
||||
Q_UNUSED(er);
|
||||
Q_UNUSED(outHandled);
|
||||
#endif
|
||||
const UInt32 ekind = GetEventKind(keyEvent);
|
||||
{
|
||||
UInt32 mac_modifiers = 0;
|
||||
@ -534,14 +530,12 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
|
||||
rightShiftKey|alphaLock)) | keyCode,
|
||||
&tmp_unused_state);
|
||||
if (!translatedChar) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (outHandled) {
|
||||
qt_mac_eat_unicode_key = false;
|
||||
if (er)
|
||||
CallNextEventHandler(er, keyEvent);
|
||||
*outHandled = qt_mac_eat_unicode_key;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -774,26 +768,6 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
|
||||
|
||||
|
||||
if (widget) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_UNUSED(info);
|
||||
// Try not to call "other" event handlers if we have a popup,
|
||||
// However, if the key has text
|
||||
// then we should pass it along because otherwise then people
|
||||
// can use input method stuff.
|
||||
if (!qApp->activePopupWidget()
|
||||
|| (qApp->activePopupWidget() && !text.isEmpty())) {
|
||||
//Find out if someone else wants the event, namely
|
||||
//is it of use to text services? If so we won't bother
|
||||
//with a QKeyEvent.
|
||||
qt_mac_eat_unicode_key = false;
|
||||
if (er)
|
||||
CallNextEventHandler(er, event);
|
||||
extern bool qt_mac_menubar_is_open();
|
||||
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Try to compress key events.
|
||||
if (!text.isEmpty() && widget->testAttribute(Qt::WA_KeyCompression)) {
|
||||
EventTime lastTime = GetEventTime(event);
|
||||
@ -866,7 +840,6 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
|
||||
UInt32 macModifiers = 0;
|
||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
|
||||
sizeof(macModifiers), 0, &macModifiers);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// The unicode characters in the range 0xF700-0xF747 are reserved
|
||||
// by Mac OS X for transient use as keyboard function keys. We
|
||||
// wont send 'text' for such key events. This is done to match
|
||||
@ -875,27 +848,20 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
|
||||
if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
|
||||
text = QString();
|
||||
bool isAccepted;
|
||||
#endif
|
||||
handled_event = QKeyMapper::sendKeyEvent(widget, grab,
|
||||
(ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
|
||||
qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
|
||||
macScanCode, macVirtualKey, macModifiers
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
,&isAccepted
|
||||
#endif
|
||||
);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
*unicodeKey = (unsigned int)isAccepted;
|
||||
#endif
|
||||
}
|
||||
return handled_event;
|
||||
}
|
||||
|
||||
void
|
||||
QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
unicodeKey // unicode character from NSEvent (modifiers applied)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
UInt32 macVirtualKey = 0;
|
||||
|
@ -159,7 +159,6 @@ void QMacPinchGestureRecognizer::reset(QGesture *gesture)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
|
||||
QMacPanGestureRecognizer::QMacPanGestureRecognizer() : _panCanceled(true)
|
||||
{
|
||||
@ -265,7 +264,6 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture)
|
||||
g->setAcceleration(qreal(1));
|
||||
QGestureRecognizer::reset(gesture);
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -81,7 +81,6 @@ public:
|
||||
void reset(QGesture *gesture);
|
||||
};
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
|
||||
class QMacPanGestureRecognizer : public QObject, public QGestureRecognizer
|
||||
{
|
||||
@ -97,7 +96,6 @@ private:
|
||||
bool _panCanceled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -65,21 +65,11 @@ QMacInputContext::QMacInputContext(QObject *parent)
|
||||
|
||||
QMacInputContext::~QMacInputContext()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(textDocument)
|
||||
DeleteTSMDocument(textDocument);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
QMacInputContext::createTextDocument()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(!textDocument) {
|
||||
InterfaceTypeList itl = { kUnicodeDocument };
|
||||
NewTSMDocument(1, itl, &textDocument, SRefCon(this));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -91,103 +81,27 @@ QString QMacInputContext::language()
|
||||
|
||||
void QMacInputContext::mouseHandler(int pos, QMouseEvent *e)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(e->type() != QEvent::MouseButtonPress)
|
||||
return;
|
||||
|
||||
if (!composing)
|
||||
return;
|
||||
if (pos < 0 || pos > currentText.length())
|
||||
reset();
|
||||
// ##### handle mouse position
|
||||
#else
|
||||
Q_UNUSED(pos);
|
||||
Q_UNUSED(e);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined QT_MAC_USE_COCOA
|
||||
|
||||
static QTextFormat qt_mac_compose_format()
|
||||
{
|
||||
QTextCharFormat ret;
|
||||
ret.setFontUnderline(true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QMacInputContext::reset()
|
||||
{
|
||||
if (recursionGuard)
|
||||
return;
|
||||
if (!currentText.isEmpty()){
|
||||
QInputMethodEvent e;
|
||||
e.setCommitString(currentText);
|
||||
qt_sendSpontaneousEvent(focusWidget(), &e);
|
||||
currentText = QString();
|
||||
}
|
||||
recursionGuard = true;
|
||||
createTextDocument();
|
||||
composing = false;
|
||||
ActivateTSMDocument(textDocument);
|
||||
FixTSMDocument(textDocument);
|
||||
recursionGuard = false;
|
||||
}
|
||||
|
||||
bool QMacInputContext::isComposing() const
|
||||
{
|
||||
return composing;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QMacInputContext::setFocusWidget(QWidget *w)
|
||||
{
|
||||
createTextDocument();
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(w)
|
||||
ActivateTSMDocument(textDocument);
|
||||
else
|
||||
DeactivateTSMDocument(textDocument);
|
||||
#endif
|
||||
QInputContext::setFocusWidget(w);
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static EventTypeSpec input_events[] = {
|
||||
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
|
||||
{ kEventClassTextInput, kEventTextInputOffsetToPos },
|
||||
{ kEventClassTextInput, kEventTextInputUpdateActiveInputArea }
|
||||
};
|
||||
static EventHandlerUPP input_proc_handlerUPP = 0;
|
||||
static EventHandlerRef input_proc_handler = 0;
|
||||
#endif
|
||||
|
||||
void
|
||||
QMacInputContext::initialize()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(!input_proc_handler) {
|
||||
input_proc_handlerUPP = NewEventHandlerUPP(QMacInputContext::globalEventProcessor);
|
||||
InstallEventHandler(GetApplicationEventTarget(), input_proc_handlerUPP,
|
||||
GetEventTypeCount(input_events), input_events,
|
||||
0, &input_proc_handler);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
QMacInputContext::cleanup()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if(input_proc_handler) {
|
||||
RemoveEventHandler(input_proc_handler);
|
||||
input_proc_handler = 0;
|
||||
}
|
||||
if(input_proc_handlerUPP) {
|
||||
DisposeEventHandlerUPP(input_proc_handlerUPP);
|
||||
input_proc_handlerUPP = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QMacInputContext::setLastKeydownEvent(EventRef event)
|
||||
@ -203,175 +117,7 @@ void QMacInputContext::setLastKeydownEvent(EventRef event)
|
||||
OSStatus
|
||||
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
|
||||
|
||||
SRefCon refcon = 0;
|
||||
GetEventParameter(event, kEventParamTextInputSendRefCon, typeRefCon, 0,
|
||||
sizeof(refcon), 0, &refcon);
|
||||
QMacInputContext *context = reinterpret_cast<QMacInputContext*>(refcon);
|
||||
|
||||
bool handled_event=true;
|
||||
UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
|
||||
switch(eclass) {
|
||||
case kEventClassTextInput: {
|
||||
handled_event = false;
|
||||
QWidget *widget = QApplicationPrivate::focus_widget;
|
||||
bool canCompose = widget && (!context || widget->inputContext() == context)
|
||||
&& !(widget->inputMethodHints() & Qt::ImhDigitsOnly
|
||||
|| widget->inputMethodHints() & Qt::ImhFormattedNumbersOnly
|
||||
|| widget->inputMethodHints() & Qt::ImhHiddenText);
|
||||
if(!canCompose) {
|
||||
handled_event = false;
|
||||
} else if(ekind == kEventTextInputOffsetToPos) {
|
||||
if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
|
||||
handled_event = false;
|
||||
break;
|
||||
}
|
||||
|
||||
QRect mr(widget->inputMethodQuery(Qt::ImMicroFocus).toRect());
|
||||
QPoint mp(widget->mapToGlobal(QPoint(mr.topLeft())));
|
||||
Point pt;
|
||||
pt.h = mp.x();
|
||||
pt.v = mp.y() + mr.height();
|
||||
SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint,
|
||||
sizeof(pt), &pt);
|
||||
handled_event = true;
|
||||
} else if(ekind == kEventTextInputUpdateActiveInputArea) {
|
||||
if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
|
||||
handled_event = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (context->recursionGuard)
|
||||
break;
|
||||
|
||||
ByteCount unilen = 0;
|
||||
GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
|
||||
0, 0, &unilen, 0);
|
||||
UniChar *unicode = (UniChar*)NewPtr(unilen);
|
||||
GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
|
||||
0, unilen, 0, unicode);
|
||||
QString text((QChar*)unicode, unilen / sizeof(UniChar));
|
||||
DisposePtr((char*)unicode);
|
||||
|
||||
ByteCount fixed_length = 0;
|
||||
GetEventParameter(event, kEventParamTextInputSendFixLen, typeByteCount, 0,
|
||||
sizeof(fixed_length), 0, &fixed_length);
|
||||
if(fixed_length == ULONG_MAX || fixed_length == unilen) {
|
||||
QInputMethodEvent e;
|
||||
e.setCommitString(text);
|
||||
context->currentText = QString();
|
||||
qt_sendSpontaneousEvent(context->focusWidget(), &e);
|
||||
handled_event = true;
|
||||
context->reset();
|
||||
} else {
|
||||
ByteCount rngSize = 0;
|
||||
OSStatus err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
|
||||
0, &rngSize, 0);
|
||||
QVarLengthArray<TextRangeArray> highlight(rngSize);
|
||||
if (noErr == err) {
|
||||
err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
|
||||
rngSize, &rngSize, highlight.data());
|
||||
}
|
||||
context->composing = true;
|
||||
if(fixed_length > 0) {
|
||||
const int qFixedLength = fixed_length / sizeof(UniChar);
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
|
||||
qFixedLength, text.length()-qFixedLength,
|
||||
qt_mac_compose_format());
|
||||
QInputMethodEvent e(text, attrs);
|
||||
context->currentText = text;
|
||||
e.setCommitString(text.left(qFixedLength), 0, qFixedLength);
|
||||
qt_sendSpontaneousEvent(widget, &e);
|
||||
handled_event = true;
|
||||
} else {
|
||||
/* Apple's enums that they have removed from Tiger :(
|
||||
enum {
|
||||
kCaretPosition = 1,
|
||||
kRawText = 2,
|
||||
kSelectedRawText = 3,
|
||||
kConvertedText = 4,
|
||||
kSelectedConvertedText = 5,
|
||||
kBlockFillText = 6,
|
||||
kOutlineText = 7,
|
||||
kSelectedText = 8
|
||||
};
|
||||
*/
|
||||
#ifndef kConvertedText
|
||||
#define kConvertedText 4
|
||||
#endif
|
||||
#ifndef kCaretPosition
|
||||
#define kCaretPosition 1
|
||||
#endif
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
if (!highlight.isEmpty()) {
|
||||
TextRangeArray *data = highlight.data();
|
||||
for (int i = 0; i < data->fNumOfRanges; ++i) {
|
||||
int start = data->fRange[i].fStart / sizeof(UniChar);
|
||||
int len = (data->fRange[i].fEnd - data->fRange[i].fStart) / sizeof(UniChar);
|
||||
if (data->fRange[i].fHiliteStyle == kCaretPosition) {
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, start, 0, QVariant());
|
||||
continue;
|
||||
}
|
||||
QTextCharFormat format;
|
||||
format.setFontUnderline(true);
|
||||
if (data->fRange[i].fHiliteStyle == kConvertedText)
|
||||
format.setUnderlineColor(Qt::gray);
|
||||
else
|
||||
format.setUnderlineColor(Qt::black);
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, start, len, format);
|
||||
}
|
||||
} else {
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
|
||||
0, text.length(), qt_mac_compose_format());
|
||||
}
|
||||
context->currentText = text;
|
||||
QInputMethodEvent e(text, attrs);
|
||||
qt_sendSpontaneousEvent(widget, &e);
|
||||
handled_event = true;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if(!context->composing)
|
||||
handled_event = false;
|
||||
#endif
|
||||
|
||||
extern bool qt_mac_eat_unicode_key; //qapplication_mac.cpp
|
||||
qt_mac_eat_unicode_key = handled_event;
|
||||
} else if(ekind == kEventTextInputUnicodeForKeyEvent) {
|
||||
EventRef key_ev = 0;
|
||||
GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
|
||||
sizeof(key_ev), 0, &key_ev);
|
||||
QString text;
|
||||
ByteCount unilen = 0;
|
||||
if(GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, 0, &unilen, 0) == noErr) {
|
||||
UniChar *unicode = (UniChar*)NewPtr(unilen);
|
||||
GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, unilen, 0, unicode);
|
||||
text = QString((QChar*)unicode, unilen / sizeof(UniChar));
|
||||
DisposePtr((char*)unicode);
|
||||
}
|
||||
unsigned char chr = 0;
|
||||
GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
|
||||
if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
|
||||
handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
|
||||
QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
|
||||
if (context && context->lastKeydownEvent()) {
|
||||
qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
|
||||
0, false);
|
||||
context->setLastKeydownEvent(0);
|
||||
}
|
||||
}
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!handled_event) //let the event go through
|
||||
return eventNotHandledErr;
|
||||
#else
|
||||
Q_UNUSED(event);
|
||||
#endif
|
||||
return noErr; //we eat the event
|
||||
}
|
||||
|
||||
|
@ -556,11 +556,7 @@ QCoreGraphicsPaintEngine::end()
|
||||
Q_D(QCoreGraphicsPaintEngine);
|
||||
setActive(false);
|
||||
if(d->pdev->devType() == QInternal::Widget && static_cast<QWidget*>(d->pdev)->windowType() == Qt::Desktop) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HideWindow(qt_mac_window_for(static_cast<QWidget*>(d->pdev)));
|
||||
#else
|
||||
// // ### need to do [qt_mac_window_for(static_cast<QWidget *>(d->pdev)) orderOut]; (need to rename)
|
||||
#endif
|
||||
|
||||
}
|
||||
if(d->shading) {
|
||||
@ -1045,11 +1041,7 @@ void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem
|
||||
if (ti.glyphs.numGlyphs) {
|
||||
switch (fe->type()) {
|
||||
case QFontEngine::Mac:
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
static_cast<QCoreTextFontEngine *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
|
||||
#else
|
||||
static_cast<QFontEngineMac *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
|
||||
#endif
|
||||
break;
|
||||
case QFontEngine::Box:
|
||||
d->drawBoxTextItem(pos, ti);
|
||||
|
@ -860,28 +860,6 @@ static QPixmap qt_mac_grabScreenRect(const QRect &rect)
|
||||
return QPixmap::fromMacCGImageRef(image);
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA // no QuickDraw in 64-bit mode
|
||||
static QPixmap qt_mac_grabScreenRect_10_3(int x, int y, int w, int h, QWidget *widget)
|
||||
{
|
||||
QPixmap pm = QPixmap(w, h);
|
||||
extern WindowPtr qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
|
||||
const BitMap *windowPort = 0;
|
||||
if((widget->windowType() == Qt::Desktop)) {
|
||||
GDHandle gdh;
|
||||
if(!(gdh=GetMainDevice()))
|
||||
qDebug("Qt: internal: Unexpected condition reached: %s:%d", __FILE__, __LINE__);
|
||||
windowPort = (BitMap*)(*(*gdh)->gdPMap);
|
||||
} else {
|
||||
windowPort = GetPortBitMapForCopyBits(GetWindowPort(qt_mac_window_for(widget)));
|
||||
}
|
||||
const BitMap *pixmapPort = GetPortBitMapForCopyBits(static_cast<GWorldPtr>(pm.macQDHandle()));
|
||||
Rect macSrcRect, macDstRect;
|
||||
SetRect(&macSrcRect, x, y, x + w, y + h);
|
||||
SetRect(&macDstRect, 0, 0, w, h);
|
||||
CopyBits(windowPort, pixmapPort, &macSrcRect, &macDstRect, srcCopy, 0);
|
||||
return pm;
|
||||
}
|
||||
#endif
|
||||
|
||||
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
||||
{
|
||||
@ -898,18 +876,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
||||
globalCoord = widget->mapToGlobal(globalCoord);
|
||||
QRect rect(globalCoord.x() + x, globalCoord.y() + y, w, h);
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
return qt_mac_grabScreenRect(rect);
|
||||
#else
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
|
||||
return qt_mac_grabScreenRect(rect);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
return qt_mac_grabScreenRect_10_3(x, y, w, h, widget);
|
||||
}
|
||||
#endif // ifdef Q_WS_MAC64
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
@ -1005,85 +972,6 @@ CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr)
|
||||
return px->cg_mask;
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
IconRef qt_mac_create_iconref(const QPixmap &px)
|
||||
{
|
||||
if (px.isNull())
|
||||
return 0;
|
||||
|
||||
//create icon
|
||||
IconFamilyHandle iconFamily = reinterpret_cast<IconFamilyHandle>(NewHandle(0));
|
||||
//create data
|
||||
{
|
||||
struct {
|
||||
OSType mac_type;
|
||||
int width, height, depth;
|
||||
bool mask;
|
||||
} images[] = {
|
||||
{ kThumbnail32BitData, 128, 128, 32, false },
|
||||
{ kThumbnail8BitMask, 128, 128, 8, true },
|
||||
{ 0, 0, 0, 0, false } //end marker
|
||||
};
|
||||
for(int i = 0; images[i].mac_type; i++) {
|
||||
//get QPixmap data
|
||||
QImage scaled_px = px.toImage().scaled(images[i].width, images[i].height);
|
||||
|
||||
quint32 *sptr = (quint32 *) scaled_px.bits();
|
||||
quint32 *srow;
|
||||
uint sbpr = scaled_px.bytesPerLine();
|
||||
|
||||
//get Handle data
|
||||
const int dbpr = images[i].width * (images[i].depth/8);
|
||||
Handle hdl = NewHandle(dbpr*images[i].height);
|
||||
if(!sptr) { //handle null pixmap
|
||||
memset((*hdl), '\0', dbpr*images[i].height);
|
||||
} else if(images[i].mask) {
|
||||
if(images[i].mac_type == kThumbnail8BitMask) {
|
||||
for(int y = 0, hindex = 0; y < images[i].height; ++y) {
|
||||
srow = sptr + (y * (sbpr/4));
|
||||
for(int x = 0; x < images[i].width; ++x)
|
||||
*((*hdl)+(hindex++)) = qAlpha(*(srow+x));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char *dest = (*hdl);
|
||||
#if defined(__i386__)
|
||||
if(images[i].depth == 32) {
|
||||
for(int y = 0; y < images[i].height; ++y) {
|
||||
uint *source = (uint*)((const uchar*)sptr+(sbpr*y));
|
||||
for(int x = 0; x < images[i].width; ++x, dest += 4)
|
||||
*((uint*)dest) = CFSwapInt32(*(source + x));
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for(int y = 0; y < images[i].height; ++y)
|
||||
memcpy(dest+(y*dbpr), ((const uchar*)sptr+(sbpr*y)), dbpr);
|
||||
}
|
||||
}
|
||||
|
||||
//set the family data to the Handle
|
||||
OSStatus set = SetIconFamilyData(iconFamily, images[i].mac_type, hdl);
|
||||
if(set != noErr)
|
||||
qWarning("%s: %d -- Unable to create icon data[%d]!! %ld",
|
||||
__FILE__, __LINE__, i, long(set));
|
||||
DisposeHandle(hdl);
|
||||
}
|
||||
}
|
||||
|
||||
//acquire and cleanup
|
||||
IconRef ret;
|
||||
static int counter = 0;
|
||||
const OSType kQtCreator = 'CUTE';
|
||||
RegisterIconRefFromIconFamily(kQtCreator, (OSType)counter, iconFamily, &ret);
|
||||
AcquireIconRef(ret);
|
||||
UnregisterIconRef(kQtCreator, (OSType)counter);
|
||||
DisposeHandle(reinterpret_cast<Handle>(iconFamily));
|
||||
counter++;
|
||||
return ret;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! \internal */
|
||||
QPaintEngine* QMacPlatformPixmap::paintEngine() const
|
||||
|
@ -90,12 +90,7 @@ bool QMacPrintEngine::begin(QPaintDevice *dev)
|
||||
}
|
||||
}
|
||||
OSStatus status = noErr;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format)
|
||||
: PMSessionBeginCGDocument(d->session, d->settings, d->format);
|
||||
#else
|
||||
status = PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format);
|
||||
#endif
|
||||
|
||||
if (status != noErr) {
|
||||
d->state = QPrinter::Error;
|
||||
@ -139,9 +134,7 @@ Qt::HANDLE QMacPrintEngine::handle() const
|
||||
|
||||
QMacPrintEnginePrivate::~QMacPrintEnginePrivate()
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
[printInfo release];
|
||||
#endif
|
||||
delete paintEngine;
|
||||
}
|
||||
|
||||
@ -250,12 +243,7 @@ bool QMacPrintEngine::newPage()
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
OSStatus err =
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
d->shouldSuppressStatus() ? PMSessionEndPageNoDialog(d->session)
|
||||
: PMSessionEndPage(d->session);
|
||||
#else
|
||||
PMSessionEndPageNoDialog(d->session);
|
||||
#endif
|
||||
if (err != noErr) {
|
||||
if (err == kPMCancel) {
|
||||
// User canceled, we need to abort!
|
||||
@ -357,18 +345,7 @@ int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
|
||||
PMPrinter printer;
|
||||
if(PMSessionGetCurrentPrinter(d->session, &printer) == noErr) {
|
||||
PMResolution resolution;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
||||
PMPrinterGetOutputResolution(printer, d->settings, &resolution);
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &resolution);
|
||||
}
|
||||
#else
|
||||
PMPrinterGetOutputResolution(printer, d->settings, &resolution);
|
||||
#endif
|
||||
val = (int)resolution.vRes;
|
||||
break;
|
||||
}
|
||||
@ -397,11 +374,7 @@ void QMacPrintEnginePrivate::initialize()
|
||||
{
|
||||
Q_Q(QMacPrintEngine);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_ASSERT(!session);
|
||||
#else
|
||||
Q_ASSERT(!printInfo);
|
||||
#endif
|
||||
|
||||
if (!paintEngine)
|
||||
paintEngine = new QCoreGraphicsPaintEngine();
|
||||
@ -410,14 +383,9 @@ void QMacPrintEnginePrivate::initialize()
|
||||
|
||||
fullPage = false;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (PMCreateSession(&session) != 0)
|
||||
session = 0;
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
|
||||
session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
|
||||
#endif
|
||||
|
||||
PMPrinter printer;
|
||||
if (session && PMSessionGetCurrentPrinter(session, &printer) == noErr) {
|
||||
@ -441,32 +409,9 @@ void QMacPrintEnginePrivate::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
bool settingsInitialized = (settings != 0);
|
||||
bool settingsOK = !settingsInitialized ? PMCreatePrintSettings(&settings) == noErr : true;
|
||||
if (settingsOK && !settingsInitialized)
|
||||
settingsOK = PMSessionDefaultPrintSettings(session, settings) == noErr;
|
||||
|
||||
|
||||
bool formatInitialized = (format != 0);
|
||||
bool formatOK = !formatInitialized ? PMCreatePageFormat(&format) == noErr : true;
|
||||
if (formatOK) {
|
||||
if (!formatInitialized) {
|
||||
formatOK = PMSessionDefaultPageFormat(session, format) == noErr;
|
||||
}
|
||||
formatOK = PMSessionValidatePageFormat(session, format, kPMDontWantBoolean) == noErr;
|
||||
}
|
||||
#else
|
||||
settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
|
||||
format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
|
||||
#endif
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (!settingsOK || !formatOK) {
|
||||
qWarning("QMacPrintEngine::initialize: Unable to initialize QPainter");
|
||||
state = QPrinter::Error;
|
||||
}
|
||||
#endif
|
||||
|
||||
QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant>::const_iterator propC;
|
||||
for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); propC++) {
|
||||
@ -476,20 +421,9 @@ void QMacPrintEnginePrivate::initialize()
|
||||
|
||||
void QMacPrintEnginePrivate::releaseSession()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (shouldSuppressStatus()) {
|
||||
PMSessionEndPageNoDialog(session);
|
||||
PMSessionEndDocumentNoDialog(session);
|
||||
} else {
|
||||
PMSessionEndPage(session);
|
||||
PMSessionEndDocument(session);
|
||||
}
|
||||
PMRelease(session);
|
||||
#else
|
||||
PMSessionEndPageNoDialog(session);
|
||||
PMSessionEndDocumentNoDialog(session);
|
||||
[printInfo release];
|
||||
#endif
|
||||
printInfo = 0;
|
||||
session = 0;
|
||||
}
|
||||
@ -512,12 +446,7 @@ bool QMacPrintEnginePrivate::newPage_helper()
|
||||
cgEngine->d_func()->restoreGraphicsState();
|
||||
|
||||
OSStatus status =
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
shouldSuppressStatus() ? PMSessionBeginPageNoDialog(session, format, 0)
|
||||
: PMSessionBeginPage(session, format, 0);
|
||||
#else
|
||||
PMSessionBeginPageNoDialog(session, format, 0);
|
||||
#endif
|
||||
if(status != noErr) {
|
||||
state = QPrinter::Error;
|
||||
return false;
|
||||
|
@ -150,11 +150,7 @@ public:
|
||||
QList<QVariant> supportedResolutions() const;
|
||||
inline bool isPrintSessionInitialized() const
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return session != 0;
|
||||
#else
|
||||
return printInfo != 0;
|
||||
#endif
|
||||
}
|
||||
bool shouldSuppressStatus() const;
|
||||
};
|
||||
|
@ -47,152 +47,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 };
|
||||
|
||||
#if defined(Q_WS_MAC32) && !defined(QT_MAC_USE_COCOA)
|
||||
#define RGN_CACHE_SIZE 200
|
||||
#ifdef RGN_CACHE_SIZE
|
||||
static bool rgncache_init = false;
|
||||
static int rgncache_used;
|
||||
static RgnHandle rgncache[RGN_CACHE_SIZE];
|
||||
static void qt_mac_cleanup_rgncache()
|
||||
{
|
||||
rgncache_init = false;
|
||||
for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
|
||||
if(rgncache[i]) {
|
||||
--rgncache_used;
|
||||
DisposeRgn(rgncache[i]);
|
||||
rgncache[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_WIDGETS_EXPORT RgnHandle qt_mac_get_rgn()
|
||||
{
|
||||
#ifdef RGN_CACHE_SIZE
|
||||
if(!rgncache_init) {
|
||||
rgncache_used = 0;
|
||||
rgncache_init = true;
|
||||
for(int i = 0; i < RGN_CACHE_SIZE; ++i)
|
||||
rgncache[i] = 0;
|
||||
qAddPostRoutine(qt_mac_cleanup_rgncache);
|
||||
} else if(rgncache_used) {
|
||||
for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
|
||||
if(rgncache[i]) {
|
||||
RgnHandle ret = rgncache[i];
|
||||
SetEmptyRgn(ret);
|
||||
rgncache[i] = 0;
|
||||
--rgncache_used;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NewRgn();
|
||||
}
|
||||
|
||||
Q_WIDGETS_EXPORT void qt_mac_dispose_rgn(RgnHandle r)
|
||||
{
|
||||
#ifdef RGN_CACHE_SIZE
|
||||
if(rgncache_init && rgncache_used < RGN_CACHE_SIZE) {
|
||||
for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
|
||||
if(!rgncache[i]) {
|
||||
++rgncache_used;
|
||||
rgncache[i] = r;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
DisposeRgn(r);
|
||||
}
|
||||
|
||||
static OSStatus qt_mac_get_rgn_rect(UInt16 msg, RgnHandle, const Rect *rect, void *reg)
|
||||
{
|
||||
if(msg == kQDRegionToRectsMsgParse) {
|
||||
QRect rct(rect->left, rect->top, (rect->right - rect->left), (rect->bottom - rect->top));
|
||||
if(!rct.isEmpty())
|
||||
*((QRegion *)reg) += rct;
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
Q_WIDGETS_EXPORT QRegion qt_mac_convert_mac_region(RgnHandle rgn)
|
||||
{
|
||||
return QRegion::fromQDRgn(rgn);
|
||||
}
|
||||
|
||||
QRegion QRegion::fromQDRgn(RgnHandle rgn)
|
||||
{
|
||||
QRegion ret;
|
||||
ret.detach();
|
||||
OSStatus oss = QDRegionToRects(rgn, kQDParseRegionFromTopLeft, qt_mac_get_rgn_rect, (void *)&ret);
|
||||
if(oss != noErr)
|
||||
return QRegion();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Create's a RegionHandle, it's the caller's responsibility to release.
|
||||
*/
|
||||
RgnHandle QRegion::toQDRgn() const
|
||||
{
|
||||
RgnHandle rgnHandle = qt_mac_get_rgn();
|
||||
if(d->qt_rgn && d->qt_rgn->numRects) {
|
||||
RgnHandle tmp_rgn = qt_mac_get_rgn();
|
||||
int n = d->qt_rgn->numRects;
|
||||
const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData();
|
||||
while (n--) {
|
||||
SetRectRgn(tmp_rgn,
|
||||
qMax(SHRT_MIN, qt_r->x()),
|
||||
qMax(SHRT_MIN, qt_r->y()),
|
||||
qMin(SHRT_MAX, qt_r->right() + 1),
|
||||
qMin(SHRT_MAX, qt_r->bottom() + 1));
|
||||
UnionRgn(rgnHandle, tmp_rgn, rgnHandle);
|
||||
++qt_r;
|
||||
}
|
||||
qt_mac_dispose_rgn(tmp_rgn);
|
||||
}
|
||||
return rgnHandle;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Create's a RegionHandle, it's the caller's responsibility to release.
|
||||
Returns 0 if the QRegion overflows.
|
||||
*/
|
||||
RgnHandle QRegion::toQDRgnForUpdate_sys() const
|
||||
{
|
||||
RgnHandle rgnHandle = qt_mac_get_rgn();
|
||||
if(d->qt_rgn && d->qt_rgn->numRects) {
|
||||
RgnHandle tmp_rgn = qt_mac_get_rgn();
|
||||
int n = d->qt_rgn->numRects;
|
||||
const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData();
|
||||
while (n--) {
|
||||
|
||||
// detect overflow. Tested for use with HIViewSetNeedsDisplayInRegion
|
||||
// in QWidgetPrivate::update_sys().
|
||||
enum { HIViewSetNeedsDisplayInRegionOverflow = 10000 }; // empirically determined conservative value
|
||||
if (qt_r->right() > HIViewSetNeedsDisplayInRegionOverflow || qt_r->bottom() > HIViewSetNeedsDisplayInRegionOverflow) {
|
||||
qt_mac_dispose_rgn(tmp_rgn);
|
||||
qt_mac_dispose_rgn(rgnHandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetRectRgn(tmp_rgn,
|
||||
qMax(SHRT_MIN, qt_r->x()),
|
||||
qMax(SHRT_MIN, qt_r->y()),
|
||||
qMin(SHRT_MAX, qt_r->right() + 1),
|
||||
qMin(SHRT_MAX, qt_r->bottom() + 1));
|
||||
UnionRgn(rgnHandle, tmp_rgn, rgnHandle);
|
||||
++qt_r;
|
||||
}
|
||||
qt_mac_dispose_rgn(tmp_rgn);
|
||||
}
|
||||
return rgnHandle;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
OSStatus QRegion::shape2QRegionHelper(int inMessage, HIShapeRef,
|
||||
@ -239,18 +93,10 @@ HIMutableShapeRef QRegion::toHIMutableShape() const
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QCFType<HIShapeRef> qdShape = HIShapeCreateWithQDRgn(QMacSmartQuickDrawRegion(toQDRgn()));
|
||||
HIShapeUnion(qdShape, shape, shape);
|
||||
#endif
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
#if !defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA)
|
||||
typedef OSStatus (*PtrHIShapeGetAsQDRgn)(HIShapeRef, RgnHandle);
|
||||
static PtrHIShapeGetAsQDRgn ptrHIShapeGetAsQDRgn = 0;
|
||||
#endif
|
||||
|
||||
|
||||
QRegion QRegion::fromHIShapeRef(HIShapeRef shape)
|
||||
@ -268,17 +114,6 @@ QRegion QRegion::fromHIShapeRef(HIShapeRef shape)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
#if !defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA)
|
||||
if (ptrHIShapeGetAsQDRgn == 0) {
|
||||
QLibrary library(QLatin1String("/System/Library/Frameworks/Carbon.framework/Carbon"));
|
||||
library.setLoadHints(QLibrary::ExportExternalSymbolsHint);
|
||||
ptrHIShapeGetAsQDRgn = reinterpret_cast<PtrHIShapeGetAsQDRgn>(library.resolve("HIShapeGetAsQDRgn"));
|
||||
}
|
||||
RgnHandle rgn = qt_mac_get_rgn();
|
||||
ptrHIShapeGetAsQDRgn(shape, rgn);
|
||||
returnRegion = QRegion::fromQDRgn(rgn);
|
||||
qt_mac_dispose_rgn(rgn);
|
||||
#endif
|
||||
}
|
||||
return returnRegion;
|
||||
}
|
||||
|
@ -93,11 +93,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// Cmd + left mousebutton should produce a right button
|
||||
// press (mainly for mac users with one-button mice):
|
||||
static bool qt_leftButtonIsRightButton = false;
|
||||
#endif
|
||||
|
||||
Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader);
|
||||
|
||||
@ -120,27 +118,17 @@ void QMacWindowFader::performFade()
|
||||
{
|
||||
const QWidgetList myWidgetsToFade = m_windowsToFade;
|
||||
const int widgetCount = myWidgetsToFade.count();
|
||||
#if QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
[NSAnimationContext beginGrouping];
|
||||
[[NSAnimationContext currentContext] setDuration:NSTimeInterval(m_duration)];
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < widgetCount; ++i) {
|
||||
QWidget *widget = m_windowsToFade.at(i);
|
||||
OSWindowRef window = qt_mac_window_for(widget);
|
||||
#if QT_MAC_USE_COCOA
|
||||
[[window animator] setAlphaValue:0.0];
|
||||
QTimer::singleShot(qRound(m_duration * 1000), widget, SLOT(hide()));
|
||||
#else
|
||||
TransitionWindowOptions options = {0, m_duration, 0, 0};
|
||||
TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction,
|
||||
0, 1, &options);
|
||||
#endif
|
||||
}
|
||||
#if QT_MAC_USE_COCOA
|
||||
[NSAnimationContext endGrouping];
|
||||
#endif
|
||||
m_duration = 0.250;
|
||||
m_windowsToFade.clear();
|
||||
}
|
||||
@ -154,22 +142,11 @@ extern void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
|
||||
|
||||
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
#endif
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
if (wnd) {
|
||||
QWidget *widget;
|
||||
#if QT_MAC_USE_COCOA
|
||||
widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)];
|
||||
#else
|
||||
const UInt32 kWidgetCreatorQt = kEventClassQt;
|
||||
enum {
|
||||
kWidgetPropertyQWidget = 'QWId' //QWidget *
|
||||
};
|
||||
if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr)
|
||||
widget = 0;
|
||||
#endif
|
||||
if (widget) {
|
||||
QMacWindowFader::currentFader()->setFadeDuration(durationSeconds);
|
||||
QMacWindowFader::currentFader()->registerWindowToFade(widget);
|
||||
@ -184,7 +161,7 @@ struct dndenum_mapper
|
||||
bool Qt2Mac;
|
||||
};
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA) && defined(__OBJC__)
|
||||
#ifdef __OBJC__
|
||||
|
||||
static dndenum_mapper dnd_enums[] = {
|
||||
{ NSDragOperationLink, Qt::LinkAction, true },
|
||||
@ -245,19 +222,12 @@ DnDParams *macCurrentDnDParameters()
|
||||
bool macWindowIsTextured( void * /*OSWindowRef*/ window )
|
||||
{
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
#if QT_MAC_USE_COCOA
|
||||
return ( [wnd styleMask] & NSTexturedBackgroundWindowMask ) ? true : false;
|
||||
#else
|
||||
WindowAttributes currentAttributes;
|
||||
GetWindowAttributes(wnd, ¤tAttributes);
|
||||
return (currentAttributes & kWindowMetalAttribute) ? true : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void macWindowToolbarShow(const QWidget *widget, bool show )
|
||||
{
|
||||
OSWindowRef wnd = qt_mac_window_for(widget);
|
||||
#if QT_MAC_USE_COCOA
|
||||
if (NSToolbar *toolbar = [wnd toolbar]) {
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
if (show != [toolbar isVisible]) {
|
||||
@ -267,65 +237,38 @@ void macWindowToolbarShow(const QWidget *widget, bool show )
|
||||
qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
|
||||
}
|
||||
}
|
||||
#else
|
||||
qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
|
||||
ShowHideWindowToolbar(wnd, show, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void macWindowToolbarSet( void * /*OSWindowRef*/ window, void *toolbarRef )
|
||||
{
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
#if QT_MAC_USE_COCOA
|
||||
[wnd setToolbar:static_cast<NSToolbar *>(toolbarRef)];
|
||||
#else
|
||||
SetWindowToolbar(wnd, static_cast<HIToolbarRef>(toolbarRef));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window )
|
||||
{
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
#if QT_MAC_USE_COCOA
|
||||
if (NSToolbar *toolbar = [wnd toolbar])
|
||||
return [toolbar isVisible];
|
||||
return false;
|
||||
#else
|
||||
return IsWindowToolbarVisible(wnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow )
|
||||
{
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
#if QT_MAC_USE_COCOA
|
||||
[wnd setHasShadow:BOOL(hasShadow)];
|
||||
#else
|
||||
if (hasShadow)
|
||||
ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
|
||||
else
|
||||
ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void macWindowFlush(void * /*OSWindowRef*/ window)
|
||||
{
|
||||
OSWindowRef wnd = static_cast<OSWindowRef>(window);
|
||||
#if QT_MAC_USE_COCOA
|
||||
[wnd flushWindowIfNeeded];
|
||||
#else
|
||||
HIWindowFlush(wnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_mac_update_mouseTracking(QWidget *widget)
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
[qt_mac_nativeview_for(widget) updateTrackingAreas];
|
||||
#else
|
||||
Q_UNUSED(widget);
|
||||
#endif
|
||||
}
|
||||
|
||||
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
|
||||
@ -352,13 +295,7 @@ InvalidContext:
|
||||
|
||||
bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
OSViewRef nativeSizeGrip = 0;
|
||||
HIViewFindByID(HIViewGetRoot(HIViewGetWindow(HIViewRef(widget->winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
|
||||
return (nativeSizeGrip != 0);
|
||||
#else
|
||||
return [[reinterpret_cast<NSView *>(widget->effectiveWinId()) window] showsResizeIndicator];
|
||||
#endif
|
||||
}
|
||||
struct qt_mac_enum_mapper
|
||||
{
|
||||
@ -426,7 +363,6 @@ QMacTabletHash *qt_mac_tablet_hash()
|
||||
return tablet_hash();
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
// Clears the QWidget pointer that each QCocoaView holds.
|
||||
void qt_mac_clearCocoaViewQWidgetPointers(QWidget *widget)
|
||||
@ -454,7 +390,6 @@ void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent)
|
||||
[proximityEvent isEnteringProximity] };
|
||||
qt_dispatchTabletProximityEvent(carbonProximityRec);
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
|
||||
{
|
||||
@ -527,7 +462,6 @@ void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
|
||||
qt_sendSpontaneousEvent(qApp, &qtabletProximity);
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
|
||||
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
|
||||
{
|
||||
@ -621,7 +555,6 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
|
||||
macScanCode, [event keyCode], [event modifierFlags]);
|
||||
return qt_sendSpontaneousEvent(widgetToGetEvent, &ke) && ke.isAccepted();
|
||||
}
|
||||
#endif
|
||||
|
||||
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
|
||||
{
|
||||
@ -640,11 +573,6 @@ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
|
||||
|
||||
bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_UNUSED(keyEvent);
|
||||
Q_UNUSED(widgetToGetEvent);
|
||||
return false;
|
||||
#else
|
||||
NSEvent *event = static_cast<NSEvent *>(keyEvent);
|
||||
EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
|
||||
Q_ASSERT(key_event);
|
||||
@ -667,15 +595,10 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
|
||||
|
||||
bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true);
|
||||
return consumed && (info != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget *widgetToGetEvent)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_UNUSED(flagsChangedEvent);
|
||||
Q_UNUSED(widgetToGetEvent);
|
||||
#else
|
||||
UInt32 modifiers = 0;
|
||||
// Sync modifiers with Qt
|
||||
NSEvent *event = static_cast<NSEvent *>(flagsChangedEvent);
|
||||
@ -685,7 +608,6 @@ void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget
|
||||
sizeof(modifiers), 0, &modifiers);
|
||||
extern void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object);
|
||||
qt_mac_send_modifiers_changed(modifiers, widgetToGetEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
QPointF flipPoint(const NSPoint &p)
|
||||
@ -703,7 +625,7 @@ NSPoint flipPoint(const QPointF &p)
|
||||
return NSMakePoint(p.x(), flipYCoordinate(p.y()));
|
||||
}
|
||||
|
||||
#if QT_MAC_USE_COCOA && __OBJC__
|
||||
#ifdef __OBJC__
|
||||
|
||||
void qt_mac_handleNonClientAreaMouseEvent(NSWindow *window, NSEvent *event)
|
||||
{
|
||||
@ -1116,11 +1038,6 @@ bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseBu
|
||||
|
||||
bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * */tabletEvent)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
Q_UNUSED(view);
|
||||
Q_UNUSED(tabletEvent);
|
||||
return false;
|
||||
#else
|
||||
QT_MANGLE_NAMESPACE(QCocoaView) *theView = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view);
|
||||
NSView *theNSView = static_cast<NSView *>(view);
|
||||
NSEvent *theTabletEvent = static_cast<NSEvent *>(tabletEvent);
|
||||
@ -1209,29 +1126,16 @@ bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * *
|
||||
|
||||
qt_sendSpontaneousEvent(widgetToGetMouse, &qtabletEvent);
|
||||
return qtabletEvent.isAccepted();
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics)
|
||||
{
|
||||
OSWindowRef theWindow = static_cast<OSWindowRef>(window);
|
||||
#if !defined(QT_MAC_USE_COCOA)
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
||||
::HIWindowSetContentBorderThickness(theWindow, &metrics);
|
||||
}
|
||||
# else
|
||||
Q_UNUSED(window);
|
||||
Q_UNUSED(metrics);
|
||||
# endif
|
||||
#else
|
||||
if ([theWindow styleMask] & NSTexturedBackgroundWindowMask)
|
||||
[theWindow setContentBorderThickness:metrics.top forEdge:NSMaxYEdge];
|
||||
[theWindow setContentBorderThickness:metrics.bottom forEdge:NSMinYEdge];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if QT_MAC_USE_COCOA
|
||||
void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget)
|
||||
{
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
@ -1294,9 +1198,7 @@ void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivat
|
||||
widget->originalDrawMethod = true;
|
||||
[theWindow display];
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
#if QT_MAC_USE_COCOA
|
||||
void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
|
||||
{
|
||||
if(!window)
|
||||
@ -1306,7 +1208,6 @@ void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
|
||||
NSToolbar *macToolbar = [theWindow toolbar];
|
||||
[macToolbar setShowsBaselineSeparator:show];
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
QStringList qt_mac_NSArrayToQStringList(void *nsarray)
|
||||
{
|
||||
@ -1326,7 +1227,6 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if QT_MAC_USE_COCOA
|
||||
void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
|
||||
{
|
||||
if (!widgetForWindow)
|
||||
@ -1351,7 +1251,6 @@ void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
|
||||
|
||||
[window setShowsToolbarButton:uint(flags & Qt::MacWindowToolBarButtonHint) != 0];
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
// Carbon: Make sure you call QDEndContext on the context when done with it.
|
||||
CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
|
||||
@ -1359,13 +1258,7 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
|
||||
if (!widget)
|
||||
return 0;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
CGContextRef context;
|
||||
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
|
||||
QDBeginCGContext(port, &context);
|
||||
#else
|
||||
CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort];
|
||||
#endif
|
||||
return context;
|
||||
}
|
||||
|
||||
@ -1373,20 +1266,12 @@ void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
|
||||
{
|
||||
if (!widget)
|
||||
return;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HIViewRender(qt_mac_nativeview_for(widget));
|
||||
#else
|
||||
[qt_mac_nativeview_for(widget) displayIfNeeded];
|
||||
#endif
|
||||
}
|
||||
|
||||
CGFloat qt_mac_get_scalefactor()
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return HIGetScaleFactor();
|
||||
#else
|
||||
return [[NSScreen mainScreen] userSpaceScaleFactor];
|
||||
#endif
|
||||
}
|
||||
|
||||
QString qt_mac_get_pasteboardString(OSPasteboardRef paste)
|
||||
@ -1455,10 +1340,8 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI
|
||||
|
||||
void qt_mac_post_retranslateAppMenu()
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
|
||||
#endif
|
||||
}
|
||||
|
||||
QWidgetPrivate *QMacScrollOptimization::_target = 0;
|
||||
@ -1467,7 +1350,6 @@ int QMacScrollOptimization::_dx = 0;
|
||||
int QMacScrollOptimization::_dy = 0;
|
||||
QRect QMacScrollOptimization::_scrollRect = QRect(0, 0, -1, -1);
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// This method implements the magic for the drawRectSpecial method.
|
||||
// We draw a line at the upper edge of the content view in order to
|
||||
// override the title baseline.
|
||||
@ -1558,6 +1440,5 @@ void qt_mac_setNeedsDisplayInRect(QWidget *widget, QRegion region)
|
||||
|
||||
}
|
||||
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -45,27 +45,14 @@
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
static CTFontRef CopyCTThemeFont(ThemeFontID themeID)
|
||||
{
|
||||
CTFontUIFontType ctID = HIThemeGetUIFontType(themeID);
|
||||
return CTFontCreateUIFontForLanguage(ctID, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
QFont qfontForThemeFont(ThemeFontID themeID)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static const ScriptCode Script = smRoman;
|
||||
Str255 f_name;
|
||||
SInt16 f_size;
|
||||
Style f_style;
|
||||
GetThemeFont(themeID, Script, f_name, &f_size, &f_style);
|
||||
extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp
|
||||
return QFont(qt_mac_from_pascal_string(f_name), f_size,
|
||||
(f_style & ::bold) ? QFont::Bold : QFont::Normal,
|
||||
(bool)(f_style & ::italic));
|
||||
#else
|
||||
QCFType<CTFontRef> ctfont = CopyCTThemeFont(themeID);
|
||||
QString familyName = QCFString(CTFontCopyFamilyName(ctfont));
|
||||
QCFType<CFDictionaryRef> dict = CTFontCopyTraits(ctfont);
|
||||
@ -77,7 +64,6 @@ QFont qfontForThemeFont(ThemeFontID themeID)
|
||||
CFNumberGetValue(num, kCFNumberFloatType, &fW);
|
||||
bool italic = (fW != 0.0);
|
||||
return QFont(familyName, CTFontGetSize(ctfont), wght, italic);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
@ -110,20 +96,7 @@ static inline QColor leopardBrush(ThemeBrush brush)
|
||||
|
||||
QColor qcolorForTheme(ThemeBrush brush)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
||||
return leopardBrush(brush);
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
RGBColor rgbcolor;
|
||||
GetThemeBrushAsColor(brush, 32, true, &rgbcolor);
|
||||
return QColor(rgbcolor.red / 256, rgbcolor.green / 256, rgbcolor.blue / 256);
|
||||
}
|
||||
#else
|
||||
return leopardBrush(brush);
|
||||
#endif
|
||||
}
|
||||
|
||||
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
|
||||
|
@ -57,9 +57,7 @@
|
||||
|
||||
#ifdef __OBJC__
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#include <objc/runtime.h>
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
@ -566,11 +566,7 @@ void QTextEngine::shapeTextMac(int item) const
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QFontEngineMacMulti *fe = static_cast<QFontEngineMacMulti *>(font);
|
||||
#else
|
||||
QCoreTextFontEngineMulti *fe = static_cast<QCoreTextFontEngineMulti *>(font);
|
||||
#endif
|
||||
QTextEngine::ShaperFlags flags;
|
||||
if (si.analysis.bidiLevel % 2)
|
||||
flags |= RightToLeft;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -741,11 +741,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
|
||||
break;
|
||||
case QStyle::CT_MenuBar:
|
||||
if (sz == QAquaSizeLarge) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
SInt16 size;
|
||||
if (!GetThemeMenuBarHeight(&size))
|
||||
ret = QSize(-1, size);
|
||||
#else
|
||||
ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
|
||||
// In the qt_mac_set_native_menubar(false) case,
|
||||
// we come it here with a zero-height main menu,
|
||||
@ -753,7 +748,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
|
||||
// Use 22 pixels for the height, by observation.
|
||||
if (ret.height() <= 0)
|
||||
ret.setHeight(22);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1133,11 +1133,7 @@ void QCompleter::setPopup(QAbstractItemView *popup)
|
||||
delete d->popup;
|
||||
if (popup->model() != d->proxy)
|
||||
popup->setModel(d->proxy);
|
||||
#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
popup->show();
|
||||
#else
|
||||
popup->hide();
|
||||
#endif
|
||||
|
||||
Qt::FocusPolicy origPolicy = Qt::NoFocus;
|
||||
if (d->widget)
|
||||
|
@ -188,12 +188,8 @@ void QSystemTrayIconPrivate::updateIcon_sys()
|
||||
{
|
||||
if(sys && !icon.isNull()) {
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
const short scale = GetMBarHeight()-4;
|
||||
#else
|
||||
CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
|
||||
const short scale = hgt - 4;
|
||||
#endif
|
||||
NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
|
||||
[(NSImageView*)[[sys->item item] view] setImage: nsimage];
|
||||
[nsimage release];
|
||||
@ -321,12 +317,8 @@ QT_END_NAMESPACE
|
||||
down = NO;
|
||||
|
||||
if( ![self icon]->icon().isNull() ) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
const short scale = GetMBarHeight()-4;
|
||||
#else
|
||||
CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
|
||||
const short scale = hgt - 4;
|
||||
#endif
|
||||
NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
|
||||
[self setImage: nsimage];
|
||||
[nsimage release];
|
||||
@ -344,12 +336,8 @@ QT_END_NAMESPACE
|
||||
int clickCount = [mouseEvent clickCount];
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
const short scale = GetMBarHeight()-4;
|
||||
#else
|
||||
CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
|
||||
const short scale = hgt - 4;
|
||||
#endif
|
||||
|
||||
if (![self icon]->icon().isNull() ) {
|
||||
NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
|
||||
@ -453,10 +441,6 @@ QT_END_NAMESPACE
|
||||
qtsystray_sendActivated(icon, QSystemTrayIcon::Trigger);
|
||||
|
||||
if (icon->contextMenu()) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
[[[self item] view] removeAllToolTips];
|
||||
iconPrivate->updateToolTip_sys();
|
||||
#endif
|
||||
NSMenu *m = [[QT_MANGLE_NAMESPACE(QNSMenu) alloc] initWithQMenu:icon->contextMenu()];
|
||||
[m setAutoenablesItems: NO];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:imageCell
|
||||
@ -533,11 +517,7 @@ private:
|
||||
[item setToolTip:(NSString*)QCFString::toCFStringRef(action->toolTip())];
|
||||
const QIcon icon = action->icon();
|
||||
if(!icon.isNull()) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
const short scale = GetMBarHeight();
|
||||
#else
|
||||
const short scale = [[NSApp mainMenu] menuBarHeight];
|
||||
#endif
|
||||
NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
|
||||
[item setImage: nsimage];
|
||||
[nsimage release];
|
||||
|
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#import <private/qcocoatoolbardelegate_mac_p.h>
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#include <private/qmainwindowlayout_p.h>
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
@ -150,4 +149,3 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
|
||||
}
|
||||
|
||||
@end
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
@ -51,7 +51,6 @@
|
||||
//
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -68,4 +67,3 @@ QT_END_NAMESPACE
|
||||
|
||||
- (id)initWithMainWindowLayout:(QT_PREPEND_NAMESPACE(QMainWindowLayout) *)layout;
|
||||
@end
|
||||
#endif
|
||||
|
@ -2064,7 +2064,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
|
||||
}
|
||||
j++;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef Q_WS_MAC
|
||||
sepWidget->raise();
|
||||
#endif
|
||||
QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
|
||||
@ -3178,7 +3178,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const
|
||||
}
|
||||
j++;
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef Q_WS_MAC
|
||||
sepWidget->raise();
|
||||
#endif
|
||||
QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
|
||||
|
@ -1034,11 +1034,6 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
|
||||
|
||||
q->setWindowFlags(flags);
|
||||
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
|
||||
ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!rect.isNull())
|
||||
q->setGeometry(rect);
|
||||
|
@ -96,28 +96,18 @@ class QMacCocoaViewContainerPrivate : public QWidgetPrivate
|
||||
Q_DECLARE_PUBLIC(QMacCocoaViewContainer)
|
||||
public:
|
||||
NSView *nsview;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HIViewRef wrapperView;
|
||||
#endif
|
||||
QMacCocoaViewContainerPrivate();
|
||||
~QMacCocoaViewContainerPrivate();
|
||||
};
|
||||
|
||||
QMacCocoaViewContainerPrivate::QMacCocoaViewContainerPrivate()
|
||||
: nsview(0)
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
, wrapperView(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate()
|
||||
{
|
||||
[nsview release];
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (wrapperView)
|
||||
CFRelease(wrapperView);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -168,20 +158,7 @@ void QMacCocoaViewContainer::setCocoaView(void *cocoaViewToWrap)
|
||||
destroy(true, true);
|
||||
[view retain];
|
||||
d->nsview = view;
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5) {
|
||||
qWarning("QMacCocoaViewContainer::setCocoaView: You cannot use this class with Carbon on versions of Mac OS X less than 10.5.");
|
||||
return;
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (d->wrapperView)
|
||||
CFRelease(d->wrapperView);
|
||||
HICocoaViewCreate(d->nsview, 0, &d->wrapperView);
|
||||
create(WId(d->wrapperView), false, true);
|
||||
#endif
|
||||
#else
|
||||
create(WId(d->nsview), false, true);
|
||||
#endif
|
||||
[oldView release];
|
||||
}
|
||||
|
||||
|
@ -1442,13 +1442,11 @@ bool QMainWindow::event(QEvent *event)
|
||||
// We are coming out of a minimize, leave things as is.
|
||||
d->layout->blockVisiblityCheck = true;
|
||||
}
|
||||
# ifdef QT_MAC_USE_COCOA
|
||||
// We need to update the HIToolbar status when we go out of or into fullscreen.
|
||||
QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event);
|
||||
if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) {
|
||||
d->layout->updateHIToolBarStatus();
|
||||
}
|
||||
# endif // Cocoa
|
||||
}
|
||||
break;
|
||||
#endif // Q_WS_MAC
|
||||
@ -1506,16 +1504,13 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
|
||||
d->useHIToolBar = set;
|
||||
createWinId(); // We need the hiview for down below.
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// Activate the unified toolbar with the raster engine.
|
||||
if (windowSurface() && set) {
|
||||
d->layout->unifiedSurface = new QUnifiedToolbarSurface(this);
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
d->layout->updateHIToolBarStatus();
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// Deactivate the unified toolbar with the raster engine.
|
||||
if (windowSurface() && !set) {
|
||||
if (d->layout->unifiedSurface) {
|
||||
@ -1523,7 +1518,6 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
|
||||
d->layout->unifiedSurface = 0;
|
||||
}
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
// Enabling the unified toolbar clears the opaque size grip setting, update it.
|
||||
d->macUpdateOpaqueSizeGrip();
|
||||
|
@ -45,12 +45,8 @@
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#include <private/qtoolbar_p.h>
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#include <Carbon/Carbon.h>
|
||||
#else
|
||||
#include <private/qcocoatoolbardelegate_mac_p.h>
|
||||
#import <private/qcocoawindowdelegate_mac_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
#ifdef QT_NAMESPACE
|
||||
@ -63,12 +59,7 @@ QT_BEGIN_NAMESPACE
|
||||
#define SNSToolbar "com.trolltech.qt-" S0(QT_NAMESPACE) ".qtoolbarInNSToolbar"
|
||||
#define MacToolbar "com.trolltech.qt-" S0(QT_NAMESPACE) ".qmainwindow.mactoolbar"
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static CFStringRef kQToolBarHIToolbarItemClassID = CFSTR(S);
|
||||
static CFStringRef kQToolBarHIToolbarIdentifier = CFSTR(SToolbar);
|
||||
#else
|
||||
static NSString *kQToolBarNSToolbarIdentifier = @SNSToolbar;
|
||||
#endif
|
||||
static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar);
|
||||
#undef SS
|
||||
#undef S0
|
||||
@ -77,249 +68,11 @@ static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar);
|
||||
#undef SNSToolbar
|
||||
#undef MacToolbar
|
||||
|
||||
#else
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
static CFStringRef kQToolBarHIToolbarItemClassID = CFSTR("com.trolltech.qt.qmainwindow.qtoolbarInHIToolbar");
|
||||
static CFStringRef kQToolBarHIToolbarIdentifier = CFSTR("com.trolltech.qt.hitoolbar-qtoolbar");
|
||||
#else
|
||||
static NSString *kQToolBarNSToolbarIdentifier = @"com.trolltech.qt.qmainwindow.qtoolbarInNSToolbar";
|
||||
#endif
|
||||
static CFStringRef kQMainWindowMacToolbarID = CFSTR("com.trolltech.qt.qmainwindow.mactoolbar");
|
||||
#endif // QT_NAMESPACE
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
|
||||
static const int kEventParamQToolBar = 'QTBR';
|
||||
static const int kEventParamQMainWindowLayout = 'QMWL';
|
||||
|
||||
const EventTypeSpec qtoolbarEvents[] =
|
||||
{
|
||||
{ kEventClassHIObject, kEventHIObjectConstruct },
|
||||
{ kEventClassHIObject, kEventHIObjectDestruct },
|
||||
{ kEventClassHIObject, kEventHIObjectInitialize },
|
||||
{ kEventClassToolbarItem, kEventToolbarItemCreateCustomView }
|
||||
};
|
||||
|
||||
struct QToolBarInHIToolbarInfo
|
||||
{
|
||||
QToolBarInHIToolbarInfo(HIToolbarItemRef item)
|
||||
: toolbarItem(item), mainWindowLayout(0)
|
||||
{}
|
||||
HIToolbarItemRef toolbarItem;
|
||||
QMainWindowLayout *mainWindowLayout;
|
||||
};
|
||||
|
||||
OSStatus QMainWindowLayout::qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef,
|
||||
EventRef event, void *data)
|
||||
{
|
||||
OSStatus result = eventNotHandledErr;
|
||||
QToolBarInHIToolbarInfo *object = static_cast<QToolBarInHIToolbarInfo *>(data);
|
||||
|
||||
switch (GetEventClass(event)) {
|
||||
case kEventClassHIObject:
|
||||
switch (GetEventKind(event)) {
|
||||
case kEventHIObjectConstruct:
|
||||
{
|
||||
HIObjectRef toolbarItem;
|
||||
GetEventParameter(event, kEventParamHIObjectInstance, typeHIObjectRef,
|
||||
0, sizeof( HIObjectRef ), 0, &toolbarItem);
|
||||
|
||||
QToolBarInHIToolbarInfo *item = new QToolBarInHIToolbarInfo(toolbarItem);
|
||||
SetEventParameter(event, kEventParamHIObjectInstance, typeVoidPtr,
|
||||
sizeof(void *), &item);
|
||||
result = noErr;
|
||||
}
|
||||
break;
|
||||
case kEventHIObjectInitialize:
|
||||
result = CallNextEventHandler(inCallRef, event);
|
||||
if (result == noErr) {
|
||||
QToolBar *toolbar = 0;
|
||||
QMainWindowLayout *layout = 0;
|
||||
GetEventParameter(event, kEventParamQToolBar, typeVoidPtr,
|
||||
0, sizeof(void *), 0, &toolbar);
|
||||
GetEventParameter(event, kEventParamQMainWindowLayout, typeVoidPtr,
|
||||
0, sizeof(void *), 0, &layout);
|
||||
object->mainWindowLayout = layout;
|
||||
object->mainWindowLayout->unifiedToolbarHash.insert(object->toolbarItem, toolbar);
|
||||
HIToolbarItemChangeAttributes(object->toolbarItem,
|
||||
kHIToolbarItemLabelDisabled, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case kEventHIObjectDestruct:
|
||||
delete object;
|
||||
result = noErr;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case kEventClassToolbarItem:
|
||||
switch (GetEventKind(event))
|
||||
{
|
||||
case kEventToolbarItemCreateCustomView:
|
||||
{
|
||||
QToolBar *toolbar
|
||||
= object->mainWindowLayout->unifiedToolbarHash.value(object->toolbarItem);
|
||||
if (toolbar) {
|
||||
HIViewRef hiview = HIViewRef(toolbar->winId());
|
||||
SetEventParameter(event, kEventParamControlRef, typeControlRef,
|
||||
sizeof(HIViewRef), &hiview);
|
||||
result = noErr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QMainWindowLayout::qtMacHIToolbarRegisterQToolBarInHIToolborItemClass()
|
||||
{
|
||||
static bool registered = false;
|
||||
|
||||
if (!registered) {
|
||||
HIObjectRegisterSubclass( kQToolBarHIToolbarItemClassID,
|
||||
kHIToolbarItemClassID, 0, QMainWindowLayout::qtoolbarInHIToolbarHandler,
|
||||
GetEventTypeCount(qtoolbarEvents), qtoolbarEvents, 0, 0 );
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void GetToolbarAllowedItems(CFMutableArrayRef array)
|
||||
{
|
||||
CFArrayAppendValue(array, kQToolBarHIToolbarIdentifier);
|
||||
}
|
||||
|
||||
HIToolbarItemRef QMainWindowLayout::createQToolBarInHIToolbarItem(QToolBar *toolbar,
|
||||
QMainWindowLayout *layout)
|
||||
{
|
||||
QMainWindowLayout::qtMacHIToolbarRegisterQToolBarInHIToolborItemClass();
|
||||
|
||||
EventRef event;
|
||||
HIToolbarItemRef result = 0;
|
||||
|
||||
CFStringRef identifier = kQToolBarHIToolbarIdentifier;
|
||||
UInt32 options = kHIToolbarItemAllowDuplicates;
|
||||
|
||||
CreateEvent(0, kEventClassHIObject, kEventHIObjectInitialize,
|
||||
GetCurrentEventTime(), 0, &event);
|
||||
SetEventParameter(event, kEventParamToolbarItemIdentifier, typeCFStringRef,
|
||||
sizeof(CFStringRef), &identifier);
|
||||
SetEventParameter(event, kEventParamAttributes, typeUInt32, sizeof(UInt32), &options);
|
||||
SetEventParameter(event, kEventParamQToolBar, typeVoidPtr, sizeof(void *), &toolbar);
|
||||
SetEventParameter(event, kEventParamQMainWindowLayout, typeVoidPtr, sizeof(void *), &layout);
|
||||
|
||||
HIObjectCreate(kQToolBarHIToolbarItemClassID, event,
|
||||
static_cast<HIObjectRef *>(&result));
|
||||
|
||||
ReleaseEvent(event);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
HIToolbarItemRef QMainWindowLayout::CreateToolbarItemForIdentifier(CFStringRef identifier,
|
||||
CFTypeRef data)
|
||||
{
|
||||
HIToolbarItemRef item = 0;
|
||||
if (CFStringCompare(kQToolBarHIToolbarIdentifier, identifier,
|
||||
kCFCompareBackwards) == kCFCompareEqualTo) {
|
||||
if (data && CFGetTypeID(data) == CFArrayGetTypeID()) {
|
||||
CFArrayRef array = static_cast<CFArrayRef>(data);
|
||||
QToolBar *toolbar = static_cast<QToolBar *>(const_cast<void *>(CFArrayGetValueAtIndex(array, 0)));
|
||||
QMainWindowLayout *layout = static_cast<QMainWindowLayout *>(const_cast<void *>(CFArrayGetValueAtIndex(array, 1)));
|
||||
item = createQToolBarInHIToolbarItem(toolbar, layout);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
static const EventTypeSpec kToolbarEvents[] = {
|
||||
{ kEventClassToolbar, kEventToolbarGetDefaultIdentifiers },
|
||||
{ kEventClassToolbar, kEventToolbarGetAllowedIdentifiers },
|
||||
{ kEventClassToolbar, kEventToolbarCreateItemWithIdentifier },
|
||||
{ kEventClassToolbar, kEventToolbarItemAdded },
|
||||
{ kEventClassToolbar, kEventToolbarItemRemoved }
|
||||
};
|
||||
|
||||
OSStatus QMainWindowLayout::qtmacToolbarDelegate(EventHandlerCallRef, EventRef event, void *data)
|
||||
{
|
||||
QMainWindowLayout *mainWindowLayout = static_cast<QMainWindowLayout *>(data);
|
||||
OSStatus result = eventNotHandledErr;
|
||||
CFMutableArrayRef array;
|
||||
CFStringRef identifier;
|
||||
switch (GetEventKind(event)) {
|
||||
case kEventToolbarGetDefaultIdentifiers:
|
||||
case kEventToolbarGetAllowedIdentifiers:
|
||||
GetEventParameter(event, kEventParamMutableArray, typeCFMutableArrayRef, 0,
|
||||
sizeof(CFMutableArrayRef), 0, &array);
|
||||
GetToolbarAllowedItems(array);
|
||||
result = noErr;
|
||||
break;
|
||||
case kEventToolbarCreateItemWithIdentifier: {
|
||||
HIToolbarItemRef item;
|
||||
CFTypeRef data = 0;
|
||||
OSStatus err = GetEventParameter(event, kEventParamToolbarItemIdentifier, typeCFStringRef,
|
||||
0, sizeof(CFStringRef), 0, &identifier);
|
||||
err = GetEventParameter(event, kEventParamToolbarItemConfigData, typeCFTypeRef,
|
||||
0, sizeof(CFTypeRef), 0, &data);
|
||||
item = CreateToolbarItemForIdentifier(identifier, data);
|
||||
if (item) {
|
||||
result = SetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
|
||||
sizeof(HIToolbarItemRef), &item );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kEventToolbarItemAdded: {
|
||||
// Double check that our "view" of the toolbar is similar.
|
||||
HIToolbarItemRef item;
|
||||
CFIndex index;
|
||||
if (GetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
|
||||
0, sizeof(HIToolbarItemRef), 0, &item) == noErr
|
||||
&& GetEventParameter(event, kEventParamIndex, typeCFIndex, 0,
|
||||
sizeof(CFIndex), 0, &index) == noErr) {
|
||||
CFRetain(item); // We will watch this until it's removed from the list (or bust).
|
||||
mainWindowLayout->toolbarItemsCopy.insert(index, item);
|
||||
QToolBar *toolbar = mainWindowLayout->unifiedToolbarHash.value(item);
|
||||
if (toolbar) {
|
||||
int toolbarIndex = mainWindowLayout->qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
|
||||
if (index != toolbarIndex) {
|
||||
// Dang, we must be out of sync, rebuild it from the "toolbarItemsCopy"
|
||||
mainWindowLayout->qtoolbarsInUnifiedToolbarList.clear();
|
||||
for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
|
||||
// This will either append the correct toolbar or an
|
||||
// null toolbar. This is fine because this list
|
||||
// is really only kept to make sure that things are but in the right order.
|
||||
mainWindowLayout->qtoolbarsInUnifiedToolbarList.append(
|
||||
mainWindowLayout->unifiedToolbarHash.value(mainWindowLayout->
|
||||
toolbarItemsCopy.at(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kEventToolbarItemRemoved: {
|
||||
HIToolbarItemRef item;
|
||||
if (GetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
|
||||
0, sizeof(HIToolbarItemRef), 0, &item) == noErr) {
|
||||
mainWindowLayout->unifiedToolbarHash.remove(item);
|
||||
for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
|
||||
if (mainWindowLayout->toolbarItemsCopy.at(i) == item) {
|
||||
// I know about it, so release it.
|
||||
mainWindowLayout->toolbarItemsCopy.removeAt(i);
|
||||
mainWindowLayout->qtoolbarsInUnifiedToolbarList.removeAt(i);
|
||||
CFRelease(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif // ! QT_MAC_USE_COCOA
|
||||
|
||||
#ifndef kWindowUnifiedTitleAndToolbarAttribute
|
||||
#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7)
|
||||
@ -328,18 +81,8 @@ OSStatus QMainWindowLayout::qtmacToolbarDelegate(EventHandlerCallRef, EventRef e
|
||||
void QMainWindowLayout::updateHIToolBarStatus()
|
||||
{
|
||||
bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac();
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
if (useMacToolbar) {
|
||||
ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
|
||||
kWindowUnifiedTitleAndToolbarAttribute, 0);
|
||||
} else {
|
||||
ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
|
||||
0, kWindowUnifiedTitleAndToolbarAttribute);
|
||||
}
|
||||
#endif
|
||||
|
||||
layoutState.mainWindow->setUpdatesEnabled(false); // reduces a little bit of flicker, not all though
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView];
|
||||
if (useMacToolbar) {
|
||||
@ -349,16 +92,13 @@ void QMainWindowLayout::updateHIToolBarStatus()
|
||||
name: NSViewFrameDidChangeNotification
|
||||
object: cView];
|
||||
}
|
||||
#endif
|
||||
if (!useMacToolbar) {
|
||||
macWindowToolbarShow(layoutState.mainWindow, false);
|
||||
// Move everything out of the HIToolbar into the main toolbar.
|
||||
while (!qtoolbarsInUnifiedToolbarList.isEmpty()) {
|
||||
// Should shrink the list by one every time.
|
||||
QToolBar *toolbar = qtoolbarsInUnifiedToolbarList.first();
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
unifiedSurface->removeToolbar(toolbar);
|
||||
#endif
|
||||
layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar);
|
||||
}
|
||||
macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0);
|
||||
@ -374,14 +114,12 @@ void QMainWindowLayout::updateHIToolBarStatus()
|
||||
}
|
||||
syncUnifiedToolbarVisibility();
|
||||
}
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
if (!useMacToolbar) {
|
||||
[cView setPostsFrameChangedNotifications:NO];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate]
|
||||
name: NSViewFrameDidChangeNotification
|
||||
object: cView];
|
||||
}
|
||||
#endif
|
||||
layoutState.mainWindow->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
@ -392,7 +130,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
|
||||
if (toolbar == 0)
|
||||
return;
|
||||
|
||||
#if defined(QT_MAC_USE_COCOA)
|
||||
// toolbar will now become native (if not already) since we need
|
||||
// an nsview for it inside the corresponding NSToolbarItem.
|
||||
// Setting isInUnifiedToolbar will (among other things) stop alien
|
||||
@ -402,7 +139,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
|
||||
// that either the menubar must be alien again, or the sibling must
|
||||
// be backed by an nsview to protect from overlapping issues:
|
||||
toolbar->d_func()->isInUnifiedToolbar = true;
|
||||
#endif
|
||||
|
||||
QToolBarLayout *toolbarLayout = static_cast<QToolBarLayout *>(toolbar->layout());
|
||||
toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(), toolbar->maximumSize()));
|
||||
@ -425,22 +161,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
|
||||
|
||||
int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HIToolbarRef macToolbar = NULL;
|
||||
if ((GetWindowToolbar(window, &macToolbar) == noErr) && !macToolbar) {
|
||||
HIToolbarCreate(kQMainWindowMacToolbarID,
|
||||
kHIToolbarItemAllowDuplicates, &macToolbar);
|
||||
InstallEventHandler(HIObjectGetEventTarget(static_cast<HIToolbarRef>(macToolbar)),
|
||||
QMainWindowLayout::qtmacToolbarDelegate, GetEventTypeCount(kToolbarEvents),
|
||||
kToolbarEvents, this, 0);
|
||||
HIToolbarSetDisplaySize(macToolbar, kHIToolbarDisplaySizeNormal);
|
||||
HIToolbarSetDisplayMode(macToolbar, kHIToolbarDisplayModeIconOnly);
|
||||
macWindowToolbarSet(window, macToolbar);
|
||||
if (layoutState.mainWindow->isVisible())
|
||||
macWindowToolbarShow(layoutState.mainWindow, true);
|
||||
CFRelease(macToolbar);
|
||||
}
|
||||
#else
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSToolbar *macToolbar = [window toolbar];
|
||||
if (macToolbar == nil) {
|
||||
@ -451,14 +171,9 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
|
||||
[window setToolbar:macToolbar];
|
||||
[macToolbar release];
|
||||
}
|
||||
#endif
|
||||
if (toolbarIndex != -1) {
|
||||
qtoolbarsInUnifiedToolbarList.removeAt(toolbarIndex);
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HIToolbarRemoveItemAtIndex(macToolbar, toolbarIndex);
|
||||
#else
|
||||
[macToolbar removeItemAtIndex:toolbarIndex];
|
||||
#endif
|
||||
}
|
||||
qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar);
|
||||
|
||||
@ -468,28 +183,15 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
|
||||
for (int i = 0; i < beforeIndex; ++i) {
|
||||
offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width());
|
||||
}
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
unifiedSurface->insertToolbar(toolbar, offset);
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
QCFType<HIToolbarItemRef> outItem;
|
||||
const QObject *stupidArray[] = { toolbar, this };
|
||||
QCFType<CFArrayRef> array = CFArrayCreate(0, reinterpret_cast<const void **>(&stupidArray),
|
||||
2, 0);
|
||||
HIToolbarCreateItemWithIdentifier(macToolbar, kQToolBarHIToolbarIdentifier,
|
||||
array, &outItem);
|
||||
HIToolbarInsertItemAtIndex(macToolbar, outItem, beforeIndex);
|
||||
#else
|
||||
NSString *toolbarID = kQToolBarNSToolbarIdentifier;
|
||||
toolbarID = [toolbarID stringByAppendingFormat:@"%p", toolbar];
|
||||
cocoaItemIDToToolbarHash.insert(qt_mac_NSStringToQString(toolbarID), toolbar);
|
||||
[macToolbar insertItemWithItemIdentifier:toolbarID atIndex:beforeIndex];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
void QMainWindowLayout::updateUnifiedToolbarOffset()
|
||||
{
|
||||
QPoint offset(0, 0);
|
||||
@ -499,7 +201,6 @@ void QMainWindowLayout::updateUnifiedToolbarOffset()
|
||||
qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset;
|
||||
}
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
|
||||
void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
|
||||
@ -517,17 +218,11 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
|
||||
toolbar->setMovable(saveState.movable);
|
||||
toolbar->setMaximumSize(saveState.maximumSize);
|
||||
toolbarSaveState.remove(toolbar);
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
HIToolbarItemRef item = static_cast<HIToolbarItemRef>(it.key());
|
||||
HIToolbarRemoveItemAtIndex(HIToolbarItemGetToolbar(item),
|
||||
toolbarItemsCopy.indexOf(item));
|
||||
#else
|
||||
NSToolbarItem *item = static_cast<NSToolbarItem *>(it.key());
|
||||
[[qt_mac_window_for(layoutState.mainWindow->window()) toolbar]
|
||||
removeItemAtIndex:toolbarItemsCopy.indexOf(item)];
|
||||
unifiedToolbarHash.remove(item);
|
||||
qtoolbarsInUnifiedToolbarList.removeAll(toolbar);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
@ -536,32 +231,25 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
|
||||
|
||||
void QMainWindowLayout::cleanUpMacToolbarItems()
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
#endif
|
||||
for (int i = 0; i < toolbarItemsCopy.size(); ++i) {
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
NSToolbarItem *item = static_cast<NSToolbarItem *>(toolbarItemsCopy.at(i));
|
||||
[item setView:0];
|
||||
#endif
|
||||
CFRelease(toolbarItemsCopy.at(i));
|
||||
}
|
||||
toolbarItemsCopy.clear();
|
||||
unifiedToolbarHash.clear();
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
OSWindowRef window = qt_mac_window_for(layoutState.mainWindow);
|
||||
NSToolbar *macToolbar = [window toolbar];
|
||||
if (macToolbar) {
|
||||
[[macToolbar delegate] release];
|
||||
[macToolbar setDelegate:nil];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
|
||||
{
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QHash<void *, QToolBar *>::const_iterator it = unifiedToolbarHash.constBegin();
|
||||
NSToolbarItem *item = nil;
|
||||
while (it != unifiedToolbarHash.constEnd()) {
|
||||
@ -582,9 +270,6 @@ void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
|
||||
nssize.height = size.height();
|
||||
[item setMinSize:nssize];
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(tb);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QMainWindowLayout::syncUnifiedToolbarVisibility()
|
||||
|
@ -85,9 +85,7 @@ typedef HIObjectRef HIToolbarItemRef;
|
||||
typedef const void * CFTypeRef;
|
||||
typedef const struct __CFString * CFStringRef;
|
||||
|
||||
# ifdef QT_MAC_USE_COCOA
|
||||
#include <private/qunifiedtoolbarsurface_mac_p.h>
|
||||
# endif // QT_MAC_USE_COCOA
|
||||
|
||||
#endif // Q_WS_MAC
|
||||
|
||||
@ -312,7 +310,6 @@ private:
|
||||
void updateTabBarShapes();
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
# ifndef QT_MAC_USE_COCOA
|
||||
static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *);
|
||||
static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event,
|
||||
void *data);
|
||||
@ -320,7 +317,6 @@ private:
|
||||
static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data);
|
||||
static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar,
|
||||
QMainWindowLayout *layout);
|
||||
# endif
|
||||
public:
|
||||
struct ToolBarSaveState {
|
||||
ToolBarSaveState() : movable(false) { }
|
||||
@ -343,10 +339,8 @@ public:
|
||||
void syncUnifiedToolbarVisibility();
|
||||
bool blockVisiblityCheck;
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QUnifiedToolbarSurface *unifiedSurface;
|
||||
void updateUnifiedToolbarOffset();
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
|
||||
#endif // Q_WS_MAC
|
||||
};
|
||||
|
@ -100,7 +100,6 @@ void QTabBarPrivate::updateMacBorderMetrics()
|
||||
metrics.left = 0;
|
||||
metrics.right = 0;
|
||||
qt_mac_updateContentBorderMetricts(window, metrics);
|
||||
#if QT_MAC_USE_COCOA
|
||||
// In Cocoa we need to keep track of the drawRect method.
|
||||
// If documentMode is enabled we need to change it, unless
|
||||
// a toolbar is present.
|
||||
@ -113,7 +112,6 @@ void QTabBarPrivate::updateMacBorderMetrics()
|
||||
// Since in Cocoa there is no simple way to remove the baseline, so we just ask the
|
||||
// top level to do the magic for us.
|
||||
privateWidget->syncUnifiedMode();
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -231,11 +231,6 @@ void QToolBarPrivate::startDrag(bool moving)
|
||||
|
||||
if (!moving) {
|
||||
state->widgetItem = layout->unplug(q);
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
if (q->isWindow()) {
|
||||
setWindowState(true, true); //set it to floating
|
||||
}
|
||||
#endif
|
||||
Q_ASSERT(state->widgetItem != 0);
|
||||
}
|
||||
state->dragging = !moving;
|
||||
@ -1129,36 +1124,6 @@ bool QToolBar::event(QEvent *event)
|
||||
mwLayout->fixSizeInUnifiedToolbar(this);
|
||||
mwLayout->syncUnifiedToolbarVisibility();
|
||||
}
|
||||
# if !defined(QT_MAC_USE_COCOA)
|
||||
// Fall through
|
||||
case QEvent::LayoutRequest: {
|
||||
// There's currently no way to invalidate the size and let
|
||||
// HIToolbar know about it. This forces a re-check.
|
||||
int earlyResult = -1;
|
||||
if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget())) {
|
||||
bool needUpdate = true;
|
||||
if (event->type() == QEvent::LayoutRequest) {
|
||||
QSize oldSizeHint = sizeHint();
|
||||
earlyResult = QWidget::event(event) ? 1 : 0;
|
||||
needUpdate = oldSizeHint != sizeHint();
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
OSWindowRef windowRef = qt_mac_window_for(mainWindow);
|
||||
if (toolbarInUnifiedToolBar(this)
|
||||
&& macWindowToolbarIsVisible(windowRef)) {
|
||||
DisableScreenUpdates();
|
||||
macWindowToolbarShow(this, false);
|
||||
macWindowToolbarShow(this, true);
|
||||
EnableScreenUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
if (earlyResult != -1)
|
||||
return earlyResult;
|
||||
}
|
||||
}
|
||||
# endif // !QT_MAC_USE_COCOA
|
||||
#endif // Q_WS_MAC
|
||||
break;
|
||||
case QEvent::ParentChange:
|
||||
|
@ -402,15 +402,12 @@ void QToolBarLayout::setGeometry(const QRect &rect)
|
||||
extension->hide();
|
||||
}
|
||||
#ifdef Q_WS_MAC
|
||||
// Nothing to do for Carbon... probably
|
||||
# ifdef QT_MAC_USE_COCOA
|
||||
if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
|
||||
Qt::ToolBarArea area = win->toolBarArea(tb);
|
||||
if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) {
|
||||
qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ private slots:
|
||||
void drawRect_task215378();
|
||||
void drawRect_task247505();
|
||||
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_OS_MAC)
|
||||
void drawText_subPixelPositionsInRaster_qtbug5053();
|
||||
#endif
|
||||
|
||||
@ -4528,11 +4528,11 @@ void tst_QPainter::clipBoundingRect()
|
||||
|
||||
}
|
||||
|
||||
// Only Mac/Cocoa supports sub pixel positions in raster engine currently
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
//Only Mac/Cocoa supports sub pixel positions in raster engine currently
|
||||
#ifdef Q_OS_MAC
|
||||
void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
|
||||
{
|
||||
QFontMetricsF fm(qApp->font());
|
||||
QFontMetricsF fm(qApp->font());
|
||||
|
||||
QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32);
|
||||
baseLine.fill(Qt::white);
|
||||
|
@ -96,7 +96,7 @@ private slots:
|
||||
void rawFontSetPixelSize_data();
|
||||
void rawFontSetPixelSize();
|
||||
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
||||
void multipleRawFontsFromData();
|
||||
#endif
|
||||
|
||||
@ -854,7 +854,7 @@ void tst_QRawFont::rawFontSetPixelSize()
|
||||
QCOMPARE(rawFont.pixelSize(), 24.0);
|
||||
}
|
||||
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
||||
void tst_QRawFont::multipleRawFontsFromData()
|
||||
{
|
||||
QFile file(QString::fromLatin1(SRCDIR "testfont.ttf"));
|
||||
|
@ -1178,7 +1178,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
|
||||
#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
|
||||
void tst_QTextScriptEngine::combiningMarks_qtbug15675()
|
||||
{
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_MAC)
|
||||
QString s;
|
||||
s.append(QChar(0x0061));
|
||||
s.append(QChar(0x0062));
|
||||
|
@ -68,11 +68,9 @@ private slots:
|
||||
void testDragWindow();
|
||||
void testMouseEnter();
|
||||
void testChildDialogInFrontOfModalParent();
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
// void testChildWindowInFrontOfParentWindow();
|
||||
// void testChildToolWindowInFrontOfChildNormalWindow();
|
||||
void testChildWindowInFrontOfStaysOnTopParentWindow();
|
||||
#endif
|
||||
void testKeyPressOnToplevel();
|
||||
void testModifierShift();
|
||||
void testModifierAlt();
|
||||
@ -318,7 +316,6 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
|
||||
QVERIFY(!child.isVisible());
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#if 0
|
||||
// This test is disabled as of Qt-4.7.4 because we cannot do it
|
||||
// unless we use the Cocoa sub window API. But using that opens up
|
||||
@ -398,7 +395,6 @@ void tst_MacNativeEvents::testChildWindowInFrontOfStaysOnTopParentWindow()
|
||||
QTest::qWait(100);
|
||||
QVERIFY(!button.isVisible());
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_MacNativeEvents::testKeyPressOnToplevel()
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -917,7 +917,7 @@ void tst_QFiledialog::selectFiles()
|
||||
QVERIFY(listView);
|
||||
for (int i = 0; i < list.count(); ++i) {
|
||||
fd.selectFile(fd.directory().path() + "/" + list.at(i));
|
||||
#if defined(QT_MAC_USE_COCOA) || defined(Q_WS_WIN)
|
||||
#if defined(Q_WS_MAC) || defined(Q_WS_WIN)
|
||||
QEXPECT_FAIL("", "This test does not work on Mac or Windows", Abort);
|
||||
#endif
|
||||
QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty());
|
||||
|
@ -87,7 +87,7 @@ Q_DECLARE_METATYPE(QRectF)
|
||||
#define Q_CHECK_PAINTEVENTS
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_MAC)
|
||||
// On mac (cocoa) we always get full update.
|
||||
// So check that the expected region is contained inside the actual
|
||||
#define COMPARE_REGIONS(ACTUAL, EXPECTED) QVERIFY((EXPECTED).subtracted(ACTUAL).isEmpty())
|
||||
|
@ -2285,7 +2285,7 @@ void tst_QGraphicsView::viewportUpdateMode()
|
||||
|
||||
// The view gets two updates for the update scene updates.
|
||||
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
|
||||
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
|
||||
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
|
||||
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
|
||||
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(14, 14));
|
||||
QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(14, 14));
|
||||
@ -3360,9 +3360,8 @@ void tst_QGraphicsView::moveItemWhileScrolling()
|
||||
int a = adjustForAntialiasing ? 2 : 1;
|
||||
expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a);
|
||||
expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (QApplicationPrivate::graphicsSystem() == 0)
|
||||
QEXPECT_FAIL("", "This will fail with Cocoa because paint events are not send in the order expected by graphicsview", Continue);
|
||||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL("", "This will fail with Cocoa because paint events are not send in the order expected by graphicsview", Continue);
|
||||
#endif
|
||||
COMPARE_REGIONS(view.lastPaintedRegion, expectedRegion);
|
||||
}
|
||||
@ -3712,7 +3711,7 @@ void tst_QGraphicsView::exposeRegion()
|
||||
COMPARE_REGIONS(view.lastUpdateRegions.at(0), expectedExposeRegion);
|
||||
|
||||
// Make sure the item didn't get any repaints.
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef Q_OS_MAC
|
||||
QCOMPARE(item->paints, 0);
|
||||
#endif
|
||||
}
|
||||
@ -3870,7 +3869,7 @@ void tst_QGraphicsView::update2()
|
||||
rect->update();
|
||||
QTRY_VERIFY(view.painted);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
|
||||
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
|
||||
QTRY_VERIFY(view.painted);
|
||||
QCOMPARE(view.lastUpdateRegions.size(), 1);
|
||||
QCOMPARE(view.lastUpdateRegions.at(0), expectedUpdateRegion);
|
||||
@ -3926,7 +3925,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape()
|
||||
child->update();
|
||||
QTRY_VERIFY(view.painted);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
|
||||
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
|
||||
QTRY_VERIFY(view.painted);
|
||||
QCOMPARE(view.lastUpdateRegions.size(), 1);
|
||||
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
|
||||
@ -3978,7 +3977,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
|
||||
child->update();
|
||||
QTRY_VERIFY(view.painted);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
|
||||
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
|
||||
QTRY_VERIFY(view.painted);
|
||||
QCOMPARE(view.lastUpdateRegions.size(), 1);
|
||||
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
|
||||
@ -3998,7 +3997,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
|
||||
expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect());
|
||||
expected.adjust(-2, -2, 2, 2); // Antialiasing
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
|
||||
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
|
||||
QTRY_VERIFY(view.painted);
|
||||
QCOMPARE(view.lastUpdateRegions.size(), 1);
|
||||
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
|
||||
|
@ -419,9 +419,7 @@ private slots:
|
||||
void childAt();
|
||||
#ifdef Q_WS_MAC
|
||||
void childAt_unifiedToolBar();
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
void taskQTBUG_11373();
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif
|
||||
void taskQTBUG_17333_ResizeInfiniteRecursion();
|
||||
|
||||
@ -2691,7 +2689,7 @@ void tst_QWidget::raise()
|
||||
QTest::qWaitForWindowShown(parent);
|
||||
QTest::qWait(10);
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_OS_MAC
|
||||
if (child1->internalWinId()) {
|
||||
QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events.", SkipAll);
|
||||
}
|
||||
@ -2721,7 +2719,7 @@ void tst_QWidget::raise()
|
||||
foreach (UpdateWidget *child, allChildren) {
|
||||
int expectedPaintEvents = child == child2 ? 1 : 0;
|
||||
int expectedZOrderChangeEvents = child == child2 ? 1 : 0;
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_OS_MAC
|
||||
QSKIP("Not yet sure why this fails.", SkipSingle);
|
||||
#endif
|
||||
QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents);
|
||||
@ -2775,7 +2773,7 @@ void tst_QWidget::raise()
|
||||
}
|
||||
|
||||
// Cocoa has no Z-Order for views, we hack it, but it results in paint events.
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef QT_OS_MAC
|
||||
void tst_QWidget::lower()
|
||||
{
|
||||
QWidget *parent = new QWidget(0);
|
||||
@ -2840,7 +2838,7 @@ void tst_QWidget::lower()
|
||||
#endif
|
||||
|
||||
// Cocoa has no Z-Order for views, we hack it, but it results in paint events.
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef QT_OS_MAC
|
||||
void tst_QWidget::stackUnder()
|
||||
{
|
||||
QTest::qWait(10);
|
||||
@ -4242,6 +4240,9 @@ void tst_QWidget::update()
|
||||
QApplication::processEvents();
|
||||
QApplication::processEvents();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QEXPECT_FAIL(0, "Cocoa compositor says to paint this twice.", Continue);
|
||||
#endif
|
||||
QTRY_COMPARE(w.numPaintEvents, 1);
|
||||
|
||||
QCOMPARE(w.visibleRegion(), QRegion(w.rect()));
|
||||
@ -4301,10 +4302,6 @@ void tst_QWidget::update()
|
||||
- child.visibleRegion().translated(childOffset);
|
||||
QCOMPARE(w.visibleRegion(), expectedVisible);
|
||||
QCOMPARE(w.paintedRegion, expectedVisible);
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
|
||||
QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
|
||||
#endif
|
||||
QCOMPARE(child.numPaintEvents, 0);
|
||||
|
||||
w.reset();
|
||||
@ -4373,7 +4370,7 @@ void tst_QWidget::update()
|
||||
QCOMPARE(sibling.numPaintEvents, 1);
|
||||
QCOMPARE(sibling.paintedRegion, sibling.visibleRegion());
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
#ifdef Q_OS_MAC
|
||||
if (child.internalWinId()) // child is native
|
||||
QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue);
|
||||
#endif
|
||||
@ -4817,11 +4814,6 @@ void tst_QWidget::windowMoveResize()
|
||||
widget.show();
|
||||
|
||||
QTest::qWait(10);
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
QEXPECT_FAIL("130,50 0x0, flags 0",
|
||||
"Showing a window with 0x0 size shifts it up.",
|
||||
Continue);
|
||||
#endif
|
||||
QTRY_COMPARE(widget.pos(), rect.topLeft());
|
||||
QTRY_COMPARE(widget.size(), rect.size());
|
||||
|
||||
@ -4863,7 +4855,7 @@ void tst_QWidget::windowMoveResize()
|
||||
widget.move(r.topLeft());
|
||||
widget.resize(r.size());
|
||||
QApplication::processEvents();
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_MAC)
|
||||
if (r.width() == 0 && r.height() > 0) {
|
||||
widget.move(r.topLeft());
|
||||
widget.resize(r.size());
|
||||
@ -4932,7 +4924,7 @@ void tst_QWidget::windowMoveResize()
|
||||
widget.move(r.topLeft());
|
||||
widget.resize(r.size());
|
||||
QApplication::processEvents();
|
||||
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
||||
#if defined(Q_WS_MAC)
|
||||
if (r.width() == 0 && r.height() > 0) {
|
||||
widget.move(r.topLeft());
|
||||
widget.resize(r.size());
|
||||
@ -5106,7 +5098,7 @@ void tst_QWidget::showAndMoveChild()
|
||||
}
|
||||
|
||||
// Cocoa only has rect granularity.
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
#ifndef QT_OS_MAC
|
||||
void tst_QWidget::subtractOpaqueSiblings()
|
||||
{
|
||||
QWidget w;
|
||||
@ -5837,9 +5829,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
|
||||
{
|
||||
EventRecorder::EventList expected;
|
||||
bool accessibilityEnabled = false;
|
||||
#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
|
||||
accessibilityEnabled = AXAPIEnabled();
|
||||
#endif
|
||||
|
||||
// Move away the cursor; otherwise it might result in an enter event if it's
|
||||
// inside the widget when the widget is shown.
|
||||
@ -5893,12 +5882,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
|
||||
<< qMakePair(&widget, QEvent::PolishRequest)
|
||||
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1));
|
||||
|
||||
#ifndef QT_MAC_USE_CARBON
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
#endif // !QT_MAC_USE_CARBON
|
||||
#ifdef Q_OS_MAC
|
||||
expected << qMakePair(&widget, QEvent::UpdateLater);
|
||||
#endif
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
|
||||
QCOMPARE(spy.eventList(), expected);
|
||||
}
|
||||
@ -5981,12 +5968,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
|
||||
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
|
||||
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2));
|
||||
|
||||
#ifndef QT_MAC_USE_CARBON
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
#endif // !QT_MAC_USE_CARBON
|
||||
#ifdef Q_OS_MAC
|
||||
expected << qMakePair(&widget, QEvent::UpdateLater);
|
||||
#endif
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
|
||||
QCOMPARE(spy.eventList(), expected);
|
||||
}
|
||||
@ -6071,12 +6056,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
|
||||
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
|
||||
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2));
|
||||
|
||||
#ifndef QT_MAC_USE_CARBON
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
#endif // !QT_MAC_USE_CARBON
|
||||
#ifdef Q_OS_MAC
|
||||
expected << qMakePair(&widget, QEvent::UpdateLater);
|
||||
#endif
|
||||
expected << qMakePair(&widget, QEvent::UpdateRequest);
|
||||
|
||||
QCOMPARE(spy.eventList(), expected);
|
||||
}
|
||||
@ -9425,7 +9408,6 @@ void tst_QWidget::childAt_unifiedToolBar()
|
||||
QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
|
||||
}
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
void tst_QWidget::taskQTBUG_11373()
|
||||
{
|
||||
QMainWindow * myWindow = new QMainWindow();
|
||||
@ -9443,7 +9425,6 @@ void tst_QWidget::taskQTBUG_11373()
|
||||
// The drawer should still not be visible, since we haven't shown it.
|
||||
QCOMPARE(drawer->isVisible(), false);
|
||||
}
|
||||
#endif // QT_MAC_USE_COCOA
|
||||
#endif
|
||||
|
||||
void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
|
||||
|
@ -47,12 +47,6 @@
|
||||
QString nativeWindowTitle(QWidget *widget, Qt::WindowState state);
|
||||
bool nativeWindowModified(QWidget *widget);
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
typedef QPair<QWidget *, HIViewRef> WidgetViewPair;
|
||||
bool testAndRelease(const HIViewRef view);
|
||||
WidgetViewPair createAndRetain(QWidget * const parent = 0);
|
||||
#else
|
||||
typedef QPair<QWidget *, WId> WidgetViewPair;
|
||||
bool testAndRelease(const WId);
|
||||
WidgetViewPair createAndRetain(QWidget * const parent = 0);
|
||||
#endif
|
||||
|
@ -49,52 +49,18 @@ QString nativeWindowTitle(QWidget *window, Qt::WindowState state)
|
||||
OSWindowRef windowRef = qt_mac_window_for(window);
|
||||
QCFString macTitle;
|
||||
if (state == Qt::WindowMinimized) {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
CopyWindowAlternateTitle(windowRef, &macTitle);
|
||||
#else
|
||||
macTitle = reinterpret_cast<CFStringRef>([[windowRef miniwindowTitle] retain]);
|
||||
#endif
|
||||
} else {
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
CopyWindowTitleAsCFString(windowRef, &macTitle);
|
||||
#else
|
||||
macTitle = reinterpret_cast<CFStringRef>([[windowRef title] retain]);
|
||||
#endif
|
||||
}
|
||||
return macTitle;
|
||||
}
|
||||
|
||||
bool nativeWindowModified(QWidget *widget)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
return IsWindowModified(qt_mac_window_for(widget));
|
||||
#else
|
||||
return [qt_mac_window_for(widget) isDocumentEdited];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
bool testAndRelease(const HIViewRef view)
|
||||
{
|
||||
// qDebug() << CFGetRetainCount(view);
|
||||
if (CFGetRetainCount(view) != 2)
|
||||
return false;
|
||||
CFRelease(view);
|
||||
CFRelease(view);
|
||||
return true;
|
||||
}
|
||||
|
||||
WidgetViewPair createAndRetain(QWidget * const parent)
|
||||
{
|
||||
QWidget * const widget = new QWidget(parent);
|
||||
const HIViewRef view = (HIViewRef)widget->winId();
|
||||
// Retain twice so we can safely call CFGetRetaintCount even if the retain count
|
||||
// is off by one because of a double release.
|
||||
CFRetain(view);
|
||||
CFRetain(view);
|
||||
return qMakePair(widget, view);
|
||||
}
|
||||
#else
|
||||
bool testAndRelease(const WId view)
|
||||
{
|
||||
if ([id(view) retainCount] != 2)
|
||||
@ -114,5 +80,4 @@ WidgetViewPair createAndRetain(QWidget * const parent)
|
||||
[id(view) retain];
|
||||
return qMakePair(widget, view);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user