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 | |
4 | /* |
5 | This file was originally created by qdbusxml2cpp version 0.8 |
6 | Command line was: |
7 | qdbusxml2cpp -a dbusmenu ../../3rdparty/dbus-ifaces/dbus-menu.xml |
8 | |
9 | However it is maintained manually. |
10 | */ |
11 | |
12 | #include <QMetaObject> |
13 | #include <QByteArray> |
14 | #include <QList> |
15 | #include <QMap> |
16 | #include <QString> |
17 | #include <QStringList> |
18 | #include <QVariant> |
19 | #include <QLocale> |
20 | |
21 | #include <private/qdbusmenuadaptor_p.h> |
22 | #include <private/qdbusplatformmenu_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | using namespace Qt::StringLiterals; |
27 | |
28 | QDBusMenuAdaptor::(QDBusPlatformMenu *) |
29 | : QDBusAbstractAdaptor(topLevelMenu) |
30 | , m_topLevelMenu(topLevelMenu) |
31 | { |
32 | setAutoRelaySignals(true); |
33 | } |
34 | |
35 | QDBusMenuAdaptor::() |
36 | { |
37 | } |
38 | |
39 | QString QDBusMenuAdaptor::() const |
40 | { |
41 | qCDebug(qLcMenu); |
42 | return "normal"_L1 ; |
43 | } |
44 | |
45 | QString QDBusMenuAdaptor::() const |
46 | { |
47 | return QLocale().textDirection() == Qt::RightToLeft ? "rtl"_L1 : "ltr"_L1 ; |
48 | } |
49 | |
50 | uint QDBusMenuAdaptor::() const |
51 | { |
52 | return 4; |
53 | } |
54 | |
55 | bool QDBusMenuAdaptor::(int id) |
56 | { |
57 | qCDebug(qLcMenu) << id; |
58 | if (id == 0) { |
59 | emit m_topLevelMenu->aboutToShow(); |
60 | } else { |
61 | QDBusPlatformMenuItem *item = QDBusPlatformMenuItem::byId(id); |
62 | if (item) { |
63 | const QDBusPlatformMenu * = static_cast<const QDBusPlatformMenu *>(item->menu()); |
64 | if (menu) |
65 | emit const_cast<QDBusPlatformMenu *>(menu)->aboutToShow(); |
66 | } |
67 | } |
68 | return false; // updateNeeded (we don't know that, so false) |
69 | } |
70 | |
71 | QList<int> QDBusMenuAdaptor::(const QList<int> &ids, QList<int> &idErrors) |
72 | { |
73 | qCDebug(qLcMenu) << ids; |
74 | Q_UNUSED(idErrors); |
75 | idErrors.clear(); |
76 | for (int id : ids) |
77 | AboutToShow(id); |
78 | return QList<int>(); // updatesNeeded |
79 | } |
80 | |
81 | void QDBusMenuAdaptor::(int id, const QString &eventId, const QDBusVariant &data, uint timestamp) |
82 | { |
83 | Q_UNUSED(data); |
84 | Q_UNUSED(timestamp); |
85 | QDBusPlatformMenuItem *item = QDBusPlatformMenuItem::byId(id); |
86 | qCDebug(qLcMenu) << id << (item ? item->text() : ""_L1 ) << eventId; |
87 | if (item && eventId == "clicked"_L1 ) |
88 | item->trigger(); |
89 | if (item && eventId == "hovered"_L1 ) |
90 | emit item->hovered(); |
91 | if (eventId == "closed"_L1 ) { |
92 | // There is no explicit AboutToHide method, so map closed event to aboutToHide method |
93 | const QDBusPlatformMenu * = nullptr; |
94 | if (item) |
95 | menu = static_cast<const QDBusPlatformMenu *>(item->menu()); |
96 | else if (id == 0) |
97 | menu = m_topLevelMenu; |
98 | if (menu) |
99 | emit const_cast<QDBusPlatformMenu *>(menu)->aboutToHide(); |
100 | } |
101 | } |
102 | |
103 | QList<int> QDBusMenuAdaptor::(const QDBusMenuEventList &events) |
104 | { |
105 | for (const QDBusMenuEvent &ev : events) |
106 | Event(id: ev.m_id, eventId: ev.m_eventId, data: ev.m_data, timestamp: ev.m_timestamp); |
107 | return QList<int>(); // idErrors |
108 | } |
109 | |
110 | QDBusMenuItemList QDBusMenuAdaptor::(const QList<int> &ids, const QStringList &propertyNames) |
111 | { |
112 | qCDebug(qLcMenu) << ids << propertyNames << "=>" << QDBusMenuItem::items(ids, propertyNames); |
113 | return QDBusMenuItem::items(ids, propertyNames); |
114 | } |
115 | |
116 | uint QDBusMenuAdaptor::(int parentId, int recursionDepth, const QStringList &propertyNames, QDBusMenuLayoutItem &layout) |
117 | { |
118 | uint ret = layout.populate(id: parentId, depth: recursionDepth, propertyNames, topLevelMenu: m_topLevelMenu); |
119 | qCDebug(qLcMenu) << parentId << "depth" << recursionDepth << propertyNames << layout.m_id << layout.m_properties << "revision" << ret << layout; |
120 | return ret; |
121 | } |
122 | |
123 | QDBusVariant QDBusMenuAdaptor::(int id, const QString &name) |
124 | { |
125 | qCDebug(qLcMenu) << id << name; |
126 | // handle method call com.canonical.dbusmenu.GetProperty |
127 | QDBusVariant value; |
128 | return value; |
129 | } |
130 | |
131 | QT_END_NAMESPACE |
132 | |
133 | #include "moc_qdbusmenuadaptor_p.cpp" |
134 | |