Skip to content

Commit adffda1

Browse files
committed
merge commits from KDE repo
1 parent ea29574 commit adffda1

19 files changed

+471
-671
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ find_package(Qt5DBus REQUIRED)
2424
find_package(KF5WindowSystem REQUIRED)
2525
find_package(Qt5X11Extras REQUIRED)
2626
find_package(XCB REQUIRED COMPONENTS xcb)
27+
find_package(KF5Config)
28+
find_package(KF5CoreAddons)
2729

2830
set(SRCS main.cpp
2931
menuimporter.h menuimporter.cpp
30-
gmenu-dbusmenu-proxy/dbusmenutypes_p.h gmenu-dbusmenu-proxy/dbusmenutypes_p.cpp
32+
dbusmenutypes_p.h dbusmenutypes_p.cpp
3133
dbusmenushortcut_p.h dbusmenushortcut_p.cpp
3234

3335
# gmenu dbus proxy
@@ -36,10 +38,10 @@ set(SRCS main.cpp
3638
gmenu-dbusmenu-proxy/menuproxy.h gmenu-dbusmenu-proxy/menuproxy.cpp
3739
gmenu-dbusmenu-proxy/menu.h gmenu-dbusmenu-proxy/menu.cpp
3840
gmenu-dbusmenu-proxy/icons.h gmenu-dbusmenu-proxy/icons.cpp
39-
gdbusmenutypes_p.h gdbusmenutypes_p.cpp
41+
gmenu-dbusmenu-proxy/gdbusmenutypes_p.h gmenu-dbusmenu-proxy/gdbusmenutypes_p.cpp
4042
gmenu-dbusmenu-proxy/actions.h gmenu-dbusmenu-proxy/actions.cpp
4143
config-X11.h
42-
)
44+
gmenu-dbusmenu-proxy/debug.h)
4345

4446
qt5_add_dbus_adaptor(SRCS com.canonical.AppMenu.Registrar.xml
4547
menuimporter.h MenuImporter menuimporteradaptor MenuImporterAdaptor)
@@ -61,6 +63,9 @@ target_link_libraries(${PROJECT}
6163
Qt5::X11Extras
6264
KF5::WindowSystem
6365
${XCB_LIBRARIES}
66+
KF5::ConfigCore
67+
KF5::ConfigGui
68+
KF5::CoreAddons
6469
)
6570

6671
include(deb.cmake)

gmenu-dbusmenu-proxy/actions.cpp

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/*
2-
* Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3-
*
4-
* This library is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public
6-
* License as published by the Free Software Foundation; either
7-
* version 2.1 of the License, or (at your option) any later version.
8-
*
9-
* This library is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public
15-
* License along with this library; if not, write to the Free Software
16-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17-
*
18-
*/
2+
SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3+
4+
SPDX-License-Identifier: LGPL-2.1-or-later
5+
*/
196

207
#include "actions.h"
218

@@ -30,9 +17,9 @@
3017
static const QString s_orgGtkActions = QStringLiteral("org.gtk.Actions");
3118

3219
Actions::Actions(const QString &serviceName, const QString &objectPath, QObject *parent)
33-
: QObject(parent)
34-
, m_serviceName(serviceName)
35-
, m_objectPath(objectPath)
20+
: QObject(parent)
21+
, m_serviceName(serviceName)
22+
, m_objectPath(objectPath)
3623
{
3724
Q_ASSERT(!serviceName.isEmpty());
3825
Q_ASSERT(!m_objectPath.isEmpty());
@@ -42,7 +29,7 @@ Actions::Actions(const QString &serviceName, const QString &objectPath, QObject
4229
s_orgGtkActions,
4330
QStringLiteral("Changed"),
4431
this,
45-
SLOT(onActionsChanged(QStringList,StringBoolMap,QVariantMap,GMenuActionMap)))) {
32+
SLOT(onActionsChanged(QStringList, StringBoolMap, QVariantMap, GMenuActionMap)))) {
4633
qDebug() << "Failed to subscribe to action changes for" << parent << "on" << serviceName << "at" << objectPath;
4734
}
4835
}
@@ -51,21 +38,18 @@ Actions::~Actions() = default;
5138

