File indexing completed on 2024-05-05 17:43:53
0001 /* 0002 SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <QString> 0011 #include <QVector> 0012 0013 #include "../libdbusmenuqt/dbusmenutypes_p.h" 0014 #include "gdbusmenutypes_p.h" 0015 0016 class Menu : public QObject 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 Menu(const QString &serviceName, const QString &objectPath, QObject *parent = nullptr); 0022 ~Menu() override; 0023 0024 void init(); 0025 void cleanup(); 0026 0027 void start(uint id); 0028 void stop(const QList<uint> &ids); 0029 0030 bool hasMenu() const; 0031 bool hasSubscription(uint subscription) const; 0032 0033 GMenuItem getSection(int id, bool *ok = nullptr) const; 0034 GMenuItem getSection(int subscription, int sectionId, bool *ok = nullptr) const; 0035 0036 QVariantMap getItem(int id) const; // bool ok argument? 0037 QVariantMap getItem(int subscription, int sectionId, int id) const; 0038 0039 public Q_SLOTS: 0040 void actionsChanged(const QStringList &dirtyActions, const QString &prefix); 0041 0042 Q_SIGNALS: 0043 void menuAppeared(); // emitted the first time a menu was successfully loaded 0044 void menuDisappeared(); 0045 0046 void subscribed(uint id); 0047 void failedToSubscribe(uint id); 0048 0049 void itemsChanged(const QVector<uint> &itemIds); 0050 void menusChanged(const QVector<uint> &menuIds); 0051 0052 private Q_SLOTS: 0053 void onMenuChanged(const GMenuChangeList &changes); 0054 0055 private: 0056 void initMenu(); 0057 0058 void menuChanged(const GMenuChangeList &changes); 0059 0060 // QSet? 0061 QList<uint> m_subscriptions; // keeps track of which menu trees we're subscribed to 0062 0063 QHash<uint, GMenuItemList> m_menus; 0064 0065 QString m_serviceName; 0066 QString m_objectPath; 0067 };