@@ -32,6 +32,7 @@ extern "C" {
3232ModelActionRootState::ModelActionRootState(QObject *parent)
3333 : RootStateObject(parent),
3434 m_menu(nullptr)
35+ , m_reentryGuard(false)
3536{
3637}
3738
@@ -62,6 +63,7 @@ void ModelActionRootState::setMenu(UnityMenuModel* menu)
6263 connect(m_menu, &UnityMenuModel::destroyed, this, &ModelActionRootState::reset);
6364 }
6465 updateActionState();
66+ updateOtherActions();
6567 Q_EMIT menuChanged();
6668
6769 if (wasValid != valid())
@@ -69,6 +71,21 @@ void ModelActionRootState::setMenu(UnityMenuModel* menu)
6971 }
7072}
7173
74+QString ModelActionRootState::secondaryAction() const
75+{
76+ return m_secondaryAction;
77+}
78+
79+QString ModelActionRootState::scrollAction() const
80+{
81+ return m_scrollAction;
82+}
83+
84+QString ModelActionRootState::submenuAction() const
85+{
86+ return m_submenuAction;
87+}
88+
7289bool ModelActionRootState::valid() const
7390{
7491 return !currentState().empty();
@@ -79,6 +96,7 @@ void ModelActionRootState::onModelRowsAdded(const QModelIndex& parent, int start
7996 Q_UNUSED(parent);
8097 if (start == 0 && end >= 0) {
8198 updateActionState();
99+ updateOtherActions();
82100 }
83101}
84102
@@ -87,6 +105,7 @@ void ModelActionRootState::onModelRowsRemoved(const QModelIndex& parent, int sta
87105 Q_UNUSED(parent);
88106 if (start == 0 && end >= 0) {
89107 updateActionState();
108+ updateOtherActions();
90109 }
91110}
92111
@@ -99,6 +118,7 @@ void ModelActionRootState::onModelDataChanged(const QModelIndex& topLeft, const
99118
100119 if (topLeft.row() <= 0 && bottomRight.row() >= 0) {
101120 updateActionState();
121+ updateOtherActions();
102122 }
103123}
104124
@@ -108,10 +128,15 @@ void ModelActionRootState::reset()
108128
109129 Q_EMIT menuChanged();
110130 setCurrentState(QVariantMap());
131+
132+ updateOtherActions();
111133}
112134
113135void ModelActionRootState::updateActionState()
114136{
137+ if (m_reentryGuard) return;
138+ m_reentryGuard = true;
139+
115140 if (m_menu && m_menu->rowCount() > 0) {
116141 ActionStateParser* oldParser = m_menu->actionStateParser();
117142 m_menu->setActionStateParser(&m_parser);
@@ -126,4 +151,54 @@ void ModelActionRootState::updateActionState()
126151 }
127152 // else if m_menu->rowCount() == 0, let's leave existing cache in place
128153 // until the new menu comes in, to avoid flashing the UI empty for a moment
154+
155+ m_reentryGuard = false;
156+}
157+
158+void ModelActionRootState::updateOtherActions()
159+{
160+ if (m_reentryGuard) return;
161+ m_reentryGuard = true;
162+
163+ if (m_menu && m_menu->rowCount() > 0) {
164+ QVariantMap map;
165+ map[QStringLiteral("submenu-action")] = QLatin1String("string");
166+ map[QStringLiteral("x-canonical-scroll-action")] = QLatin1String("string");
167+ map[QStringLiteral("x-canonical-secondary-action")] = QLatin1String("string");
168+ m_menu->loadExtendedAttributes(0, map);
169+ QVariantMap extMap = m_menu->get(0, "ext").toMap();
170+
171+ QString secondaryAction = extMap[QStringLiteral("xCanonicalSecondaryAction")].toString();
172+ if (m_secondaryAction != secondaryAction) {
173+ m_secondaryAction = secondaryAction;
174+ Q_EMIT secondaryActionChanged();
175+ }
176+
177+ QString scrollAction = extMap[QStringLiteral("xCanonicalScrollAction")].toString();
178+ if (m_scrollAction != scrollAction) {
179+ m_scrollAction = scrollAction;
180+ Q_EMIT scrollActionChanged();
181+ }
182+
183+ QString submenuAction = extMap[QStringLiteral("submenuAction")].toString();
184+ if (m_submenuAction != submenuAction) {
185+ m_submenuAction = submenuAction;
186+ Q_EMIT submenuActionChanged();
187+ }
188+ } else {
189+ if (!m_secondaryAction.isEmpty()) {
190+ m_secondaryAction.clear();
191+ Q_EMIT secondaryActionChanged();
192+ }
193+ if (!m_scrollAction.isEmpty()) {
194+ m_scrollAction.clear();
195+ Q_EMIT scrollActionChanged();
196+ }
197+ if (!m_submenuAction.isEmpty()) {
198+ m_submenuAction.clear();
199+ Q_EMIT submenuActionChanged();
200+ }
201+ }
202+
203+ m_reentryGuard = false;
129204}