qkeysequence.sip 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. // qkeysequence.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QKeySequence /TypeHintIn="Union[QKeySequence, QKeySequence.StandardKey, QString, int]"/
  22. {
  23. %TypeHeaderCode
  24. #include <qkeysequence.h>
  25. %End
  26. %ConvertToTypeCode
  27. // Allow a StandardKey, QString or an integer whenever a QKeySequence is
  28. // expected.
  29. if (sipIsErr == NULL)
  30. {
  31. if (sipCanConvertToType(sipPy, sipType_QKeySequence, SIP_NO_CONVERTORS))
  32. return 1;
  33. PyErr_Clear();
  34. sipConvertToEnum(sipPy, sipType_QKeySequence_StandardKey);
  35. if (!PyErr_Occurred())
  36. return 1;
  37. if (sipCanConvertToType(sipPy, sipType_QString, 0))
  38. return 1;
  39. PyErr_Clear();
  40. PyLong_AsLong(sipPy);
  41. return !PyErr_Occurred();
  42. }
  43. if (sipCanConvertToType(sipPy, sipType_QKeySequence, SIP_NO_CONVERTORS))
  44. {
  45. *sipCppPtr = reinterpret_cast<QKeySequence *>(sipConvertToType(sipPy, sipType_QKeySequence, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
  46. return 0;
  47. }
  48. PyErr_Clear();
  49. int skey = sipConvertToEnum(sipPy, sipType_QKeySequence_StandardKey);
  50. if (!PyErr_Occurred())
  51. {
  52. *sipCppPtr = new QKeySequence(static_cast<QKeySequence::StandardKey>(skey));
  53. return sipGetState(sipTransferObj);
  54. }
  55. PyErr_Clear();
  56. if (sipCanConvertToType(sipPy, sipType_QString, 0))
  57. {
  58. int state;
  59. QString *qs = reinterpret_cast<QString *>(sipConvertToType(sipPy, sipType_QString, 0, 0, &state, sipIsErr));
  60. if (*sipIsErr)
  61. {
  62. sipReleaseType(qs, sipType_QString, state);
  63. return 0;
  64. }
  65. *sipCppPtr = new QKeySequence(*qs);
  66. sipReleaseType(qs, sipType_QString, state);
  67. return sipGetState(sipTransferObj);
  68. }
  69. int key = PyLong_AsLong(sipPy);
  70. *sipCppPtr = new QKeySequence(key);
  71. return sipGetState(sipTransferObj);
  72. %End
  73. %PickleCode
  74. sipRes = Py_BuildValue("iiii", sipCpp->operator[](0), sipCpp->operator[](1), sipCpp->operator[](2), sipCpp->operator[](3));
  75. %End
  76. public:
  77. enum SequenceFormat
  78. {
  79. NativeText,
  80. PortableText,
  81. };
  82. enum SequenceMatch
  83. {
  84. NoMatch,
  85. PartialMatch,
  86. ExactMatch,
  87. };
  88. enum StandardKey
  89. {
  90. UnknownKey,
  91. HelpContents,
  92. WhatsThis,
  93. Open,
  94. Close,
  95. Save,
  96. New,
  97. Delete,
  98. Cut,
  99. Copy,
  100. Paste,
  101. Undo,
  102. Redo,
  103. Back,
  104. Forward,
  105. Refresh,
  106. ZoomIn,
  107. ZoomOut,
  108. Print,
  109. AddTab,
  110. NextChild,
  111. PreviousChild,
  112. Find,
  113. FindNext,
  114. FindPrevious,
  115. Replace,
  116. SelectAll,
  117. Bold,
  118. Italic,
  119. Underline,
  120. MoveToNextChar,
  121. MoveToPreviousChar,
  122. MoveToNextWord,
  123. MoveToPreviousWord,
  124. MoveToNextLine,
  125. MoveToPreviousLine,
  126. MoveToNextPage,
  127. MoveToPreviousPage,
  128. MoveToStartOfLine,
  129. MoveToEndOfLine,
  130. MoveToStartOfBlock,
  131. MoveToEndOfBlock,
  132. MoveToStartOfDocument,
  133. MoveToEndOfDocument,
  134. SelectNextChar,
  135. SelectPreviousChar,
  136. SelectNextWord,
  137. SelectPreviousWord,
  138. SelectNextLine,
  139. SelectPreviousLine,
  140. SelectNextPage,
  141. SelectPreviousPage,
  142. SelectStartOfLine,
  143. SelectEndOfLine,
  144. SelectStartOfBlock,
  145. SelectEndOfBlock,
  146. SelectStartOfDocument,
  147. SelectEndOfDocument,
  148. DeleteStartOfWord,
  149. DeleteEndOfWord,
  150. DeleteEndOfLine,
  151. InsertParagraphSeparator,
  152. InsertLineSeparator,
  153. SaveAs,
  154. Preferences,
  155. Quit,
  156. FullScreen,
  157. Deselect,
  158. DeleteCompleteLine,
  159. Backspace,
  160. Cancel,
  161. };
  162. QKeySequence();
  163. QKeySequence(const QKeySequence &ks /Constrained/);
  164. QKeySequence(QKeySequence::StandardKey key);
  165. QKeySequence(const QString &key, QKeySequence::SequenceFormat format = QKeySequence::NativeText);
  166. QKeySequence(int k1, int key2 = 0, int key3 = 0, int key4 = 0);
  167. QKeySequence(QKeyCombination k1, QKeyCombination key2 = QKeyCombination::fromCombined(0), QKeyCombination key3 = QKeyCombination::fromCombined(0), QKeyCombination key4 = QKeyCombination::fromCombined(0));
  168. QKeySequence(const QVariant &variant /GetWrapper/) /NoDerived/;
  169. %MethodCode
  170. if (a0->canConvert<QKeySequence>())
  171. sipCpp = new QKeySequence(a0->value<QKeySequence>());
  172. else
  173. sipError = sipBadCallableArg(0, a0Wrapper);
  174. %End
  175. ~QKeySequence();
  176. int count() const /__len__/;
  177. bool isEmpty() const;
  178. QKeySequence::SequenceMatch matches(const QKeySequence &seq) const;
  179. static QKeySequence mnemonic(const QString &text);
  180. QKeyCombination operator[](int i) const;
  181. %MethodCode
  182. Py_ssize_t idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
  183. if (idx < 0)
  184. sipIsErr = 1;
  185. else
  186. sipRes = new QKeyCombination(sipCpp->operator[]((uint)idx));
  187. %End
  188. bool operator==(const QKeySequence &other) const;
  189. bool operator!=(const QKeySequence &other) const;
  190. bool operator<(const QKeySequence &ks) const;
  191. bool operator>(const QKeySequence &other) const;
  192. bool operator<=(const QKeySequence &other) const;
  193. bool operator>=(const QKeySequence &other) const;
  194. bool isDetached() const;
  195. void swap(QKeySequence &other /Constrained/);
  196. QString toString(QKeySequence::SequenceFormat format = QKeySequence::PortableText) const;
  197. static QKeySequence fromString(const QString &str, QKeySequence::SequenceFormat format = QKeySequence::PortableText);
  198. static QList<QKeySequence> keyBindings(QKeySequence::StandardKey key);
  199. static QList<QKeySequence> listFromString(const QString &str, QKeySequence::SequenceFormat format = QKeySequence::PortableText);
  200. static QString listToString(const QList<QKeySequence> &list, QKeySequence::SequenceFormat format = QKeySequence::PortableText);
  201. Py_hash_t __hash__() const;
  202. %MethodCode
  203. sipRes = qHash(*sipCpp);
  204. %End
  205. };
  206. QDataStream &operator<<(QDataStream &in, const QKeySequence &ks) /ReleaseGIL/;
  207. QDataStream &operator>>(QDataStream &out, QKeySequence &ks /Constrained/) /ReleaseGIL/;
  208. void qt_set_sequence_auto_mnemonic(bool b);