File indexing completed on 2024-04-28 15:29:43
0001 /* 0002 SPDX-FileCopyrightText: 2017, 2018 David Edmundson <davidedmundson@kde.org> 0003 SPDX-FileCopyrightText: 2020 Alexander Lohnau <alexander.lohnau@gmx.de> 0004 SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <KRunner/QueryMatch> 0012 #include <QDBusArgument> 0013 #include <QList> 0014 #include <QString> 0015 #include <QVariantMap> 0016 0017 struct RemoteMatch { 0018 // sssuda{sv} 0019 QString id; 0020 QString text; 0021 QString iconName; 0022 Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch; 0023 qreal relevance = 0; 0024 QVariantMap properties; 0025 }; 0026 0027 typedef QList<RemoteMatch> RemoteMatches; 0028 0029 struct RemoteAction { 0030 QString id; 0031 QString text; 0032 QString iconName; 0033 }; 0034 0035 typedef QList<RemoteAction> RemoteActions; 0036 0037 struct RemoteImage { 0038 // iiibiiay (matching notification spec image-data attribute) 0039 int width = 0; 0040 int height = 0; 0041 int rowStride = 0; 0042 bool hasAlpha = false; 0043 int bitsPerSample = 0; 0044 int channels = 0; 0045 QByteArray data; 0046 }; 0047 0048 inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteMatch &match) 0049 { 0050 argument.beginStructure(); 0051 argument << match.id; 0052 argument << match.text; 0053 argument << match.iconName; 0054 argument << match.type; 0055 argument << match.relevance; 0056 argument << match.properties; 0057 argument.endStructure(); 0058 return argument; 0059 } 0060 0061 inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match) 0062 { 0063 argument.beginStructure(); 0064 argument >> match.id; 0065 argument >> match.text; 0066 argument >> match.iconName; 0067 int type; 0068 argument >> type; 0069 match.type = static_cast<Plasma::QueryMatch::Type>(type); 0070 argument >> match.relevance; 0071 argument >> match.properties; 0072 argument.endStructure(); 0073 0074 return argument; 0075 } 0076 0077 inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteAction &action) 0078 { 0079 argument.beginStructure(); 0080 argument << action.id; 0081 argument << action.text; 0082 argument << action.iconName; 0083 argument.endStructure(); 0084 return argument; 0085 } 0086 0087 inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action) 0088 { 0089 argument.beginStructure(); 0090 argument >> action.id; 0091 argument >> action.text; 0092 argument >> action.iconName; 0093 argument.endStructure(); 0094 return argument; 0095 } 0096 0097 inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteImage &image) 0098 { 0099 argument.beginStructure(); 0100 argument << image.width; 0101 argument << image.height; 0102 argument << image.rowStride; 0103 argument << image.hasAlpha; 0104 argument << image.bitsPerSample; 0105 argument << image.channels; 0106 argument << image.data; 0107 argument.endStructure(); 0108 return argument; 0109 } 0110 0111 inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteImage &image) 0112 { 0113 argument.beginStructure(); 0114 argument >> image.width; 0115 argument >> image.height; 0116 argument >> image.rowStride; 0117 argument >> image.hasAlpha; 0118 argument >> image.bitsPerSample; 0119 argument >> image.channels; 0120 argument >> image.data; 0121 argument.endStructure(); 0122 return argument; 0123 } 0124 0125 Q_DECLARE_METATYPE(RemoteMatch) 0126 Q_DECLARE_METATYPE(RemoteMatches) 0127 Q_DECLARE_METATYPE(RemoteAction) 0128 Q_DECLARE_METATYPE(RemoteActions) 0129 Q_DECLARE_METATYPE(RemoteImage)