5239
void Actions::load()
5340
{
54-
QDBusMessage msg = QDBusMessage::createMethodCall(m_serviceName,
55-
m_objectPath,
56-
s_orgGtkActions,
57-
QStringLiteral("DescribeAll"));
41+
QDBusMessage msg = QDBusMessage::createMethodCall(m_serviceName, m_objectPath, s_orgGtkActions, QStringLiteral("DescribeAll"));
5842

5943
QDBusPendingReply<GMenuActionMap> reply = QDBusConnection::sessionBus().asyncCall(msg);
6044
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
6145
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
6246
QDBusPendingReply<GMenuActionMap> reply = *watcher;
6347
if (reply.isError()) {
6448
qDebug() << "Failed to get actions from" << m_serviceName << "at" << m_objectPath << reply.error();
65-
emit failedToLoad();
49+
Q_EMIT failedToLoad();
6650
} else {
6751
m_actions = reply.value();
68-
emit loaded();
52+
Q_EMIT loaded();
6953
}
7054
watcher->deleteLater();
7155
});
@@ -94,10 +78,7 @@ void Actions::trigger(const QString &name, const QVariant &target, uint timestam
9478
return;
9579
}
9680

97-
QDBusMessage msg = QDBusMessage::createMethodCall(m_serviceName,
98-
m_objectPath,
99-
s_orgGtkActions,
100-
QStringLiteral("Activate"));
81+
QDBusMessage msg = QDBusMessage::createMethodCall(m_serviceName, m_objectPath, s_orgGtkActions, QStringLiteral("Activate"));
10182
msg << name;
10283

10384
QVariantList args;
@@ -134,10 +115,7 @@ bool Actions::isValid() const
134115
return !m_actions.isEmpty();
135116
}
136117

137-
void Actions::onActionsChanged(const QStringList &removed,
138-
const StringBoolMap &enabledChanges,
139-
const QVariantMap &stateChanges,
140-
const GMenuActionMap &added)
118+
void Actions::onActionsChanged(const QStringList &removed, const StringBoolMap &enabledChanges, const QVariantMap &stateChanges, const GMenuActionMap &added)
141119
{
142120
// Collect the actions that we removed, altered, or added, so we can eventually signal changes for all menus that contain one of those actions
143121
QStringList dirtyActions;
@@ -201,18 +179,12 @@ void Actions::onActionsChanged(const QStringList &removed,
201179
for (auto it = added.constBegin(), end = added.constEnd(); it != end; ++it) {
202180
const QString &actionName = it.key();
203181

204-
// if (DBUSMENUPROXY().isInfoEnabled()) {
205-
// if (m_actions.contains(actionName)) {
206-
// qDebug() << "Got new action" << actionName << "that we already have, overwriting existing one";
207-
// }
208-
// }
209-
210182
m_actions.insert(actionName, it.value());
211183

212184
dirtyActions.append(actionName);
213185
}
214186

215187
if (!dirtyActions.isEmpty()) {
216-
emit actionsChanged(dirtyActions);
188+
Q_EMIT actionsChanged(dirtyActions);
217189
}
218-
}
190+
}

gmenu-dbusmenu-proxy/actions.h

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
/*
2-
* Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3-
*
4-
* This library is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public
6-
* License as published by the Free Software Foundation; either
7-
* version 2.1 of the License, or (at your option) any later version.
8-
*
9-
* This library is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public
15-
* License along with this library; if not, write to the Free Software
16-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17-
*
18-
*/
2+
SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3+
4+
SPDX-License-Identifier: LGPL-2.1-or-later
5+
*/
196

207
#pragma once
218

229
#include <QObject>
2310
#include <QString>
11+
#include <QStringList>
2412

2513
#include "gdbusmenutypes_p.h"
2614

27-
class QStringList;
28-
2915
class Actions : public QObject
3016
{
31-
Q_OBJECT
17+
Q_OBJECT
3218

3319
public:
3420
Actions(const QString &serviceName, const QString &objectPath, QObject *parent = nullptr);
@@ -42,21 +28,17 @@ class Actions : public QObject
4228

4329
bool isValid() const; // basically "has actions"
4430

45-
signals:
31+
Q_SIGNALS:
4632
void loaded();
4733
void failedToLoad(); // expose error?
4834
void actionsChanged(const QStringList &dirtyActions);
4935

50-
private slots:
51-
void onActionsChanged(const QStringList &removed,
52-
const StringBoolMap &enabledChanges,
53-
const QVariantMap &stateChanges,
54-
const GMenuActionMap &added);
36+
private Q_SLOTS:
37+
void onActionsChanged(const QStringList &removed, const StringBoolMap &enabledChanges, const QVariantMap &stateChanges, const GMenuActionMap &added);
5538

5639
private:
5740
GMenuActionMap m_actions;
5841

5942
QString m_serviceName;
6043
QString m_objectPath;
61-
62-
};
44+
};

