Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcocoahelpers.mm File Reference

(5f15a93f16727824372bfd1a6490754440de942f)

#include <AppKit/AppKit.h>
#include <qpa/qplatformtheme.h>
#include "qcocoahelpers.h"
#include "qnsview.h"
#include <QtCore>
#include <QtGui>
#include <qpa/qplatformscreen.h>
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>
#include <QtGui/private/qcoregraphics_p.h>
#include <algorithm>
+ Include dependency graph for qcocoahelpers.mm:

Go to the source code of this file.

Classes

struct  dndenum_mapper
 

Functions

QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY (lcQpaWindow, "qt.qpa.window")
 
 Q_LOGGING_CATEGORY (lcQpaDrawing, "qt.qpa.drawing")
 
 Q_LOGGING_CATEGORY (lcQpaMouse, "qt.qpa.input.mouse", QtCriticalMsg)
 
 Q_LOGGING_CATEGORY (lcQpaKeys, "qt.qpa.input.keys", QtCriticalMsg)
 
 Q_LOGGING_CATEGORY (lcQpaScreen, "qt.qpa.screen", QtCriticalMsg)
 
 Q_LOGGING_CATEGORY (lcQpaApplication, "qt.qpa.application")
 
QStringList qt_mac_NSArrayToQStringList (NSArray< NSString * > *array)
 
NSMutableArray< NSString * > * qt_mac_QStringListToNSMutableArray (const QStringList &list)
 
NSDragOperation qt_mac_mapDropAction (Qt::DropAction action)
 
NSDragOperation qt_mac_mapDropActions (Qt::DropActions actions)
 
Qt::DropAction qt_mac_mapNSDragOperation (NSDragOperation nsActions)
 
Qt::DropActions qt_mac_mapNSDragOperations (NSDragOperation nsActions)
 
QNSViewqnsview_cast (NSView *view)
 Returns the view cast to a QNSview if possible.
 
void qt_mac_transformProccessToForegroundApplication ()
 
QString qt_mac_applicationName ()
 
QPointF qt_mac_flip (const QPointF &pos, const QRectF &reference)
 
QRectF qt_mac_flip (const QRectF &rect, const QRectF &reference)
 Flips the Y coordinate of the point/rect between quadrant I and IV.
 
Qt::MouseButton cocoaButton2QtButton (NSInteger buttonNum)
 Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
 
Qt::MouseButton cocoaButton2QtButton (NSEvent *event)
 Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
 
QEvent::Type cocoaEvent2QtMouseEvent (NSEvent *event)
 Returns the QEvent::Type that corresponds to an NSEvent.type.
 
Qt::MouseButtons cocoaMouseButtons2QtMouseButtons (NSInteger pressedMouseButtons)
 Returns the Qt::MouseButtons that corresponds to an NSEvent.pressedMouseButtons.
 
Qt::MouseButtons currentlyPressedMouseButtons ()
 Returns the Qt::MouseButtons that corresponds to an NSEvent.pressedMouseButtons.
 
QString qt_mac_removeAmpersandEscapes (QString s)
 
NSString * qt_mac_AppKitString (NSString *table, NSString *key)
 
InputMethodQueryResult queryInputMethod (QObject *object, Qt::InputMethodQueries queries)
 
QDebug operator<< (QDebug debug, const NSRange &range)
 
QDebug operator<< (QDebug debug, SEL selector)
 

Variables

static dndenum_mapper dnd_enums []
 
NSButton * _cancelButton
 
NSView * _panelContents
 
NSEdgeInsets _panelContentsMargins
 

Function Documentation

◆ cocoaButton2QtButton() [1/2]

Qt::MouseButton cocoaButton2QtButton ( NSEvent * event)

Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.

Note
AppKit will use buttonNumber 0 to indicate both "left button" and "no button". Only NSEvents that describes mouse press/release/dragging events (e.g NSEventTypeOtherMouseDown) will contain a valid button number.
Wacom tablet might not return the correct button number for NSEvent buttonNumber on right clicks. Decide here that the button is the "right" button.

Definition at line 264 of file qcocoahelpers.mm.

References cocoaButton2QtButton(), cocoaEvent2QtMouseEvent(), QEvent::MouseMove, Qt::NoButton, and Qt::RightButton.

+ Here is the call graph for this function:

◆ cocoaButton2QtButton() [2/2]

Qt::MouseButton cocoaButton2QtButton ( NSInteger buttonNum)

Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.

Note
AppKit will use buttonNumber 0 to indicate both "left button" and "no button". Only NSEvents that describes mouse press/release events (e.g NSEventTypeOtherMouseDown) will contain a valid button number.

