| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | #ifndef QIBUSTYPES_H |
| 4 | #define QIBUSTYPES_H |
| 5 | |
| 6 | #include <qlist.h> |
| 7 | #include <qevent.h> |
| 8 | #include <QDBusArgument> |
| 9 | #include <QTextCharFormat> |
| 10 | #include <QLoggingCategory> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | Q_DECLARE_LOGGING_CATEGORY(qtQpaInputMethods) |
| 15 | Q_DECLARE_LOGGING_CATEGORY(qtQpaInputMethodsSerialize) |
| 16 | |
| 17 | class QIBusSerializable |
| 18 | { |
| 19 | public: |
| 20 | QIBusSerializable(); |
| 21 | |
| 22 | void serializeTo(QDBusArgument &argument) const; |
| 23 | void deserializeFrom(const QDBusArgument &argument); |
| 24 | |
| 25 | QString name; |
| 26 | QHash<QString, QDBusArgument> attachments; |
| 27 | }; |
| 28 | |
| 29 | class QIBusAttribute : private QIBusSerializable |
| 30 | { |
| 31 | public: |
| 32 | enum Type { |
| 33 | Invalid = 0, |
| 34 | Underline = 1, |
| 35 | Foreground = 2, |
| 36 | Background = 3, |
| 37 | }; |
| 38 | |
| 39 | enum Underline { |
| 40 | UnderlineNone = 0, |
| 41 | UnderlineSingle = 1, |
| 42 | UnderlineDouble = 2, |
| 43 | UnderlineLow = 3, |
| 44 | UnderlineError = 4, |
| 45 | }; |
| 46 | |
| 47 | QIBusAttribute(); |
| 48 | |
| 49 | QTextCharFormat format() const; |
| 50 | |
| 51 | void serializeTo(QDBusArgument &argument) const; |
| 52 | void deserializeFrom(const QDBusArgument &argument); |
| 53 | |
| 54 | Type type; |
| 55 | quint32 value; |
| 56 | quint32 start; |
| 57 | quint32 end; |
| 58 | }; |
| 59 | Q_DECLARE_TYPEINFO(QIBusAttribute, Q_RELOCATABLE_TYPE); |
| 60 | |
| 61 | class QIBusAttributeList : private QIBusSerializable |
| 62 | { |
| 63 | public: |
| 64 | QIBusAttributeList(); |
| 65 | |
| 66 | QList<QInputMethodEvent::Attribute> imAttributes() const; |
| 67 | |
| 68 | void serializeTo(QDBusArgument &argument) const; |
| 69 | void deserializeFrom(const QDBusArgument &argument); |
| 70 | |
| 71 | QList<QIBusAttribute> attributes; |
| 72 | }; |
| 73 | Q_DECLARE_TYPEINFO(QIBusAttributeList, Q_RELOCATABLE_TYPE); |
| 74 | |
| 75 | class QIBusText : private QIBusSerializable |
| 76 | { |
| 77 | public: |
| 78 | QIBusText(); |
| 79 | |
| 80 | void serializeTo(QDBusArgument &argument) const; |
| 81 | void deserializeFrom(const QDBusArgument &argument); |
| 82 | |
| 83 | QString text; |
| 84 | QIBusAttributeList attributes; |
| 85 | }; |
| 86 | Q_DECLARE_TYPEINFO(QIBusText, Q_RELOCATABLE_TYPE); |
| 87 | |
| 88 | class QIBusEngineDesc : private QIBusSerializable |
| 89 | { |
| 90 | public: |
| 91 | QIBusEngineDesc(); |
| 92 | |
| 93 | void serializeTo(QDBusArgument &argument) const; |
| 94 | void deserializeFrom(const QDBusArgument &argument); |
| 95 | |
| 96 | QString engine_name; |
| 97 | QString longname; |
| 98 | QString description; |
| 99 | QString language; |
| 100 | QString license; |
| 101 | QString author; |
| 102 | QString icon; |
| 103 | QString layout; |
| 104 | unsigned int rank; |
| 105 | QString hotkeys; |
| 106 | QString symbol; |
| 107 | QString setup; |
| 108 | QString layout_variant; |
| 109 | QString layout_option; |
| 110 | QString version; |
| 111 | QString textdomain; |
| 112 | QString iconpropkey; |
| 113 | }; |
| 114 | Q_DECLARE_TYPEINFO(QIBusEngineDesc, Q_RELOCATABLE_TYPE); |
| 115 | |
| 116 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute) |
| 117 | { attribute.serializeTo(argument); return argument; } |
| 118 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute) |
| 119 | { attribute.deserializeFrom(argument); return argument; } |
| 120 | |
| 121 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList) |
| 122 | { attributeList.serializeTo(argument); return argument; } |
| 123 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttributeList &attributeList) |
| 124 | { attributeList.deserializeFrom(argument); return argument; } |
| 125 | |
| 126 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text) |
| 127 | { text.serializeTo(argument); return argument; } |
| 128 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text) |
| 129 | { text.deserializeFrom(argument); return argument; } |
| 130 | |
| 131 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc) |
| 132 | { desc.serializeTo(argument); return argument; } |
| 133 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc) |
| 134 | { desc.deserializeFrom(argument); return argument; } |
| 135 | |
| 136 | class QIBusPropTypeClientCommitPreedit |
| 137 | { |
| 138 | public: |
| 139 | QIBusPropTypeClientCommitPreedit() {} |
| 140 | |
| 141 | QIBusPropTypeClientCommitPreedit(bool inClientCommitPreedit); |
| 142 | |
| 143 | void serializeTo(QDBusArgument &argument) const; |
| 144 | void deserializeFrom(const QDBusArgument &argument); |
| 145 | |
| 146 | bool clientCommitPreedit; |
| 147 | }; |
| 148 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusPropTypeClientCommitPreedit &data) |
| 149 | { data.serializeTo(argument); return argument; } |
| 150 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusPropTypeClientCommitPreedit &data) |
| 151 | { data.deserializeFrom(argument); return argument; } |
| 152 | |
| 153 | class QIBusPropTypeContentType |
| 154 | { |
| 155 | public: |
| 156 | QIBusPropTypeContentType() {} |
| 157 | |
| 158 | QIBusPropTypeContentType(unsigned int inPurpose, unsigned int inHint); |
| 159 | |
| 160 | void serializeTo(QDBusArgument &argument) const; |
| 161 | void deserializeFrom(const QDBusArgument &argument); |
| 162 | |
| 163 | unsigned int purpose; |
| 164 | unsigned int hints; |
| 165 | }; |
| 166 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusPropTypeContentType &data) |
| 167 | { data.serializeTo(argument); return argument; } |
| 168 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusPropTypeContentType &data) |
| 169 | { data.deserializeFrom(argument); return argument; } |
| 170 | |
| 171 | Q_DECLARE_TYPEINFO(QIBusPropTypeClientCommitPreedit, Q_RELOCATABLE_TYPE); |
| 172 | Q_DECLARE_TYPEINFO(QIBusPropTypeContentType, Q_RELOCATABLE_TYPE); |
| 173 | |
| 174 | QT_END_NAMESPACE |
| 175 | |
| 176 | Q_DECLARE_METATYPE(QIBusAttribute) |
| 177 | Q_DECLARE_METATYPE(QIBusAttributeList) |
| 178 | Q_DECLARE_METATYPE(QIBusText) |
| 179 | Q_DECLARE_METATYPE(QIBusEngineDesc) |
| 180 | |
| 181 | Q_DECLARE_METATYPE(QIBusPropTypeClientCommitPreedit) |
| 182 | Q_DECLARE_METATYPE(QIBusPropTypeContentType) |
| 183 | #endif |
| 184 | |