1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.gui.keysequence; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.list; 17 import qt.core.metamacros; 18 import qt.core.namespace; 19 import qt.core.string; 20 import qt.core.typeinfo; 21 import qt.core.variant; 22 import qt.helpers; 23 24 /+ QT_REQUIRE_CONFIG(shortcut); 25 26 27 28 /***************************************************************************** 29 QKeySequence stream functions 30 *****************************************************************************/ 31 #if !defined(QT_NO_DATASTREAM) || defined(Q_CLANG_QDOC) 32 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); 33 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks); 34 #endif 35 36 #if defined(Q_CLANG_QDOC) 37 void qt_set_sequence_auto_mnemonic(bool b); 38 #endif +/ 39 40 extern(C++, class) struct QKeySequencePrivate; 41 42 /+ Q_GUI_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QKeySequence &key, size_t seed = 0) noexcept; +/ 43 44 /// Binding for C++ class [QKeySequence](https://doc.qt.io/qt-6/qkeysequence.html). 45 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QKeySequence 46 { 47 mixin(Q_GADGET); 48 49 public: 50 enum StandardKey { 51 UnknownKey, 52 HelpContents, 53 WhatsThis, 54 Open, 55 Close, 56 Save, 57 New, 58 Delete, 59 Cut, 60 Copy, 61 Paste, 62 Undo, 63 Redo, 64 Back, 65 Forward, 66 Refresh, 67 ZoomIn, 68 ZoomOut, 69 Print, 70 AddTab, 71 NextChild, 72 PreviousChild, 73 Find, 74 FindNext, 75 FindPrevious, 76 Replace, 77 SelectAll, 78 Bold, 79 Italic, 80 Underline, 81 MoveToNextChar, 82 MoveToPreviousChar, 83 MoveToNextWord, 84 MoveToPreviousWord, 85 MoveToNextLine, 86 MoveToPreviousLine, 87 MoveToNextPage, 88 MoveToPreviousPage, 89 MoveToStartOfLine, 90 MoveToEndOfLine, 91 MoveToStartOfBlock, 92 MoveToEndOfBlock, 93 MoveToStartOfDocument, 94 MoveToEndOfDocument, 95 SelectNextChar, 96 SelectPreviousChar, 97 SelectNextWord, 98 SelectPreviousWord, 99 SelectNextLine, 100 SelectPreviousLine, 101 SelectNextPage, 102 SelectPreviousPage, 103 SelectStartOfLine, 104 SelectEndOfLine, 105 SelectStartOfBlock, 106 SelectEndOfBlock, 107 SelectStartOfDocument, 108 SelectEndOfDocument, 109 DeleteStartOfWord, 110 DeleteEndOfWord, 111 DeleteEndOfLine, 112 InsertParagraphSeparator, 113 InsertLineSeparator, 114 SaveAs, 115 Preferences, 116 Quit, 117 FullScreen, 118 Deselect, 119 DeleteCompleteLine, 120 Backspace, 121 Cancel 122 } 123 /+ Q_ENUM(StandardKey) +/ 124 125 enum SequenceFormat { 126 NativeText, 127 PortableText 128 } 129 130 @disable this(); 131 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 132 ref typeof(this) rawConstructor(); 133 static typeof(this) create() 134 { 135 typeof(this) r = typeof(this).init; 136 r.rawConstructor(); 137 return r; 138 } 139 140 this(ref const(QString) key, SequenceFormat format = SequenceFormat.NativeText); 141 this(int k1, int k2 = 0, int k3 = 0, int k4 = 0); 142 this(QKeyCombination k1, 143 QKeyCombination k2 = QKeyCombination.fromCombined(0), 144 QKeyCombination k3 = QKeyCombination.fromCombined(0), 145 QKeyCombination k4 = QKeyCombination.fromCombined(0)); 146 @disable this(this); 147 this(ref const(QKeySequence) ks); 148 this(StandardKey key); 149 ~this(); 150 151 int count() const; 152 bool isEmpty() const; 153 154 enum SequenceMatch { 155 NoMatch, 156 PartialMatch, 157 ExactMatch 158 } 159 160 QString toString(SequenceFormat format = SequenceFormat.PortableText) const; 161 static QKeySequence fromString(ref const(QString) str, SequenceFormat format = SequenceFormat.PortableText); 162 163 /+ static QList!(QKeySequence) listFromString(ref const(QString) str, SequenceFormat format = SequenceFormat.PortableText); 164 static QString listToString(ref const(QList!(QKeySequence)) list, SequenceFormat format = SequenceFormat.PortableText); +/ 165 166 SequenceMatch matches(ref const(QKeySequence) seq) const; 167 static QKeySequence mnemonic(ref const(QString) text); 168 // static QList!(QKeySequence) keyBindings(StandardKey key); 169 170 /+auto opCast(T : QVariant)() const;+/ 171 QKeyCombination opIndex(uint i) const; 172 /+ref QKeySequence operator =(ref const(QKeySequence) other);+/ 173 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QKeySequence) +/ 174 /+ void swap(QKeySequence &other) noexcept { qSwap(d, other.d); } +/ 175 176 /+bool operator ==(ref const(QKeySequence) other) const;+/ 177 /+pragma(inline, true) bool operator != (ref const(QKeySequence) other) const 178 { return !(this == other); }+/ 179 /+bool operator < (ref const(QKeySequence) ks) const;+/ 180 /+pragma(inline, true) bool operator > (ref const(QKeySequence) other) const 181 { return other < this; }+/ 182 /+pragma(inline, true) bool operator <= (ref const(QKeySequence) other) const 183 { return !(other < this); }+/ 184 /+pragma(inline, true) bool operator >= (ref const(QKeySequence) other) const 185 { return !(this < other); }+/ 186 187 bool isDetached() const; 188 private: 189 static int decodeString(ref const(QString) ks); 190 static QString encodeString(int key); 191 int assign(ref const(QString) str); 192 int assign(ref const(QString) str, SequenceFormat format); 193 void setKey(QKeyCombination key, int index); 194 195 QKeySequencePrivate* d; 196 197 /+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); +/ 198 /+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks); +/ 199 /+ friend Q_GUI_EXPORT size_t qHash(const QKeySequence &key, size_t seed) noexcept; +/ 200 /+ friend class QShortcutMap; +/ 201 /+ friend class QShortcut; +/ 202 203 public: 204 alias DataPtr = QKeySequencePrivate*; 205 pragma(inline, true) ref DataPtr data_ptr() return { return d; } 206 mixin(CREATE_CONVENIENCE_WRAPPERS); 207 } 208 209 /+ Q_DECLARE_SHARED(QKeySequence) 210 211 #if !defined(QT_NO_DEBUG_STREAM) || defined(Q_CLANG_QDOC) 212 Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &); 213 #endif +/ 214