QtBase  v6.3.1
qkeysequence.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QKEYSEQUENCE_H
41 #define QKEYSEQUENCE_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtCore/qstring.h>
45 #include <QtCore/qobjectdefs.h>
46 
48 
50 
51 class QKeySequence;
52 
53 /*****************************************************************************
54  QKeySequence stream functions
55  *****************************************************************************/
56 #if !defined(QT_NO_DATASTREAM) || defined(Q_CLANG_QDOC)
57 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
59 #endif
60 
61 #if defined(Q_CLANG_QDOC)
63 #endif
64 
65 class QVariant;
67 
68 Q_GUI_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QKeySequence &key, size_t seed = 0) noexcept;
69 
70 class Q_GUI_EXPORT QKeySequence
71 {
72  Q_GADGET
73 
74 public:
75  enum StandardKey {
82  New,
84  Cut,
146  Cancel
147  };
148  Q_ENUM(StandardKey)
149 
152  PortableText
153  };
154 
155  QKeySequence();
156  QKeySequence(const QString &key, SequenceFormat format = NativeText);
157  QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
162  QKeySequence(const QKeySequence &ks);
163  QKeySequence(StandardKey key);
164  ~QKeySequence();
165 
166  int count() const;
167  bool isEmpty() const;
168 
172  ExactMatch
173  };
174 
175  QString toString(SequenceFormat format = PortableText) const;
176  static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
177 
178  static QList<QKeySequence> listFromString(const QString &str, SequenceFormat format = PortableText);
179  static QString listToString(const QList<QKeySequence> &list, SequenceFormat format = PortableText);
180 
181  SequenceMatch matches(const QKeySequence &seq) const;
182  static QKeySequence mnemonic(const QString &text);
183  static QList<QKeySequence> keyBindings(StandardKey key);
184 
185  operator QVariant() const;
186  QKeyCombination operator[](uint i) const;
187  QKeySequence &operator=(const QKeySequence &other);
189  void swap(QKeySequence &other) noexcept { qt_ptr_swap(d, other.d); }
190 
191  bool operator==(const QKeySequence &other) const;
192  inline bool operator!= (const QKeySequence &other) const
193  { return !(*this == other); }
194  bool operator< (const QKeySequence &ks) const;
195  inline bool operator> (const QKeySequence &other) const
196  { return other < *this; }
197  inline bool operator<= (const QKeySequence &other) const
198  { return !(other < *this); }
199  inline bool operator>= (const QKeySequence &other) const
200  { return !(*this < other); }
201 
202  bool isDetached() const;
203 private:
204  static int decodeString(const QString &ks);
205  static QString encodeString(int key);
206  int assign(const QString &str);
207  int assign(const QString &str, SequenceFormat format);
208  void setKey(QKeyCombination key, int index);
209 
211 
212  friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
213  friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
214  friend Q_GUI_EXPORT size_t qHash(const QKeySequence &key, size_t seed) noexcept;
215  friend class QShortcutMap;
216  friend class QShortcut;
217 
218 public:
220  inline DataPtr &data_ptr() { return d; }
221 };
222 
224 
225 #if !defined(QT_NO_DEBUG_STREAM) || defined(Q_CLANG_QDOC)
226 Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
227 #endif
228 
230 
231 #endif // QKEYSEQUENCE_H
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
template< typename Enum > bool operator!=(Enum lhs, QFlags< Enum > rhs)
template< typename Enum > size_t qHash(QFlags< Enum > flags, size_t seed=0) noexcept
template< typename Enum > bool operator==(Enum lhs, QFlags< Enum > rhs)
static constexpr QKeyCombination fromCombined(int combined)
Definition: qnamespace.h:1897
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:71
DataPtr & data_ptr()
Definition: qkeysequence.h:220
@ InsertParagraphSeparator
Definition: qkeysequence.h:137
void qt_set_sequence_auto_mnemonic(bool b)
QKeySequencePrivate * DataPtr
Definition: qkeysequence.h:219
static QString encodeString(int key, QKeySequence::SequenceFormat format)
The QShortcut class is used to create keyboard shortcuts.
Definition: qshortcut.h:55
The QString class provides a Unicode character string.
Definition: qstring.h:388
bool operator<=(const QUuid &lhs, const QUuid &rhs)
Definition: quuid.h:216
bool operator>=(const QUuid &lhs, const QUuid &rhs)
Definition: quuid.h:218
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
QString str
[2]
QString text
[meta data]
void
Definition: png.h:1080
#define Q_DECL_PURE_FUNCTION
constexpr bool operator>(const QFixed &f, int i)
Definition: qfixed_p.h:182
unsigned int uint
Definition: qglobal.h:334
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
Definition: qglobal.h:563
QT_REQUIRE_CONFIG(shortcut)
GLboolean GLboolean GLboolean b
GLuint64 key
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum format
GLuint in
Definition: qopenglext.h:8870
#define k1
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_GADGET
Definition: qtmetamacros.h:193
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
QTextStream out(stdout)
[7]
QString decodeString(QCborStreamReader &reader)
[26]
QSharedPointer< T > other(t)
[5]
this swap(other)
setKey(0)
[0]
QStringList list
[0]