| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QKEYSEQUENCE_H
|
|---|
| 43 | #define QKEYSEQUENCE_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qnamespace.h>
|
|---|
| 46 | #include <QtCore/qstring.h>
|
|---|
| 47 |
|
|---|
| 48 | QT_BEGIN_HEADER
|
|---|
| 49 |
|
|---|
| 50 | QT_BEGIN_NAMESPACE
|
|---|
| 51 |
|
|---|
| 52 | QT_MODULE(Gui)
|
|---|
| 53 |
|
|---|
| 54 | #ifndef QT_NO_SHORTCUT
|
|---|
| 55 |
|
|---|
| 56 | /*****************************************************************************
|
|---|
| 57 | QKeySequence stream functions
|
|---|
| 58 | *****************************************************************************/
|
|---|
| 59 | #ifndef QT_NO_DATASTREAM
|
|---|
| 60 | class QKeySequence;
|
|---|
| 61 | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
|
|---|
| 62 | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 | #ifdef qdoc
|
|---|
| 66 | void qt_set_sequence_auto_mnemonic(bool b);
|
|---|
| 67 | #endif
|
|---|
| 68 |
|
|---|
| 69 | class QVariant;
|
|---|
| 70 | class QKeySequencePrivate;
|
|---|
| 71 |
|
|---|
| 72 | class Q_GUI_EXPORT QKeySequence
|
|---|
| 73 | {
|
|---|
| 74 | public:
|
|---|
| 75 | enum StandardKey {
|
|---|
| 76 | UnknownKey,
|
|---|
| 77 | HelpContents,
|
|---|
| 78 | WhatsThis,
|
|---|
| 79 | Open,
|
|---|
| 80 | Close,
|
|---|
| 81 | Save,
|
|---|
| 82 | New,
|
|---|
| 83 | Delete,
|
|---|
| 84 | Cut,
|
|---|
| 85 | Copy,
|
|---|
| 86 | Paste,
|
|---|
| 87 | Undo,
|
|---|
| 88 | Redo,
|
|---|
| 89 | Back,
|
|---|
| 90 | Forward,
|
|---|
| 91 | Refresh,
|
|---|
| 92 | ZoomIn,
|
|---|
| 93 | ZoomOut,
|
|---|
| 94 | Print,
|
|---|
| 95 | AddTab,
|
|---|
| 96 | NextChild,
|
|---|
| 97 | PreviousChild,
|
|---|
| 98 | Find,
|
|---|
| 99 | FindNext,
|
|---|
| 100 | FindPrevious,
|
|---|
| 101 | Replace,
|
|---|
| 102 | SelectAll,
|
|---|
| 103 | Bold,
|
|---|
| 104 | Italic,
|
|---|
| 105 | Underline,
|
|---|
| 106 | MoveToNextChar,
|
|---|
| 107 | MoveToPreviousChar,
|
|---|
| 108 | MoveToNextWord,
|
|---|
| 109 | MoveToPreviousWord,
|
|---|
| 110 | MoveToNextLine,
|
|---|
| 111 | MoveToPreviousLine,
|
|---|
| 112 | MoveToNextPage,
|
|---|
| 113 | MoveToPreviousPage,
|
|---|
| 114 | MoveToStartOfLine,
|
|---|
| 115 | MoveToEndOfLine,
|
|---|
| 116 | MoveToStartOfBlock,
|
|---|
| 117 | MoveToEndOfBlock,
|
|---|
| 118 | MoveToStartOfDocument,
|
|---|
| 119 | MoveToEndOfDocument,
|
|---|
| 120 | SelectNextChar,
|
|---|
| 121 | SelectPreviousChar,
|
|---|
| 122 | SelectNextWord,
|
|---|
| 123 | SelectPreviousWord,
|
|---|
| 124 | SelectNextLine,
|
|---|
| 125 | SelectPreviousLine,
|
|---|
| 126 | SelectNextPage,
|
|---|
| 127 | SelectPreviousPage,
|
|---|
| 128 | SelectStartOfLine,
|
|---|
| 129 | SelectEndOfLine,
|
|---|
| 130 | SelectStartOfBlock,
|
|---|
| 131 | SelectEndOfBlock,
|
|---|
| 132 | SelectStartOfDocument,
|
|---|
| 133 | SelectEndOfDocument,
|
|---|
| 134 | DeleteStartOfWord,
|
|---|
| 135 | DeleteEndOfWord,
|
|---|
| 136 | DeleteEndOfLine,
|
|---|
| 137 | InsertParagraphSeparator,
|
|---|
| 138 | InsertLineSeparator,
|
|---|
| 139 | SaveAs
|
|---|
| 140 | };
|
|---|
| 141 |
|
|---|
| 142 | QKeySequence();
|
|---|
| 143 | QKeySequence(const QString &key);
|
|---|
| 144 | QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
|
|---|
| 145 | QKeySequence(const QKeySequence &ks);
|
|---|
| 146 | QKeySequence(StandardKey key);
|
|---|
| 147 | ~QKeySequence();
|
|---|
| 148 |
|
|---|
| 149 | uint count() const; // ### Qt 5: return 'int'
|
|---|
| 150 | bool isEmpty() const;
|
|---|
| 151 |
|
|---|
| 152 | enum SequenceMatch {
|
|---|
| 153 | NoMatch,
|
|---|
| 154 | PartialMatch,
|
|---|
| 155 | ExactMatch
|
|---|
| 156 | #ifdef QT3_SUPPORT
|
|---|
| 157 | , Identical = ExactMatch
|
|---|
| 158 | #endif
|
|---|
| 159 | };
|
|---|
| 160 |
|
|---|
| 161 | enum SequenceFormat {
|
|---|
| 162 | NativeText,
|
|---|
| 163 | PortableText
|
|---|
| 164 | };
|
|---|
| 165 |
|
|---|
| 166 | QString toString(SequenceFormat format = PortableText) const;
|
|---|
| 167 | static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
|
|---|
| 168 |
|
|---|
| 169 | SequenceMatch matches(const QKeySequence &seq) const;
|
|---|
| 170 | static QKeySequence mnemonic(const QString &text);
|
|---|
| 171 | static QList<QKeySequence> keyBindings(StandardKey key);
|
|---|
| 172 |
|
|---|
| 173 | // ### Qt 5: kill 'operator QString' - it's evil
|
|---|
| 174 | operator QString() const;
|
|---|
| 175 | operator QVariant() const;
|
|---|
| 176 | operator int() const;
|
|---|
| 177 | int operator[](uint i) const;
|
|---|
| 178 | QKeySequence &operator=(const QKeySequence &other);
|
|---|
| 179 | bool operator==(const QKeySequence &other) const;
|
|---|
| 180 | inline bool operator!= (const QKeySequence &other) const
|
|---|
| 181 | { return !(*this == other); }
|
|---|
| 182 | bool operator< (const QKeySequence &ks) const;
|
|---|
| 183 | inline bool operator> (const QKeySequence &other) const
|
|---|
| 184 | { return other < *this; }
|
|---|
| 185 | inline bool operator<= (const QKeySequence &other) const
|
|---|
| 186 | { return !(other < *this); }
|
|---|
| 187 | inline bool operator>= (const QKeySequence &other) const
|
|---|
| 188 | { return !(*this < other); }
|
|---|
| 189 |
|
|---|
| 190 | bool isDetached() const;
|
|---|
| 191 | private:
|
|---|
| 192 | static int decodeString(const QString &ks);
|
|---|
| 193 | static QString encodeString(int key);
|
|---|
| 194 | int assign(const QString &str);
|
|---|
| 195 | void setKey(int key, int index);
|
|---|
| 196 |
|
|---|
| 197 | QKeySequencePrivate *d;
|
|---|
| 198 |
|
|---|
| 199 | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
|
|---|
| 200 | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
|
|---|
| 201 | friend class Q3AccelManager;
|
|---|
| 202 | friend class QShortcutMap;
|
|---|
| 203 | friend class QShortcut;
|
|---|
| 204 |
|
|---|
| 205 | public:
|
|---|
| 206 | typedef QKeySequencePrivate * DataPtr;
|
|---|
| 207 | inline DataPtr &data_ptr() { return d; }
|
|---|
| 208 | };
|
|---|
| 209 | Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
|
|---|
| 210 | Q_DECLARE_SHARED(QKeySequence)
|
|---|
| 211 |
|
|---|
| 212 | #ifndef QT_NO_DEBUG_STREAM
|
|---|
| 213 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
|
|---|
| 214 | #endif
|
|---|
| 215 |
|
|---|
| 216 | #else
|
|---|
| 217 |
|
|---|
| 218 | class Q_GUI_EXPORT QKeySequence
|
|---|
| 219 | {
|
|---|
| 220 | public:
|
|---|
| 221 | QKeySequence() {}
|
|---|
| 222 | QKeySequence(int) {}
|
|---|
| 223 | };
|
|---|
| 224 |
|
|---|
| 225 | #endif // QT_NO_SHORTCUT
|
|---|
| 226 |
|
|---|
| 227 | QT_END_NAMESPACE
|
|---|
| 228 |
|
|---|
| 229 | QT_END_HEADER
|
|---|
| 230 |
|
|---|
| 231 | #endif // QKEYSEQUENCE_H
|
|---|