File: menu.h

package info (click to toggle)
cutefish-core 0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,076 kB
  • sloc: cpp: 11,327; xml: 443; sh: 29; makefile: 6
file content (67 lines) | stat: -rw-r--r-- 1,646 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 "./extend/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 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 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;
};