![]() |
Qt 6.x
The Qt SDK
|
#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>
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) |
QNSView * | qnsview_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) |
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 |
Qt::MouseButton cocoaButton2QtButton | ( | NSEvent * | event | ) |
Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
Definition at line 264 of file qcocoahelpers.mm.
References cocoaButton2QtButton(), cocoaEvent2QtMouseEvent(), QEvent::MouseMove, Qt::NoButton, and Qt::RightButton.
Qt::MouseButton cocoaButton2QtButton | ( | NSInteger | buttonNum | ) |
Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
Definition at line 244 of file qcocoahelpers.mm.
References Qt::NoButton.
Referenced by cocoaButton2QtButton(), and QCocoaWindow::setupPopupMonitor().
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().
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().
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().
Definition at line 490 of file qcocoahelpers.mm.
References debug.
Definition at line 501 of file qcocoahelpers.mm.
Q_LOGGING_CATEGORY | ( | lcQpaApplication | , |
"qt.qpa.application" | |||
) |
Q_LOGGING_CATEGORY | ( | lcQpaDrawing | , |
"qt.qpa.drawing" | |||
) |
Q_LOGGING_CATEGORY | ( | lcQpaKeys | , |
"qt.qpa.input.keys" | , | ||
QtCriticalMsg | |||
) |
Q_LOGGING_CATEGORY | ( | lcQpaMouse | , |
"qt.qpa.input.mouse" | , | ||
QtCriticalMsg | |||
) |
Q_LOGGING_CATEGORY | ( | lcQpaScreen | , |
"qt.qpa.screen" | , | ||
QtCriticalMsg | |||
) |
QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY | ( | lcQpaWindow | , |
"qt.qpa.window" | |||
) |
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 QCocoaInputContext::commit(), qRegisterNotificationCallbacks(), QCocoaWindow::recreateWindowIfNeeded(), QCocoaInputContext::reset(), QCocoaInputContext::setFocusObject(), QCocoaWindow::setWindowCursor(), QCocoaMenu::showPopup(), and QCocoaScreen::topLevelAt().
QString qt_mac_applicationName | ( | ) |
Definition at line 184 of file qcocoahelpers.mm.
References QCoreApplicationPrivate::appName(), QString::contains(), QGuiApplicationPrivate::instance(), QString::isEmpty(), and QString::split().
Definition at line 222 of file qcocoahelpers.mm.
References pos.
Referenced by QCocoaScreen::mapFromNative(), QCocoaScreen::mapFromNative(), QCocoaScreen::mapToNative(), QCocoaScreen::mapToNative(), and qt_mac_flip().
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.
NSDragOperation qt_mac_mapDropAction | ( | Qt::DropAction | action | ) |
Definition at line 71 of file qcocoahelpers.mm.
References dnd_enums, i, dndenum_mapper::mac_code, and dndenum_mapper::qt_code.
NSDragOperation qt_mac_mapDropActions | ( | Qt::DropActions | actions | ) |
Definition at line 81 of file qcocoahelpers.mm.
References dnd_enums, i, dndenum_mapper::mac_code, and dndenum_mapper::qt_code.
Qt::DropAction qt_mac_mapNSDragOperation | ( | NSDragOperation | nsActions | ) |
Definition at line 91 of file qcocoahelpers.mm.
References dnd_enums, i, Qt::IgnoreAction, dndenum_mapper::mac_code, and dndenum_mapper::qt_code.
Qt::DropActions qt_mac_mapNSDragOperations | ( | NSDragOperation | nsActions | ) |
Definition at line 101 of file qcocoahelpers.mm.
References dnd_enums, i, Qt::IgnoreAction, dndenum_mapper::mac_code, and dndenum_mapper::qt_code.
QStringList qt_mac_NSArrayToQStringList | ( | NSArray< NSString * > * | array | ) |
Definition at line 38 of file qcocoahelpers.mm.
NSMutableArray< NSString * > * qt_mac_QStringListToNSMutableArray | ( | const QStringList & | list | ) |
Definition at line 46 of file qcocoahelpers.mm.
References list, and QList< T >::size().
Definition at line 334 of file qcocoahelpers.mm.
References QPlatformTheme::removeMnemonics(), and QString::trimmed().
Referenced by QCocoaMenu::setText().
void qt_mac_transformProccessToForegroundApplication | ( | ) |
Definition at line 142 of file qcocoahelpers.mm.
Referenced by QCocoaIntegration::QCocoaIntegration().
InputMethodQueryResult queryInputMethod | ( | QObject * | object, |
Qt::InputMethodQueries | queries | ||
) |
Definition at line 468 of file qcocoahelpers.mm.
References i, Qt::ImEnabled, QMetaEnum::keyCount(), QCoreApplication::sendEvent(), QVariant::toBool(), QMetaEnum::value(), and QInputMethodQueryEvent::value().
NSButton* _cancelButton |
Definition at line 352 of file qcocoahelpers.mm.
NSView* _panelContents |
Definition at line 353 of file qcocoahelpers.mm.
NSEdgeInsets _panelContentsMargins |
Definition at line 354 of file qcocoahelpers.mm.
|
static |
Definition at line 61 of file qcocoahelpers.mm.
Referenced by qt_mac_mapDropAction(), qt_mac_mapDropActions(), qt_mac_mapNSDragOperation(), and qt_mac_mapNSDragOperations().