gmenu-dbusmenu-proxy/debug.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Created by ragdoll on 2022/4/3.
3+
//
4+
5+
#ifndef DDE_GLOBALMENU_SERVICE_DEBUG_H
6+
#define DDE_GLOBALMENU_SERVICE_DEBUG_H
7+
8+
#include <QLoggingCategory>
9+
10+
static const QLoggingCategory &DBUSMENUPROXY() {
11+
static const QLoggingCategory category("DBusMenuProxy");
12+
return category;
13+
}
14+
15+
#endif //DDE_GLOBALMENU_SERVICE_DEBUG_H
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/*
2-
* Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3-
*
4-
* This library is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public
6-
* License as published by the Free Software Foundation; either
7-
* version 2.1 of the License, or (at your option) any later version.
8-
*
9-
* This library is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public
15-
* License along with this library; if not, write to the Free Software
16-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17-
*
18-
*/
2+
SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3+
4+
SPDX-License-Identifier: LGPL-2.1-or-later
5+
*/
196

207
#include "gdbusmenutypes_p.h"
218

@@ -129,4 +116,4 @@ void GDBusMenuTypes_register()
129116
qDBusRegisterMetaType<StringBoolMap>();
130117

131118
registered = true;
132-
}
119+
}
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/*
2-
* Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3-
*
4-
* This library is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public
6-
* License as published by the Free Software Foundation; either
7-
* version 2.1 of the License, or (at your option) any later version.
8-
*
9-
* This library is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public
15-
* License along with this library; if not, write to the Free Software
16-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17-
*
18-
*/
2+
SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
3+
4+
SPDX-License-Identifier: LGPL-2.1-or-later
5+
*/
196

207
#pragma once
218

@@ -34,8 +21,7 @@ using StringBoolMap = QMap<QString, bool>;
3421
Q_DECLARE_METATYPE(StringBoolMap);
3522

3623
// Menu item itself (Start method)
37-
struct GMenuItem
38-
{
24+
struct GMenuItem {
3925
uint id;
4026
uint section;
4127
VariantMapList items;
@@ -49,8 +35,7 @@ using GMenuItemList = QList<GMenuItem>;
4935
Q_DECLARE_METATYPE(GMenuItemList);
5036

5137
// Information about what section or submenu to use for a particular entry
52-
struct GMenuSection
53-
{
38+
struct GMenuSection {
5439
uint subscription;
5540
uint menu;
5641
};
@@ -60,8 +45,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const GMenuSection &item);
6045
const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuSection &item);
6146

6247
// Changes of a menu item (Changed signal)
63-
struct GMenuChange
64-
{
48+
struct GMenuChange {
6549
uint subscription;
6650
uint menu;
6751

@@ -78,8 +62,7 @@ using GMenuChangeList = QList<GMenuChange>;
7862
Q_DECLARE_METATYPE(GMenuChangeList);
7963

8064
// An application action
81-
struct GMenuAction
82-
{
65+
struct GMenuAction {
8366
bool enabled;
8467
QDBusSignature signature;
8568
QVariantList state;
@@ -92,8 +75,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuAction &item
9275
using GMenuActionMap = QMap<QString, GMenuAction>;
9376
Q_DECLARE_METATYPE(GMenuActionMap);
9477

95-
struct GMenuActionsChange
96-
{
78+
struct GMenuActionsChange {
9779
QStringList removed;
9880
QMap<QString, bool> enabledChanged;
9981
QVariantMap stateChanged;
@@ -104,4 +86,4 @@ Q_DECLARE_METATYPE(GMenuActionsChange);
10486
QDBusArgument &operator<<(QDBusArgument &argument, const GMenuActionsChange &item);
10587
const QDBusArgument &operator>>(const QDBusArgument &argument, GMenuActionsChange &item);
10688

107-
void GDBusMenuTypes_register();
89+
void GDBusMenuTypes_register();

0 commit comments

Comments
 (0)