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