File indexing completed on 2025-01-12 03:40:51
0001 /* This file is part of the dbusmenu-qt library 0002 SPDX-FileCopyrightText: 2010 Canonical 0003 Author: Aurelien Gateau <aurelien.gateau@canonical.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 #ifndef DBUSMENUEXPORTERPRIVATE_P_H 0008 #define DBUSMENUEXPORTERPRIVATE_P_H 0009 0010 // Local 0011 #include "dbusmenuexporter.h" 0012 #include "dbusmenutypes_p.h" 0013 0014 // Qt 0015 #include <QHash> 0016 #include <QMap> 0017 #include <QSet> 0018 #include <QVariant> 0019 0020 class QMenu; 0021 class QTimer; 0022 0023 class DBusMenuExporterDBus; 0024 0025 class DBusMenuExporterPrivate 0026 { 0027 public: 0028 DBusMenuExporter *q = nullptr; 0029 0030 QString m_objectPath; 0031 0032 DBusMenuExporterDBus *m_dbusObject = nullptr; 0033 0034 QMenu *m_rootMenu = nullptr; 0035 QHash<QAction *, QVariantMap> m_actionProperties; 0036 QMap<int, QAction *> m_actionForId; 0037 QMap<QAction *, int> m_idForAction; 0038 int m_nextId; 0039 uint m_revision; 0040 bool m_emittedLayoutUpdatedOnce; 0041 0042 QSet<int> m_itemUpdatedIds; 0043 QTimer *m_itemUpdatedTimer = nullptr; 0044 0045 QSet<int> m_layoutUpdatedIds; 0046 QTimer *m_layoutUpdatedTimer = nullptr; 0047 0048 int idForAction(QAction *action) const; 0049 void addMenu(QMenu *menu, int parentId); 0050 QVariantMap propertiesForAction(QAction *action) const; 0051 QVariantMap propertiesForKMenuTitleAction(QAction *action_) const; 0052 QVariantMap propertiesForSeparatorAction(QAction *action) const; 0053 QVariantMap propertiesForStandardAction(QAction *action) const; 0054 QMenu *menuForId(int id) const; 0055 void fillLayoutItem(DBusMenuLayoutItem *item, QMenu *menu, int id, int depth, const QStringList &propertyNames); 0056 0057 void addAction(QAction *action, int parentId); 0058 void updateAction(QAction *action); 0059 void removeAction(QAction *action, int parentId); 0060 /** 0061 * Removes any reference from action in the exporter, but do not notify the 0062 * change outside. This is useful when a submenu is destroyed because we do 0063 * not receive QEvent::ActionRemoved events for its actions. 0064 * IMPORTANT: action might have already been destroyed when this method is 0065 * called, so don't dereference the pointer (it is a QObject to avoid being 0066 * tempted to dereference) 0067 */ 0068 void removeActionInternal(QObject *action); 0069 0070 void emitLayoutUpdated(int id); 0071 0072 void insertIconProperty(QVariantMap *map, QAction *action) const; 0073 0074 void collapseSeparators(QMenu *); 0075 }; 0076 0077 #endif /* DBUSMENUEXPORTERPRIVATE_P_H */