Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcocoahelpers.mm File Reference

(76d861f39f5d063a0e065c7e3646606ed6a3b9d1)

#include <AppKit/AppKit.h>
#include <qpa/qplatformtheme.h>
#include "qcocoahelpers.h"
#include "qnsview.h"
#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)
QT_BEGIN_NAMESPACE 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 262 of file qcocoahelpers.mm.

◆ 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 242 of file qcocoahelpers.mm.

◆ cocoaEvent2QtMouseEvent()

QEvent::Type cocoaEvent2QtMouseEvent ( NSEvent * event)

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

Definition at line 284 of file qcocoahelpers.mm.

◆ cocoaMouseButtons2QtMouseButtons()

Qt::MouseButtons cocoaMouseButtons2QtMouseButtons ( NSInteger pressedMouseButtons)

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

Definition at line 317 of file qcocoahelpers.mm.

◆ currentlyPressedMouseButtons()

Qt::MouseButtons currentlyPressedMouseButtons ( )

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

Definition at line 327 of file qcocoahelpers.mm.

◆ operator<<() [1/2]

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

Definition at line 499 of file qcocoahelpers.mm.

◆ operator<<() [2/2]

QDebug operator<< ( QDebug debug,
SEL selector )

Definition at line 510 of file qcocoahelpers.mm.

◆ Q_LOGGING_CATEGORY() [1/6]

QT_BEGIN_NAMESPACE 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 129 of file qcocoahelpers.mm.

◆ qt_mac_AppKitString()

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

Definition at line 337 of file qcocoahelpers.mm.

◆ qt_mac_applicationName()

QString qt_mac_applicationName ( )

Definition at line 182 of file qcocoahelpers.mm.

◆ qt_mac_flip() [1/2]

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

Definition at line 220 of file qcocoahelpers.mm.

◆ 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 225 of file qcocoahelpers.mm.

◆ qt_mac_mapDropAction()

NSDragOperation qt_mac_mapDropAction ( Qt::DropAction action)

Definition at line 69 of file qcocoahelpers.mm.

References dnd_enums, and dndenum_mapper::Qt2Mac.

◆ qt_mac_mapDropActions()

NSDragOperation qt_mac_mapDropActions ( Qt::DropActions actions)

Definition at line 79 of file qcocoahelpers.mm.

References dnd_enums, and dndenum_mapper::Qt2Mac.

◆ qt_mac_mapNSDragOperation()

Qt::DropAction qt_mac_mapNSDragOperation ( NSDragOperation nsActions)

Definition at line 89 of file qcocoahelpers.mm.

References dnd_enums.

◆ qt_mac_mapNSDragOperations()

Qt::DropActions qt_mac_mapNSDragOperations ( NSDragOperation nsActions)

Definition at line 99 of file qcocoahelpers.mm.

References dnd_enums.

◆ qt_mac_NSArrayToQStringList()

QStringList qt_mac_NSArrayToQStringList ( NSArray< NSString * > * array)

Definition at line 36 of file qcocoahelpers.mm.

◆ qt_mac_QStringListToNSMutableArray()

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

Definition at line 44 of file qcocoahelpers.mm.

◆ qt_mac_removeAmpersandEscapes()

QString qt_mac_removeAmpersandEscapes ( QString s)

Definition at line 332 of file qcocoahelpers.mm.

◆ qt_mac_transformProccessToForegroundApplication()

void qt_mac_transformProccessToForegroundApplication ( )

Definition at line 140 of file qcocoahelpers.mm.

◆ queryInputMethod()

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

Definition at line 477 of file qcocoahelpers.mm.

Variable Documentation

◆ _cancelButton

NSButton* _cancelButton
Initial value:
{
NSButton *_okButton

Definition at line 359 of file qcocoahelpers.mm.

◆ _panelContents

NSView* _panelContents

Definition at line 360 of file qcocoahelpers.mm.

◆ _panelContentsMargins

NSEdgeInsets _panelContentsMargins

Definition at line 361 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 59 of file qcocoahelpers.mm.

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