diff --git a/doomsday/sdk/libappfw/include/de/widgets/menuwidget.h b/doomsday/sdk/libappfw/include/de/widgets/menuwidget.h index f66e403b1f..4e57b8f81e 100644 --- a/doomsday/sdk/libappfw/include/de/widgets/menuwidget.h +++ b/doomsday/sdk/libappfw/include/de/widgets/menuwidget.h @@ -27,6 +27,7 @@ #include "../GridLayout" #include "../ScrollAreaWidget" #include "../ButtonWidget" +#include "../PanelWidget" namespace de { @@ -139,6 +140,14 @@ class LIBAPPFW_PUBLIC MenuWidget : public ScrollAreaWidget public slots: void dismissPopups(); +signals: + /** + * Called when a submenu/widget is opened by one of the items. + * + * @param panel Panel that was opened. + */ + void subWidgetOpened(de::PanelWidget *panel); + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/sdk/libappfw/src/widgets/menuwidget.cpp b/doomsday/sdk/libappfw/src/widgets/menuwidget.cpp index 27a5f5d5af..9ac04fc22d 100644 --- a/doomsday/sdk/libappfw/src/widgets/menuwidget.cpp +++ b/doomsday/sdk/libappfw/src/widgets/menuwidget.cpp @@ -329,6 +329,14 @@ DENG2_PIMPL(MenuWidget) w->audienceForClose() += this; w->audienceForDeletion() += this; + + emit self.subWidgetOpened(w); + + // Automatically close other subwidgets when one is opened. + foreach(auto *panel, openSubs) + { + if(panel != w) panel->close(); + } } bool isVisibleItem(Widget const *child) const