Definition at line 244 of file qcocoahelpers.mm.

References Qt::NoButton.

Referenced by cocoaButton2QtButton(), and QCocoaWindow::setupPopupMonitor().

+ Here is the caller graph for this function:

◆ cocoaEvent2QtMouseEvent()

QEvent::Type cocoaEvent2QtMouseEvent ( NSEvent * event)

Returns the QEvent::Type that corresponds to an NSEvent.type.

Definition at line 286 of file qcocoahelpers.mm.

References QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, and QEvent::None.

Referenced by cocoaButton2QtButton(), and QCocoaWindow::setupPopupMonitor().

+ Here is the caller graph for this function:

◆ cocoaMouseButtons2QtMouseButtons()

Qt::MouseButtons cocoaMouseButtons2QtMouseButtons ( NSInteger pressedMouseButtons)

Returns the Qt::MouseButtons that corresponds to an NSEvent.pressedMouseButtons.

Definition at line 319 of file qcocoahelpers.mm.

References Qt::MouseButtonMask.

Referenced by currentlyPressedMouseButtons().

+ Here is the caller graph for this function:

◆ currentlyPressedMouseButtons()

Qt::MouseButtons currentlyPressedMouseButtons ( )

Returns the Qt::MouseButtons that corresponds to an NSEvent.pressedMouseButtons.

Definition at line 329 of file qcocoahelpers.mm.

References cocoaMouseButtons2QtMouseButtons().

Referenced by QCocoaWindow::setupPopupMonitor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [1/2]

QDebug operator<< ( QDebug debug,
const NSRange & range )

Definition at line 499 of file qcocoahelpers.mm.

References debug.

◆ operator<<() [2/2]

QDebug operator<< ( QDebug debug,
SEL selector )

Definition at line 510 of file qcocoahelpers.mm.

References debug, and selector.

◆ Q_LOGGING_CATEGORY() [1/6]

Q_LOGGING_CATEGORY ( lcQpaApplication ,
"qt.qpa.application"  )

◆ Q_LOGGING_CATEGORY() [2/6]

Q_LOGGING_CATEGORY ( lcQpaDrawing ,
"qt.qpa.drawing"  )

◆ Q_LOGGING_CATEGORY() [3/6]

Q_LOGGING_CATEGORY ( lcQpaKeys ,
"qt.qpa.input.keys" ,
QtCriticalMsg  )

◆ Q_LOGGING_CATEGORY() [4/6]

Q_LOGGING_CATEGORY ( lcQpaMouse ,
"qt.qpa.input.mouse" ,
QtCriticalMsg  )

◆ Q_LOGGING_CATEGORY() [5/6]

Q_LOGGING_CATEGORY ( lcQpaScreen ,
"qt.qpa.screen" ,
QtCriticalMsg  )

◆ Q_LOGGING_CATEGORY() [6/6]

QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY ( lcQpaWindow ,
"qt.qpa.window"  )

◆ qnsview_cast()

QNSView * qnsview_cast ( NSView * view)

Returns the view cast to a QNSview if possible.

If the view is not a QNSView, nil is returned, which is safe to send messages to, effectivly making [qnsview_cast(view) message] a no-op.

For extra verbosity and clearer code, please consider checking that the platform window is not a foreign window before using this cast, via QPlatformWindow::isForeignWindow().

Do not use this method solely to check for foreign windows, as that will make the code harder to read for people not working primarily on macOS, who do not know the difference between the NSView and QNSView cases.

Definition at line 131 of file qcocoahelpers.mm.

References view.

Referenced by QCocoaBackingStore::colorSpace(), QCocoaInputContext::commit(), QCocoaWindow::createNSWindow(), qRegisterNotificationCallbacks(), QCocoaWindow::recreateWindowIfNeeded(), QCocoaInputContext::reset(), QCocoaInputContext::setFocusObject(), QCocoaWindow::setWindowCursor(), QCocoaMenu::showPopup(), and QCocoaScreen::topLevelAt().

+ Here is the caller graph for this function:

◆ qt_mac_AppKitString()

NSString * qt_mac_AppKitString ( NSString * table,
NSString * key )

Definition at line 339 of file qcocoahelpers.mm.

Referenced by QCocoaMenuBar::syncMenu_helper().

+ Here is the caller graph for this function:

◆ qt_mac_applicationName()

QString qt_mac_applicationName ( )

Definition at line 184 of file qcocoahelpers.mm.

References QGuiApplicationPrivate::instance(), and QString::isEmpty().

+ Here is the call graph for this function:

◆ qt_mac_flip() [1/2]

QPointF qt_mac_flip ( const QPointF & pos,
const QRectF & reference )

