44 #include "private/qapplication_p.h" 46 #ifndef QT_NO_SHORTCUT 53 #ifndef QT_NO_DATASTREAM 59 # include <private/qt_mac_p.h> 103 return key < entry.
key;
111 if (i == MacSpecialKeyEntriesEnd)
115 && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
116 if (macSymbol == kControlUnicode)
117 macSymbol = kCommandUnicode;
119 macSymbol = kControlUnicode;
122 return QChar(macSymbol);
133 && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
134 if (unicode == kControlUnicode)
394 static const struct {
900 if (bindings.
size() > 0) {
989 uint oldshortcut = shortcut;
1017 QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
1023 QKeySequencePrivate::keyBindings[i].
shortcut;
1055 Q_ASSERT_X(index >= 0 && index < 4,
"QKeySequence::setKey",
"index out of range");
1114 if (p <= 0 || p >= (
int)text.
length())
1127 qWarning(
"QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'",
qPrintable(text));
1171 int p = 0,
diff = 0;
1175 while (keyseq.
length() && n < 4) {
1181 if (p == keyseq.
count() - 1) {
1195 keyseq = keyseq.
right(-1 == p ? 0 : keyseq.
length() - (p + 1));
1229 gmodifs = globalModifs();
1236 *gmodifs << QModifKeyName(
Qt::CTRL,
QChar(kCommandUnicode));
1237 *gmodifs << QModifKeyName(
Qt::ALT,
QChar(kOptionUnicode));
1239 *gmodifs << QModifKeyName(
Qt::CTRL,
QChar(kControlUnicode));
1241 *gmodifs << QModifKeyName(
Qt::META,
QChar(kControlUnicode));
1250 gmodifs = globalPortableModifs();
1258 if (!gmodifs)
return ret;
1272 for (
int i = 0; i < modifs.
size(); ++i) {
1284 const QString sub = sl.
mid(lastI, i - lastI + 1);
1289 for (
int j = 0; j < modifs.
size(); ++j) {
1291 if (sub == mkf.
name) {
1303 accel = accel.
mid(p + 1);
1306 if (accel.
length() == 1) {
1316 }
else if (accel[0] ==
QLatin1Char(
'f') && (fnum = accel.
mid(1).
toInt()) && (fnum >= 1) && (fnum <= 35)) {
1323 for (
int tran = 0; tran < 2; ++tran) {
1326 for (
int i = 0;
keyname[i].name; ++i) {
1330 if (accel == keyName.
toLower()) {
1365 #if defined(Q_WS_MAC) 1377 const int *modifierOrder;
1378 const int *qtkeyOrder;
1380 modifierOrder = DontSwapModifierOrder;
1381 qtkeyOrder = DontSwapQtKeyOrder;
1383 modifierOrder = ModifierOrder;
1384 qtkeyOrder = QtKeyOrder;
1387 for (
int i = 0; modifierOrder[i] != 0; ++i) {
1388 if (key & modifierOrder[i])
1399 if ((key &
Qt::ALT) == Qt::ALT)
1421 #if defined(Q_WS_MAC) 1483 for (
uint i = 0; i < userN; ++i) {
1484 int userKey = (*this)[i],
1485 sequenceKey = seq[i];
1486 if (userKey != sequenceKey)
1526 QKeySequence::operator int ()
const 1540 Q_ASSERT_X(index < 4,
"QKeySequence::operator[]",
"index out of range");
1583 return (
d->
key[0] == other.
d->
key[0] &&
1604 for (
int i = 0; i < 4; ++i)
1606 return d->
key[i] < other.
d->
key[i];
1682 for (
int i = 0; i <
end; ++i) {
1708 #if !defined(QT_NO_DATASTREAM) 1723 list << keysequence.
d->
key[0];
1726 list << keysequence.
d->
key[1];
1727 list << keysequence.
d->
key[2];
1728 list << keysequence.
d->
key[3];
1751 for (
int i = 0; i < 4; ++i)
1752 keysequence.
d->
key[i] = list.value(i);
1756 #endif //QT_NO_DATASTREAM 1758 #ifndef QT_NO_DEBUG_STREAM 1761 #ifndef Q_BROKEN_DEBUG_STREAM 1765 qWarning(
"This compiler doesn't support streaming QKeySequence to QDebug");
1772 #endif // QT_NO_SHORTCUT
The QVariant class acts like a union for the most common Qt data types.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QDebug class provides an output stream for debugging information.
QKeySequence::StandardKey standardKey
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
static QString keyName(const QString &rKey)
static const struct @203 keyname[]
QModifKeyName(int q, QChar n)
#define QT_END_NAMESPACE
This macro expands to.
const QChar at(int i) const
Returns the character at the given index position in the string.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if the character is the Unicode character 0x0000 ('\0'); otherwise returns false...
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
static QString encodeString(int key, QKeySequence::SequenceFormat format)
friend Q_GUI_EXPORT QDataStream & operator<<(QDataStream &in, const QKeySequence &ks)
Writes the key sequence to the stream.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
int length() const
Returns the number of characters in this string.
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
void setKey(int key, int index)
KeySequences should never be modified, but rather just created.
static bool match(const uchar *found, const char *target, uint len)
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
~QKeySequence()
Destroys the key sequence.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
StandardKey
This enum represent standard key bindings.
bool ref()
Atomically increments the value of this QAtomicInt.
static QList< QKeySequence > keyBindings(StandardKey key)
Returns a list of key bindings for the given key.
The QString class provides a Unicode character string.
static QString encodeString(int key)
Creates a shortcut string for key.
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
The QChar class provides a 16-bit Unicode character.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
static ushort highSurrogate(uint ucs4)
Returns the high surrogate value of a ucs4 code point.
int operator[](uint i) const
Returns a reference to the element at position index in the key sequence.
static ushort lowSurrogate(uint ucs4)
Returns the low surrogate value of a ucs4 code point.
static uint currentPlatform()
void append(const T &t)
Inserts value at the end of the list.
static void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool requiresSurrogates(uint ucs4)
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
void truncate(int pos)
Truncates the string at the given position index.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
static QKeySequence fromString(const QString &str, SequenceFormat format=PortableText)
Return a QKeySequence from the string str based on format.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b)
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
void prepend(const T &t)
Inserts value at the beginning of the list.
const T & at(int i) const
Returns the item at index position i in the list.
bool deref()
Atomically decrements the value of this QAtomicInt.
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static const int NumEntries
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
QString toString(SequenceFormat format=PortableText) const
Return a string representation of the key sequence, based on format.
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
static int decodeString(const QString &ks)
Constructs a single key from the string str.
int version() const
Returns the version number of the data serialization format.
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &in, QKeySequence &ks)
Reads a key sequence from the stream into the key sequence.
T & first()
Returns a reference to the first item in the list.
static const MacSpecialKey entries[NumEntries]
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
#define Q_ASSERT_X(cond, where, what)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
The QKeySequence class encapsulates a key sequence as used by shortcuts.
int assign(const QString &str)
Adds the given keys to the key sequence.
static bool qt_sequence_no_mnemonics
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static int decodeString(const QString &keyStr, QKeySequence::SequenceFormat format)
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
static const uint numberOfKeyBindings
QKeySequence & operator=(const QKeySequence &other)
Assignment operator.
int size() const
Returns the number of items in the list.
void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
uint count() const
Returns the number of keys in the key sequence.
bool operator<(const QKeySequence &ks) const
Provides an arbitrary comparison of this key sequence and other key sequence.
QKeySequence()
Constructs an empty key sequence.
static const QKeyBinding keyBindings[]
static int qtkeyForMacSymbol(const QChar ch)
The QDataStream class provides serialization of binary data to a QIODevice.
QChar qt_macSymbolForQtKey(int key)
bool operator==(const QKeySequence &other) const
Returns true if this key sequence is equal to the other key sequence; otherwise returns false...
static QString qtKey(CFStringRef cfkey)
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
static const KeyPair *const end
static const MacSpecialKey *const MacSpecialKeyEntriesEnd
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
SequenceFormat
This means that it will be shown translated and on the Mac it will resemble a key sequence from the m...
#define qPrintable(string)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static bool operator<(const MacSpecialKey &entry, int key)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static int maybeSwapShortcut(int shortcut)
SequenceMatch matches(const QKeySequence &seq) const
Matches the sequence with seq.
QModifKeyName(int q, const QString &n)