KGlobalAccel

kglobalshortcutinfo_dbus.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kglobalshortcutinfo.h"
8#include "kglobalshortcutinfo_p.h"
9
10QDBusArgument &operator<<(QDBusArgument &argument, const QKeySequence &sequence)
11{
12 argument.beginStructure();
13 argument.beginArray(qMetaTypeId<int>());
14 for (int i = 0; i < maxSequenceLength; i++) {
15 argument << (i < sequence.count() ? sequence[i].toCombined() : 0);
16 }
17 argument.endArray();
18 argument.endStructure();
19 return argument;
20}
21
22const QDBusArgument &operator>>(const QDBusArgument &argument, QKeySequence &sequence)
23{
24 int s1;
25 int s2;
26 int s3;
27 int s4;
28 argument.beginStructure();
29 argument.beginArray();
30 argument >> s1 >> s2 >> s3 >> s4;
31 sequence = QKeySequence(s1, s2, s3, s4);
32 argument.endArray();
33 argument.endStructure();
34 return argument;
35}
36
38{
39 argument.beginStructure();
40 /* clang-format off */
41 argument << shortcut.uniqueName()
42 << shortcut.friendlyName()
43 << shortcut.componentUniqueName()
44 << shortcut.componentFriendlyName()
45 << shortcut.contextUniqueName()
46 << shortcut.contextFriendlyName();
47 /* clang-format on */
48 argument.beginArray(qMetaTypeId<int>());
49
50 const QList<QKeySequence> keys = shortcut.keys();
51 for (const QKeySequence &key : keys) {
52 argument << key[0].toCombined();
53 }
54 argument.endArray();
55 argument.beginArray(qMetaTypeId<int>());
56
57 const QList<QKeySequence> defaultKeys = shortcut.defaultKeys();
58 for (const QKeySequence &key : defaultKeys) {
59 argument << key[0].toCombined();
60 }
61 argument.endArray();
62 argument.endStructure();
63 return argument;
64}
65
66const QDBusArgument &operator>>(const QDBusArgument &argument, KGlobalShortcutInfo &shortcut)
67{
68 argument.beginStructure();
69 /* clang-format off */
70 argument >> shortcut.d->uniqueName
71 >> shortcut.d->friendlyName
72 >> shortcut.d->componentUniqueName
73 >> shortcut.d->componentFriendlyName
74 >> shortcut.d->contextUniqueName
75 >> shortcut.d->contextFriendlyName;
76 /* clang-format on */
77
78 argument.beginArray();
79 while (!argument.atEnd()) {
80 int key;
81 argument >> key;
82 shortcut.d->keys.append(QKeySequence(key));
83 }
84 argument.endArray();
85 argument.beginArray();
86 while (!argument.atEnd()) {
87 int key;
88 argument >> key;
89 shortcut.d->defaultKeys.append(QKeySequence(key));
90 }
91 argument.endArray();
92 argument.endStructure();
93 return argument;
94}
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
const QList< QKeySequence > & shortcut(StandardShortcut id)
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
bool atEnd() const const
void beginArray(QMetaType id)
void beginStructure()
void endStructure()
int count() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:49:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.