Definition at line 222 of file qcocoahelpers.mm.

References pos.

Referenced by QCocoaScreen::mapFromNative(), QCocoaScreen::mapFromNative(), QCocoaScreen::mapToNative(), QCocoaScreen::mapToNative(), and qt_mac_flip().

+ Here is the caller graph for this function:

◆ qt_mac_flip() [2/2]

QRectF qt_mac_flip ( const QRectF & rect,
const QRectF & reference )

Flips the Y coordinate of the point/rect between quadrant I and IV.

The native coordinate system on macOS uses quadrant I, with origin in bottom left, and Qt uses quadrant IV, with origin in top left.

By flipping the Y coordinate, we can map the point/rect between the two coordinate systems.

The flip is always in relation to a reference rectangle, e.g. the frame of the parent view, or the screen geometry. In the latter case the specialized QCocoaScreen::mapFrom/To functions should be used instead.

Definition at line 227 of file qcocoahelpers.mm.

References qt_mac_flip(), and rect.

+ Here is the call graph for this function:

◆ qt_mac_mapDropAction()

NSDragOperation qt_mac_mapDropAction ( Qt::DropAction action)

Definition at line 71 of file qcocoahelpers.mm.

References dnd_enums, and i.

◆ qt_mac_mapDropActions()

NSDragOperation qt_mac_mapDropActions ( Qt::DropActions actions)

Definition at line 81 of file qcocoahelpers.mm.

References dnd_enums, and i.

◆ qt_mac_mapNSDragOperation()

Qt::DropAction qt_mac_mapNSDragOperation ( NSDragOperation nsActions)

Definition at line 91 of file qcocoahelpers.mm.

References dnd_enums, i, and Qt::IgnoreAction.

◆ qt_mac_mapNSDragOperations()

Qt::DropActions qt_mac_mapNSDragOperations ( NSDragOperation nsActions)

Definition at line 101 of file qcocoahelpers.mm.

References dnd_enums, i, and Qt::IgnoreAction.

◆ qt_mac_NSArrayToQStringList()

QStringList qt_mac_NSArrayToQStringList ( NSArray< NSString * > * array)

Definition at line 38 of file qcocoahelpers.mm.

◆ qt_mac_QStringListToNSMutableArray()

NSMutableArray< NSString * > * qt_mac_QStringListToNSMutableArray ( const QStringList & list)

Definition at line 46 of file qcocoahelpers.mm.

References list, and QList< T >::size().

+ Here is the call graph for this function:

◆ qt_mac_removeAmpersandEscapes()

QString qt_mac_removeAmpersandEscapes ( QString s)

Definition at line 334 of file qcocoahelpers.mm.

References QPlatformTheme::removeMnemonics().

Referenced by QCocoaMenu::setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_mac_transformProccessToForegroundApplication()

void qt_mac_transformProccessToForegroundApplication ( )

Definition at line 142 of file qcocoahelpers.mm.

Referenced by QCocoaIntegration::QCocoaIntegration().

+ Here is the caller graph for this function:

◆ queryInputMethod()

InputMethodQueryResult queryInputMethod ( QObject * object,
Qt::InputMethodQueries queries )

Definition at line 477 of file qcocoahelpers.mm.

References i, Qt::ImEnabled, and QCoreApplication::sendEvent().

+ Here is the call graph for this function:

Variable Documentation

◆ _cancelButton

NSButton* _cancelButton
Initial value:
{
NSButton *_okButton

Definition at line 361 of file qcocoahelpers.mm.

◆ _panelContents

NSView* _panelContents

Definition at line 362 of file qcocoahelpers.mm.

◆ _panelContentsMargins

NSEdgeInsets _panelContentsMargins

Definition at line 363 of file qcocoahelpers.mm.

◆ dnd_enums

dndenum_mapper dnd_enums[]
static
Initial value:
= {
{ NSDragOperationLink, Qt::LinkAction, true },
{ NSDragOperationMove, Qt::MoveAction, true },
{ NSDragOperationDelete, Qt::MoveAction, true },
{ NSDragOperationCopy, Qt::CopyAction, true },
{ NSDragOperationGeneric, Qt::CopyAction, false },
{ NSDragOperationEvery, Qt::ActionMask, false },
{ NSDragOperationNone, Qt::IgnoreAction, false }
}
@ CopyAction
@ ActionMask
@ IgnoreAction
@ MoveAction
@ LinkAction

Definition at line 61 of file qcocoahelpers.mm.

Referenced by qt_mac_mapDropAction(), qt_mac_mapDropActions(), qt_mac_mapNSDragOperation(), and qt_mac_mapNSDragOperations().