| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the plugins of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | #ifndef QIBUSTYPES_H |
| 40 | #define QIBUSTYPES_H |
| 41 | |
| 42 | #include <qlist.h> |
| 43 | #include <qevent.h> |
| 44 | #include <QDBusArgument> |
| 45 | #include <QTextCharFormat> |
| 46 | #include <QLoggingCategory> |
| 47 | |
| 48 | QT_BEGIN_NAMESPACE |
| 49 | |
| 50 | Q_DECLARE_LOGGING_CATEGORY(qtQpaInputMethods) |
| 51 | Q_DECLARE_LOGGING_CATEGORY(qtQpaInputMethodsSerialize) |
| 52 | |
| 53 | class QIBusSerializable |
| 54 | { |
| 55 | public: |
| 56 | QIBusSerializable(); |
| 57 | |
| 58 | void serializeTo(QDBusArgument &argument) const; |
| 59 | void deserializeFrom(const QDBusArgument &argument); |
| 60 | |
| 61 | QString name; |
| 62 | QHash<QString, QDBusArgument> attachments; |
| 63 | }; |
| 64 | |
| 65 | class QIBusAttribute : private QIBusSerializable |
| 66 | { |
| 67 | public: |
| 68 | enum Type { |
| 69 | Invalid = 0, |
| 70 | Underline = 1, |
| 71 | Foreground = 2, |
| 72 | Background = 3, |
| 73 | }; |
| 74 | |
| 75 | enum Underline { |
| 76 | UnderlineNone = 0, |
| 77 | UnderlineSingle = 1, |
| 78 | UnderlineDouble = 2, |
| 79 | UnderlineLow = 3, |
| 80 | UnderlineError = 4, |
| 81 | }; |
| 82 | |
| 83 | QIBusAttribute(); |
| 84 | |
| 85 | QTextCharFormat format() const; |
| 86 | |
| 87 | void serializeTo(QDBusArgument &argument) const; |
| 88 | void deserializeFrom(const QDBusArgument &argument); |
| 89 | |
| 90 | Type type; |
| 91 | quint32 value; |
| 92 | quint32 start; |
| 93 | quint32 end; |
| 94 | }; |
| 95 | Q_DECLARE_TYPEINFO(QIBusAttribute, Q_MOVABLE_TYPE); |
| 96 | |
| 97 | class QIBusAttributeList : private QIBusSerializable |
| 98 | { |
| 99 | public: |
| 100 | QIBusAttributeList(); |
| 101 | |
| 102 | QList<QInputMethodEvent::Attribute> imAttributes() const; |
| 103 | |
| 104 | void serializeTo(QDBusArgument &argument) const; |
| 105 | void deserializeFrom(const QDBusArgument &argument); |
| 106 | |
| 107 | QList<QIBusAttribute> attributes; |
| 108 | }; |
| 109 | Q_DECLARE_TYPEINFO(QIBusAttributeList, Q_MOVABLE_TYPE); |
| 110 | |
| 111 | class QIBusText : private QIBusSerializable |
| 112 | { |
| 113 | public: |
| 114 | QIBusText(); |
| 115 | |
| 116 | void serializeTo(QDBusArgument &argument) const; |
| 117 | void deserializeFrom(const QDBusArgument &argument); |
| 118 | |
| 119 | QString text; |
| 120 | QIBusAttributeList attributes; |
| 121 | }; |
| 122 | Q_DECLARE_TYPEINFO(QIBusText, Q_MOVABLE_TYPE); |
| 123 | |
| 124 | class QIBusEngineDesc : private QIBusSerializable |
| 125 | { |
| 126 | public: |
| 127 | QIBusEngineDesc(); |
| 128 | |
| 129 | void serializeTo(QDBusArgument &argument) const; |
| 130 | void deserializeFrom(const QDBusArgument &argument); |
| 131 | |
| 132 | QString engine_name; |
| 133 | QString longname; |
| 134 | QString description; |
| 135 | QString language; |
| 136 | QString license; |
| 137 | QString author; |
| 138 | QString icon; |
| 139 | QString layout; |
| 140 | unsigned int rank; |
| 141 | QString hotkeys; |
| 142 | QString symbol; |
| 143 | QString setup; |
| 144 | QString layout_variant; |
| 145 | QString layout_option; |
| 146 | QString version; |
| 147 | QString textdomain; |
| 148 | QString iconpropkey; |
| 149 | }; |
| 150 | Q_DECLARE_TYPEINFO(QIBusEngineDesc, Q_MOVABLE_TYPE); |
| 151 | |
| 152 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttribute &attribute) |
| 153 | { attribute.serializeTo(argument); return argument; } |
| 154 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &attribute) |
| 155 | { attribute.deserializeFrom(argument); return argument; } |
| 156 | |
| 157 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusAttributeList &attributeList) |
| 158 | { attributeList.serializeTo(argument); return argument; } |
| 159 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttributeList &attributeList) |
| 160 | { attributeList.deserializeFrom(argument); return argument; } |
| 161 | |
| 162 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusText &text) |
| 163 | { text.serializeTo(argument); return argument; } |
| 164 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusText &text) |
| 165 | { text.deserializeFrom(argument); return argument; } |
| 166 | |
| 167 | inline QDBusArgument &operator<<(QDBusArgument &argument, const QIBusEngineDesc &desc) |
| 168 | { desc.serializeTo(argument); return argument; } |
| 169 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusEngineDesc &desc) |
| 170 | { desc.deserializeFrom(argument); return argument; } |
| 171 | |
| 172 | QT_END_NAMESPACE |
| 173 | |
| 174 | Q_DECLARE_METATYPE(QIBusAttribute) |
| 175 | Q_DECLARE_METATYPE(QIBusAttributeList) |
| 176 | Q_DECLARE_METATYPE(QIBusText) |
| 177 | Q_DECLARE_METATYPE(QIBusEngineDesc) |
| 178 | |
| 179 | #endif |
| 180 | |