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.
size() > 0) {
788 d = bindings.
first().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)) {
1020 keyseq = keyseq.
right(-1 ==
p ? 0 : keyseq.
size() - (
p + 1));
1042int QKeySequence::decodeString(
const QString &
str)
1052 accel = std::move(accel).
toLower();
1057 gmodifs = globalModifs();
1059#if defined(Q_OS_APPLE)
1079 gmodifs = globalPortableModifs();
1101#if defined(Q_OS_APPLE)
1102 for (
int i = 0;
i < modifs.
size(); ++
i) {
1116 while ((
i = sl.
indexOf(u
'+',
i + 1)) != -1) {
1127 if (
sub.size() == 1) {
1133 bool validModifier =
false;
1134 for (
int j = 0;
j < modifs.
size(); ++
j) {
1138 validModifier =
true;
1152 accelRef = accelRef.
mid(
p + 1);
1155 if (accelRef.
size() == 1) {
1156#if defined(Q_OS_APPLE)
1157 int qtKey = qtkeyForAppleSymbol(accelRef.
at(0));
1165 }
else if (accelRef.
at(0) == u
'f' && (fnum = accelRef.
mid(1).
toInt()) >= 1 && fnum <= 35) {
1172 for (
int tran = 0; tran < 2; ++tran) {
1179 if (accelRef == std::move(
keyName).toLower()) {
1228#if defined(Q_OS_APPLE)
1240 const int *modifierOrder;
1241 const int *qtkeyOrder;
1243 modifierOrder = DontSwapModifierOrder;
1244 qtkeyOrder = DontSwapQtKeyOrder;
1246 modifierOrder = ModifierOrder;
1247 qtkeyOrder = QtKeyOrder;
1250 for (
int i = 0; modifierOrder[
i] != 0; ++
i) {
1251 if (
key & modifierOrder[
i])
1252 s += appleSymbolForQtKey(qtkeyOrder[
i]);
1272#if defined(Q_OS_APPLE)
1307#if defined(Q_OS_APPLE)
1317#if defined(Q_OS_APPLE)
1362 for (
uint i = 0;
i < userN; ++
i) {
1364 sequenceKey = seq[
i];
1365 if (userKey != sequenceKey)
1422 return (d->
key[0] ==
other.d->key[0] &&
1520 for (
int i = 0;
i <
end; ++
i) {
1522 finalString +=
", "_L1;
1585#if !defined(QT_NO_DATASTREAM)
1596 static_assert(
QKeySequencePrivate::MaxKeyCount == 4,
"Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");
1597 const bool extended =
s.
version() >= 5 && keysequence.
count() > 1;
1624 qWarning(
"Premature EOF while reading QKeySequence");
1636#ifndef QT_NO_DEBUG_STREAM
1640 dbg.nospace() <<
"QKeySequence(" <<
p.toString() <<
')';
1657#include "moc_qkeysequence.cpp"
T loadRelaxed() const noexcept
static constexpr QChar fromUcs2(char16_t c) noexcept
static constexpr bool requiresSurrogates(char32_t ucs4) noexcept
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
static constexpr char16_t highSurrogate(char32_t ucs4) noexcept
Returns the high surrogate part of a UCS-4-encoded code point.
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
static constexpr char16_t lowSurrogate(char32_t ucs4) noexcept
Returns the low surrogate part of a UCS-4-encoded code point.
QChar toUpper() const noexcept
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
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()
static constexpr QKeyCombination fromCombined(int combined)
static Q_GUI_EXPORT QString keyName(int key, QKeySequence::SequenceFormat format)
static QString encodeString(int key, QKeySequence::SequenceFormat format)
static int 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.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
int toInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an int using base base, which is 10 by default and must be betwe...
constexpr QChar at(qsizetype n) const noexcept
Returns the character at position n in this string view.
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 right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
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.
void truncate(qsizetype pos)
Truncates the string at the given position index.
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toLower() const &
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
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 >
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 struct @200 keyname[]
static constexpr int numKeyNames
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b)
QDataStream & operator<<(QDataStream &s, const QKeySequence &keysequence)
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)
#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)
QModifKeyName(int q, QChar n)
QModifKeyName(int q, const QString &n)