6#include <qpa/qplatformtheme.h>
7#include "private/qguiapplication_p.h"
10#include <QtCore/qhashfunctions.h>
11#ifndef QT_NO_DATASTREAM
16#if defined(Q_OS_APPLE)
17#include <QtCore/private/qcore_mac_p.h>
27#if defined(Q_OS_APPLE) || defined(Q_QDOC)
29struct AppleSpecialKey {
36static constexpr int kShiftUnicode = 0x21E7;
37static constexpr int kControlUnicode = 0x2303;
38static constexpr int kOptionUnicode = 0x2325;
39static constexpr int kCommandUnicode = 0x2318;
41static constexpr AppleSpecialKey entries[] = {
66static constexpr bool operator<(
const AppleSpecialKey &lhs,
const AppleSpecialKey &rhs)
68 return lhs.key < rhs.key;
71static constexpr bool operator<(
const AppleSpecialKey &lhs,
int rhs)
76static constexpr bool operator<(
int lhs,
const AppleSpecialKey &rhs)
81static_assert(
q20::is_sorted(std::begin(entries), std::end(entries)));
83static QChar appleSymbolForQtKey(
int key)
85 const auto i = std::lower_bound(std::begin(entries), std::end(entries),
key);
86 if (
i == std::end(entries) ||
key < *
i)
88 ushort appleSymbol =
i->appleSymbol;
90 && (appleSymbol == kControlUnicode || appleSymbol == kCommandUnicode)) {
91 if (appleSymbol == kControlUnicode)
92 appleSymbol = kCommandUnicode;
94 appleSymbol = kControlUnicode;
97 return QChar(appleSymbol);
100static int qtkeyForAppleSymbol(
const QChar ch)
102 const ushort unicode =
ch.unicode();
103 for (
const AppleSpecialKey &
entry : entries) {
104 if (
entry.appleSymbol == unicode) {
107 && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
108 if (unicode == kControlUnicode)
386static constexpr struct {
787 if (!bindings.isEmpty()) {
788 d = bindings.constFirst().d;
856 :
QKeySequence(
k1.toCombined(), k2.toCombined(), k3.toCombined(), k4.toCombined())
946 if (p <= 0 || p >= (
int)
text.
size())
978int QKeySequence::assign(
const QString &ks)
1006 if (
p == keyseq.size() - 1) {
1009 if (u
',' == keyseq.at(
p+1))
1011 if (u
' ' == keyseq.at(
p+1)) {
1019 QString part = keyseq.
left(-1 ==
p ? keyseq.size() :
p - diff);
1020 keyseq = keyseq.
right(-1 ==
p ? 0 : keyseq.
size() - (
p + 1));
1044 accel = std::move(accel).toLower();
1047 QList<QModifKeyName> *gmodifs;
1049 gmodifs = globalModifs();
1050 if (gmodifs->isEmpty()) {
1051#if defined(Q_OS_APPLE)
1071 gmodifs = globalPortableModifs();
1072 if (gmodifs->isEmpty()) {
1082 QList<QModifKeyName> modifs;
1093#if defined(Q_OS_APPLE)
1094 for (
int i = 0;
i < modifs.size(); ++
i) {
1096 if (sl.contains(mkf.name)) {
1098 accel.remove(mkf.name);
1102 if (accel.isEmpty())
1108 while ((
i = sl.indexOf(u
'+',
i + 1)) != -1) {
1119 if (
sub.size() == 1) {
1121 if (accel.lastIndexOf(u
'+') != accel.size()-1)
1125 bool validModifier =
false;
1126 for (
int j = 0;
j < modifs.size(); ++
j) {
1128 if (
sub == mkf.name) {
1130 validModifier =
true;
1141 qsizetype p = accel.lastIndexOf(u
'+', accel.size() - 2);
1144 accelRef = accelRef.mid(
p + 1);
1147 if (accelRef.size() == 1) {
1148#if defined(Q_OS_APPLE)
1149 int qtKey = qtkeyForAppleSymbol(accelRef.at(0));
1155 ret |= accelRef.at(0).toUpper().unicode();
1157 }
else if (accelRef.at(0) == u
'f' && (fnum = accelRef.mid(1).toInt()) >= 1 && fnum <= 35) {
1164 for (
int tran = 0; tran < 2; ++tran) {
1171 if (accelRef == std::move(
keyName).toLower()) {
1206 const auto key = keyCombination.
key();
1214#if defined(Q_OS_APPLE)
1226 const int *modifierOrder;
1227 const int *qtkeyOrder;
1229 modifierOrder = DontSwapModifierOrder;
1230 qtkeyOrder = DontSwapQtKeyOrder;
1232 modifierOrder = ModifierOrder;
1233 qtkeyOrder = QtKeyOrder;
1236 for (
int i = 0; modifierOrder[
i] != 0; ++
i) {
1238 s += appleSymbolForQtKey(qtkeyOrder[
i]);
1258#if defined(Q_OS_APPLE)
1281 if (!QChar::requiresSurrogates(
key)) {
1292#if defined(Q_OS_APPLE)
1302#if defined(Q_OS_APPLE)
1318 if (!QChar::requiresSurrogates(
key)) {
1319 p = QChar::fromUcs2(
key).toUpper();
1347 for (
uint i = 0;
i < userN; ++
i) {
1349 sequenceKey = seq[
i];
1350 if (userKey != sequenceKey)
1407 return (d->
key[0] ==
other.d->key[0] &&
1505 for (
int i = 0;
i <
end; ++
i) {
1507 finalString +=
", "_L1;
1509 finalString.truncate(finalString.size() - 2);
1535 QList<QKeySequence>
result;
1570#if !defined(QT_NO_DATASTREAM)
1581 static_assert(
QKeySequencePrivate::MaxKeyCount == 4,
"Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");
1582 const bool extended =
s.
version() >= 5 && keysequence.count() > 1;
1585 s <<
quint32(keysequence.d->key[1])
1586 <<
quint32(keysequence.d->key[2])
1587 <<
quint32(keysequence.d->key[3]);
1609 qWarning(
"Premature EOF while reading QKeySequence");
1621#ifndef QT_NO_DEBUG_STREAM
1625 dbg.nospace() <<
"QKeySequence(" <<
p.toString() <<
')';
1642#include "moc_qkeysequence.cpp"
T loadRelaxed() const noexcept
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore\reentrant
int version() const
Returns the version number of the data serialization format.
static QPlatformTheme * platformTheme()
constexpr Qt::Key key() const noexcept
static constexpr QKeyCombination fromCombined(int combined)
constexpr int toCombined() const noexcept
constexpr Qt::KeyboardModifiers keyboardModifiers() const noexcept
static QString encodeString(QKeyCombination keyCombination, QKeySequence::SequenceFormat format)
static constexpr int MaxKeyCount
static Q_GUI_EXPORT QString keyName(Qt::Key key, QKeySequence::SequenceFormat format)
static QKeyCombination decodeString(QString accel, QKeySequence::SequenceFormat format)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
~QKeySequence()
Destroys the key sequence.
SequenceMatch matches(const QKeySequence &seq) const
Matches the sequence with seq.
QKeySequence & operator=(const QKeySequence &other)
Move-assigns other to this QKeySequence instance.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
bool operator<(const QKeySequence &ks) const
Provides an arbitrary comparison of this key sequence and other key sequence.
SequenceMatch
\value NoMatch The key sequences are different; not even partially matching.
static QKeySequence fromString(const QString &str, SequenceFormat format=PortableText)
int count() const
Returns the number of keys in the key sequence.
static QList< QKeySequence > keyBindings(StandardKey key)
static QList< QKeySequence > listFromString(const QString &str, SequenceFormat format=PortableText)
SequenceFormat
\value NativeText The key sequence as a platform specific string.
QKeyCombination operator[](uint i) const
Returns a reference to the element at position index in the key sequence.
static QString listToString(const QList< QKeySequence > &list, SequenceFormat format=PortableText)
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
bool operator==(const QKeySequence &other) const
Returns true if this key sequence is equal to the other key sequence; otherwise returns false.
QString toString(SequenceFormat format=PortableText) const
QKeySequence()
Constructs an empty key sequence.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
QString right(qsizetype n) const &
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QString toUpper() const &
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
EGLImageKHR int int EGLuint64KHR * modifiers
list append(new Employee("Blackpool", "Stephen"))
Combined button and popup list for selecting options.
@ Key_KeyboardBrightnessUp
@ Key_MediaTogglePlayPause
@ Key_KeyboardBrightnessDown
@ AA_MacDontSwapCtrlAndMeta
constexpr bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate p={})
QT_WARNING_POP void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
#define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter * sub
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0) noexcept(noexcept(qHash(*first)))
static Q_CONSTINIT bool qt_sequence_no_mnemonics
QDataStream & operator>>(QDataStream &s, QKeySequence &keysequence)
static constexpr int numKeyNames
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b)
QDataStream & operator<<(QDataStream &s, const QKeySequence &keysequence)
static constexpr struct @196 keyname[]
static void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLchar ** strings
[1]
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define Q_ASSERT_X(cond, x, msg)
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static QString qtKey(CFStringRef cfkey)
static QString keyName(const QString &rKey)
#define qPrintable(string)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
#define QT_TRANSLATE_NOOP(scope, x)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
QString decodeString(QCborStreamReader &reader)
[26]
QModifKeyName(int q, QChar n)
QModifKeyName(int q, const QString &n)