From 9c7f37e648024a8c7129e332dfb12b3ebd1ebf25 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 21 Jan 2016 20:43:50 +0300 Subject: dbusmenu: Refactor the code to allow dynamic updating of menus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Transfer propertiesUpdated and updated signals from submenus to parent menus. Without this, the adaptor only receives this signal from top-level menu items, and doesn't receive it from items of submenus. Connect to these signals when a menu item is added or synced, and disconnect when it is removed. * Make QDBusPlatformMenus use IDs of items containing them, not their own IDs (own IDs do not make any sense since they are not exported over D-Bus). * Store toplevel menus per-adaptor, to make it possible to export multiple menus (for example a menubar and a tray icon menu). * Adjust the QDBusMenuLayoutItem::populate methods to always get the menu via its containing item and to populate the menus recursively. * Map D-Bus menu AboutToShow method to platform menu aboutToShow method, and map hovered and closed events to hovered and aboutToHide signals. (QTBUG-46293) * Always set the visible property on item. Otherwise, when an item becomes visible, the D-Bus menu still thinks it's invisible because that property was not changed back to true. (QTBUG-48647) * Call emitUpdated from insertMenuItem and removeMenuItem methods, as they really update layout. Do not call it from syncMenuItem, it changes only properties but not the layout. * Start revision numbering with 1, because libdbusmenu-based hosts ignore updated signal with revision=1. Task-number: QTBUG-46293 Task-number: QTBUG-48647 Change-Id: Icf713405db0443e25462c1a19046df7689fe5e78 Reviewed-by: Shawn Rutledge Reviewed-by: Błażej Szczygieł --- src/platformsupport/dbusmenu/qdbusplatformmenu_p.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/platformsupport/dbusmenu/qdbusplatformmenu_p.h') diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h index 5892391299..f2419b5378 100644 --- a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h +++ b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h @@ -130,6 +130,7 @@ public: ~QDBusPlatformMenu(); void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) Q_DECL_OVERRIDE; void removeMenuItem(QPlatformMenuItem *menuItem) Q_DECL_OVERRIDE; + void syncSubMenu(const QDBusPlatformMenu *menu); void syncMenuItem(QPlatformMenuItem *menuItem) Q_DECL_OVERRIDE; void syncSeparatorsCollapsible(bool enable) Q_DECL_OVERRIDE { Q_UNUSED(enable); } @@ -147,8 +148,7 @@ public: void setMinimumWidth(int width) Q_DECL_OVERRIDE { Q_UNUSED(width); } void setFont(const QFont &font) Q_DECL_OVERRIDE { Q_UNUSED(font); } void setMenuType(MenuType type) Q_DECL_OVERRIDE { Q_UNUSED(type); } - - int dbusID() const { return m_dbusID; } + void setContainingMenuItem(QDBusPlatformMenuItem *item); void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE { @@ -169,9 +169,6 @@ public: bool operator==(const QDBusPlatformMenu& other) { return m_tag == other.m_tag; } - static QDBusPlatformMenu* byId(int id); - static QList topLevelMenus() { return m_topLevelMenus; } - uint revision() const { return m_revision; } void emitUpdated(); @@ -187,12 +184,10 @@ private: bool m_isEnabled; bool m_isVisible; bool m_isSeparator; - int m_dbusID; uint m_revision; QHash m_itemsByTag; QList m_items; QDBusPlatformMenuItem *m_containingMenuItem; - static QList m_topLevelMenus; }; QT_END_NAMESPACE -- cgit v1.2.3