File: menu.h

package info (click to toggle)
plasma-workspace 4%3A5.27.5-2%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 102,040 kB
  • sloc: cpp: 121,800; xml: 3,238; python: 645; perl: 586; sh: 254; javascript: 113; ruby: 62; makefile: 15; ansic: 13
file content (67 lines) | stat: -rw-r--r-- 1,658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
    SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>

    SPDX-License-Identifier: LGPL-2.1-or-later
*/

#pragma once

#include <QObject>
#include <QString>
#include <QVector>

#include "../libdbusmenuqt/dbusmenutypes_p.h"
#include "gdbusmenutypes_p.h"

class Menu : public QObject
{
    Q_OBJECT

public:
    Menu(const QString &serviceName, const QString &objectPath, QObject *parent = nullptr);
    ~Menu() override;

    void init();
    void cleanup();

    void start(uint id);
    void stop(const QList<uint> &ids);

    bool hasMenu() const;
    bool hasSubscription(uint subscription) const;

    GMenuItem getSection(int id, bool *ok = nullptr) const;
    GMenuItem getSection(int subscription, int sectionId, bool *ok = nullptr) const;

    QVariantMap getItem(int id) const; // bool ok argument?
    QVariantMap getItem(int subscription, int sectionId, int id) const;

public Q_SLOTS:
    void actionsChanged(const QStringList &dirtyActions, const QString &prefix);

Q_SIGNALS:
    void menuAppeared(); // emitted the first time a menu was successfully loaded
    void menuDisappeared();

    void subscribed(uint id);
    void failedToSubscribe(uint id);

    void itemsChanged(const QVector<uint> &itemIds);
    void menusChanged(const QVector<uint> &menuIds);

private Q_SLOTS:
    void onMenuChanged(const GMenuChangeList &changes);

private:
    void initMenu();

    void menuChanged(const GMenuChangeList &changes);

    // QSet?
    QList<uint> m_subscriptions; // keeps track of which menu trees we're subscribed to

    QHash<uint, GMenuItemList> m_menus;

    QString m_serviceName;
    QString m_objectPath;
};