macOS: Clean up some more Objective-C usage in QNSView implementation
- Format selectors consistently
- Use proper style for init methods
Follow-up to ba871065e0
Change-Id: I5742e248b83d5955b1d110038dd1b4d79d701fbb
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
83a1203c3b
commit
bbe9bda106
@ -96,13 +96,13 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
|
|||||||
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent;
|
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent;
|
||||||
|
|
||||||
#ifndef QT_NO_TABLETEVENT
|
#ifndef QT_NO_TABLETEVENT
|
||||||
- (bool)handleTabletEvent: (NSEvent *)theEvent;
|
- (bool)handleTabletEvent:(NSEvent *)theEvent;
|
||||||
- (void)tabletPoint: (NSEvent *)theEvent;
|
- (void)tabletPoint:(NSEvent *)theEvent;
|
||||||
- (void)tabletProximity: (NSEvent *)theEvent;
|
- (void)tabletProximity:(NSEvent *)theEvent;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (int) convertKeyCode : (QChar)keyCode;
|
- (int)convertKeyCode:(QChar)keyCode;
|
||||||
+ (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags;
|
+ (Qt::KeyboardModifiers)convertKeyModifiers:(ulong)modifierFlags;
|
||||||
- (bool)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType;
|
- (bool)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType;
|
||||||
- (void)keyDown:(NSEvent *)theEvent;
|
- (void)keyDown:(NSEvent *)theEvent;
|
||||||
- (void)keyUp:(NSEvent *)theEvent;
|
- (void)keyUp:(NSEvent *)theEvent;
|
||||||
|
@ -92,10 +92,9 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
|
|
||||||
- (instancetype)initWithView:(QNSView *)theView
|
- (instancetype)initWithView:(QNSView *)theView
|
||||||
{
|
{
|
||||||
self = [super init];
|
if ((self = [super init]))
|
||||||
if (self) {
|
|
||||||
view = theView;
|
view = theView;
|
||||||
}
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +156,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if (self = [super initWithFrame:NSZeroRect]) {
|
if ((self = [super initWithFrame:NSZeroRect])) {
|
||||||
m_buttons = Qt::NoButton;
|
m_buttons = Qt::NoButton;
|
||||||
m_acceptedMouseDowns = Qt::NoButton;
|
m_acceptedMouseDowns = Qt::NoButton;
|
||||||
m_frameStrutButtons = Qt::NoButton;
|
m_frameStrutButtons = Qt::NoButton;
|
||||||
@ -200,36 +199,34 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
|
|
||||||
- (instancetype)initWithCocoaWindow:(QCocoaWindow *)platformWindow
|
- (instancetype)initWithCocoaWindow:(QCocoaWindow *)platformWindow
|
||||||
{
|
{
|
||||||
self = [self init];
|
if ((self = [self init])) {
|
||||||
if (!self)
|
m_platformWindow = platformWindow;
|
||||||
return 0;
|
m_sendKeyEvent = false;
|
||||||
|
m_dontOverrideCtrlLMB = qt_mac_resolveOption(false, platformWindow->window(), "_q_platform_MacDontOverrideCtrlLMB", "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
|
||||||
m_platformWindow = platformWindow;
|
m_trackingArea = nil;
|
||||||
m_sendKeyEvent = false;
|
|
||||||
m_dontOverrideCtrlLMB = qt_mac_resolveOption(false, platformWindow->window(), "_q_platform_MacDontOverrideCtrlLMB", "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
|
|
||||||
m_trackingArea = nil;
|
|
||||||
|
|
||||||
#ifdef QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR
|
#ifdef QT_COCOA_ENABLE_ACCESSIBILITY_INSPECTOR
|
||||||
// prevent rift in space-time continuum, disable
|
// prevent rift in space-time continuum, disable
|
||||||
// accessibility for the accessibility inspector's windows.
|
// accessibility for the accessibility inspector's windows.
|
||||||
static bool skipAccessibilityForInspectorWindows = false;
|
static bool skipAccessibilityForInspectorWindows = false;
|
||||||
if (!skipAccessibilityForInspectorWindows) {
|
if (!skipAccessibilityForInspectorWindows) {
|
||||||
|
|
||||||
// m_accessibleRoot = window->accessibleRoot();
|
// m_accessibleRoot = window->accessibleRoot();
|
||||||
|
|
||||||
AccessibilityInspector *inspector = new AccessibilityInspector(window);
|
AccessibilityInspector *inspector = new AccessibilityInspector(window);
|
||||||
skipAccessibilityForInspectorWindows = true;
|
skipAccessibilityForInspectorWindows = true;
|
||||||
inspector->inspectWindow(window);
|
inspector->inspectWindow(window);
|
||||||
skipAccessibilityForInspectorWindows = false;
|
skipAccessibilityForInspectorWindows = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[self registerDragTypes];
|
[self registerDragTypes];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(textInputContextKeyboardSelectionDidChangeNotification:)
|
selector:@selector(textInputContextKeyboardSelectionDidChangeNotification:)
|
||||||
name:NSTextInputContextKeyboardSelectionDidChangeNotification
|
name:NSTextInputContextKeyboardSelectionDidChangeNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -251,7 +248,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
- (void) setQCocoaGLContext:(QCocoaGLContext *)context
|
- (void)setQCocoaGLContext:(QCocoaGLContext *)context
|
||||||
{
|
{
|
||||||
m_glContext = context;
|
m_glContext = context;
|
||||||
[m_glContext->nsOpenGLContext() setView:self];
|
[m_glContext->nsOpenGLContext() setView:self];
|
||||||
@ -315,7 +312,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
[super removeFromSuperview];
|
[super removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isOpaque
|
- (BOOL)isOpaque
|
||||||
{
|
{
|
||||||
if (!m_platformWindow)
|
if (!m_platformWindow)
|
||||||
return true;
|
return true;
|
||||||
@ -503,7 +500,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
|
|||||||
m_frameStrutButtons = Qt::NoButton;
|
m_frameStrutButtons = Qt::NoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint) screenMousePoint:(NSEvent *)theEvent
|
- (NSPoint)screenMousePoint:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint screenPoint;
|
NSPoint screenPoint;
|
||||||
if (theEvent) {
|
if (theEvent) {
|
||||||
@ -936,7 +933,7 @@ struct QCocoaTabletDeviceData
|
|||||||
typedef QHash<uint, QCocoaTabletDeviceData> QCocoaTabletDeviceDataHash;
|
typedef QHash<uint, QCocoaTabletDeviceData> QCocoaTabletDeviceDataHash;
|
||||||
Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
|
Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
|
||||||
|
|
||||||
- (bool)handleTabletEvent: (NSEvent *)theEvent
|
- (bool)handleTabletEvent:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
static bool ignoreButtonMapping = qEnvironmentVariableIsSet("QT_MAC_TABLET_IGNORE_BUTTON_MAPPING");
|
static bool ignoreButtonMapping = qEnvironmentVariableIsSet("QT_MAC_TABLET_IGNORE_BUTTON_MAPPING");
|
||||||
|
|
||||||
@ -1360,12 +1357,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
}
|
}
|
||||||
#endif // QT_CONFIG(wheelevent)
|
#endif // QT_CONFIG(wheelevent)
|
||||||
|
|
||||||
- (int) convertKeyCode : (QChar)keyChar
|
- (int)convertKeyCode:(QChar)keyChar
|
||||||
{
|
{
|
||||||
return qt_mac_cocoaKey2QtKey(keyChar);
|
return qt_mac_cocoaKey2QtKey(keyChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (Qt::KeyboardModifiers) convertKeyModifiers : (ulong)modifierFlags
|
+ (Qt::KeyboardModifiers)convertKeyModifiers:(ulong)modifierFlags
|
||||||
{
|
{
|
||||||
const bool dontSwapCtrlAndMeta = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
|
const bool dontSwapCtrlAndMeta = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
|
||||||
Qt::KeyboardModifiers qtMods =Qt::NoModifier;
|
Qt::KeyboardModifiers qtMods =Qt::NoModifier;
|
||||||
@ -1574,18 +1571,18 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) insertNewline:(id)sender
|
- (void)insertNewline:(id)sender
|
||||||
{
|
{
|
||||||
Q_UNUSED(sender);
|
Q_UNUSED(sender);
|
||||||
m_resendKeyEvent = true;
|
m_resendKeyEvent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) doCommandBySelector:(SEL)aSelector
|
- (void)doCommandBySelector:(SEL)aSelector
|
||||||
{
|
{
|
||||||
[self tryToPerform:aSelector with:self];
|
[self tryToPerform:aSelector with:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
|
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||||
{
|
{
|
||||||
Q_UNUSED(replacementRange)
|
Q_UNUSED(replacementRange)
|
||||||
|
|
||||||
@ -1619,7 +1616,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
m_composingFocusObject = nullptr;
|
m_composingFocusObject = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
|
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
|
||||||
{
|
{
|
||||||
Q_UNUSED(replacementRange)
|
Q_UNUSED(replacementRange)
|
||||||
QString preeditString;
|
QString preeditString;
|
||||||
@ -1703,7 +1700,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
m_composingFocusObject = nullptr;
|
m_composingFocusObject = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) unmarkText
|
- (void)unmarkText
|
||||||
{
|
{
|
||||||
if (!m_composingText.isEmpty()) {
|
if (!m_composingText.isEmpty()) {
|
||||||
if (QObject *fo = m_platformWindow->window()->focusObject()) {
|
if (QObject *fo = m_platformWindow->window()->focusObject()) {
|
||||||
@ -1721,12 +1718,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
m_composingFocusObject = nullptr;
|
m_composingFocusObject = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) hasMarkedText
|
- (BOOL)hasMarkedText
|
||||||
{
|
{
|
||||||
return (m_composingText.isEmpty() ? NO: YES);
|
return (m_composingText.isEmpty() ? NO: YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||||
{
|
{
|
||||||
Q_UNUSED(actualRange)
|
Q_UNUSED(actualRange)
|
||||||
QObject *fo = m_platformWindow->window()->focusObject();
|
QObject *fo = m_platformWindow->window()->focusObject();
|
||||||
@ -1747,7 +1744,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
return [[[NSAttributedString alloc] initWithString:const_cast<NSString *>(tmpString)] autorelease];
|
return [[[NSAttributedString alloc] initWithString:const_cast<NSString *>(tmpString)] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRange) markedRange
|
- (NSRange)markedRange
|
||||||
{
|
{
|
||||||
NSRange range;
|
NSRange range;
|
||||||
if (!m_composingText.isEmpty()) {
|
if (!m_composingText.isEmpty()) {
|
||||||
@ -1760,7 +1757,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRange) selectedRange
|
- (NSRange)selectedRange
|
||||||
{
|
{
|
||||||
NSRange selectedRange = {0, 0};
|
NSRange selectedRange = {0, 0};
|
||||||
|
|
||||||
@ -1782,7 +1779,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
return selectedRange;
|
return selectedRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange
|
||||||
{
|
{
|
||||||
Q_UNUSED(aRange)
|
Q_UNUSED(aRange)
|
||||||
Q_UNUSED(actualRange)
|
Q_UNUSED(actualRange)
|
||||||
|
Loading…
Reference in New Issue
Block a user