Guard QAppleKeyMapper::fromNSString() with iOS define
It's only used from iOS. Change-Id: I0d653cb76fc27085c74feb5d2628cb1a201ade05 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
cd4000a97d
commit
e44aee9848
|
|
@ -36,36 +36,6 @@ static Qt::KeyboardModifiers swapModifiersIfNeeded(const Qt::KeyboardModifiers m
|
|||
return swappedModifiers;
|
||||
}
|
||||
|
||||
Qt::Key QAppleKeyMapper::fromNSString(Qt::KeyboardModifiers qtModifiers, NSString *characters,
|
||||
NSString *charactersIgnoringModifiers, QString &text)
|
||||
{
|
||||
if ([characters isEqualToString:@"\t"]) {
|
||||
if (qtModifiers & Qt::ShiftModifier)
|
||||
return Qt::Key_Backtab;
|
||||
return Qt::Key_Tab;
|
||||
} else if ([characters isEqualToString:@"\r"]) {
|
||||
if (qtModifiers & Qt::KeypadModifier)
|
||||
return Qt::Key_Enter;
|
||||
return Qt::Key_Return;
|
||||
}
|
||||
if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) {
|
||||
QChar ch;
|
||||
if (((qtModifiers & Qt::MetaModifier) || (qtModifiers & Qt::AltModifier)) &&
|
||||
([charactersIgnoringModifiers length] != 0)) {
|
||||
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
|
||||
} else if ([characters length] != 0) {
|
||||
ch = QChar([characters characterAtIndex:0]);
|
||||
}
|
||||
if (!(qtModifiers & (Qt::ControlModifier | Qt::MetaModifier)) &&
|
||||
(ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)) {
|
||||
text = QString::fromNSString(characters);
|
||||
}
|
||||
if (!ch.isNull())
|
||||
return Qt::Key(ch.toUpper().unicode());
|
||||
}
|
||||
return Qt::Key_unknown;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
static constexpr std::tuple<NSEventModifierFlags, Qt::KeyboardModifier> cocoaModifierMap[] = {
|
||||
{ NSEventModifierFlagShift, Qt::ShiftModifier },
|
||||
|
|
@ -584,6 +554,36 @@ QList<QKeyCombination> QAppleKeyMapper::possibleKeyCombinations(const QKeyEvent
|
|||
|
||||
#else // iOS
|
||||
|
||||
Qt::Key QAppleKeyMapper::fromNSString(Qt::KeyboardModifiers qtModifiers, NSString *characters,
|
||||
NSString *charactersIgnoringModifiers, QString &text)
|
||||
{
|
||||
if ([characters isEqualToString:@"\t"]) {
|
||||
if (qtModifiers & Qt::ShiftModifier)
|
||||
return Qt::Key_Backtab;
|
||||
return Qt::Key_Tab;
|
||||
} else if ([characters isEqualToString:@"\r"]) {
|
||||
if (qtModifiers & Qt::KeypadModifier)
|
||||
return Qt::Key_Enter;
|
||||
return Qt::Key_Return;
|
||||
}
|
||||
if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) {
|
||||
QChar ch;
|
||||
if (((qtModifiers & Qt::MetaModifier) || (qtModifiers & Qt::AltModifier)) &&
|
||||
([charactersIgnoringModifiers length] != 0)) {
|
||||
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
|
||||
} else if ([characters length] != 0) {
|
||||
ch = QChar([characters characterAtIndex:0]);
|
||||
}
|
||||
if (!(qtModifiers & (Qt::ControlModifier | Qt::MetaModifier)) &&
|
||||
(ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)) {
|
||||
text = QString::fromNSString(characters);
|
||||
}
|
||||
if (!ch.isNull())
|
||||
return Qt::Key(ch.toUpper().unicode());
|
||||
}
|
||||
return Qt::Key_unknown;
|
||||
}
|
||||
|
||||
// Keyboard keys (non-modifiers)
|
||||
API_AVAILABLE(ios(13.4)) Qt::Key QAppleKeyMapper::fromUIKitKey(NSString *keyCode)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ public:
|
|||
Qt::KeyboardModifiers queryKeyboardModifiers() const override;
|
||||
QList<QKeyCombination> possibleKeyCombinations(const QKeyEvent *event) const override;
|
||||
|
||||
static Qt::Key fromNSString(Qt::KeyboardModifiers qtMods, NSString *characters,
|
||||
NSString *charactersIgnoringModifiers, QString &text);
|
||||
#ifdef Q_OS_MACOS
|
||||
static Qt::KeyboardModifiers fromCocoaModifiers(NSEventModifierFlags cocoaModifiers);
|
||||
static NSEventModifierFlags toCocoaModifiers(Qt::KeyboardModifiers);
|
||||
|
|
@ -44,6 +42,9 @@ public:
|
|||
static QChar toCocoaKey(Qt::Key key);
|
||||
static Qt::Key fromCocoaKey(QChar keyCode);
|
||||
#else
|
||||
static Qt::Key fromNSString(Qt::KeyboardModifiers qtMods, NSString *characters,
|
||||
NSString *charactersIgnoringModifiers, QString &text);
|
||||
|
||||
static Qt::Key fromUIKitKey(NSString *keyCode);
|
||||
static Qt::KeyboardModifiers fromUIKitModifiers(ulong uikitModifiers);
|
||||
static ulong toUIKitModifiers(Qt::KeyboardModifiers);
|
||||
|
|
|
|||
Loading…
Reference in New Issue