Signal which menu has updated in libdbusmenu-qt

Summary:
Then update appet, SNI, and appmenu appropriately which are only care
about the root menu.

This fixes some premature showing and re-evaluation.

Test Plan:
Ran statusnotifiertest and checked submenu worked
Ran applet and checked everything was still fine
Restarted kded and checked window decoration menu

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4161
wilder-5.14
David Edmundson 9 years ago
parent 68abbe6693
commit 77e57190ed
  1. 6
      applets/appmenu/plugin/appmenumodel.cpp
  2. 4
      appmenu/appmenu.cpp
  3. 6
      dataengines/statusnotifieritem/statusnotifieritemsource.cpp
  4. 22
      libdbusmenuqt/dbusmenuimporter.cpp
  5. 2
      libdbusmenuqt/dbusmenuimporter.h

@ -225,12 +225,12 @@ void AppMenuModel::updateApplicationMenu(const QString &serviceName, const QStri
m_importer->deleteLater();
}
m_importer = new KDBusMenuImporter(serviceName, menuObjectPath, this);
m_importer = new KDBusMenuImporter(serviceName, menuObjectPath, this);
QMetaObject::invokeMethod(m_importer, "updateMenu", Qt::QueuedConnection);
connect(m_importer.data(), &DBusMenuImporter::menuUpdated, this, [=] {
connect(m_importer.data(), &DBusMenuImporter::menuUpdated, this, [=](QMenu *menu) {
m_menu = m_importer->menu();
if (m_menu.isNull()) {
if (m_menu.isNull() || menu != m_menu) {
return;
}
setMenuAvailable(true);

@ -136,9 +136,9 @@ void AppMenuModule::slotShowMenu(int x, int y, const QString &serviceName, const
QMetaObject::invokeMethod(importer, "updateMenu", Qt::QueuedConnection);
disconnect(importer, 0, this, 0); // ensure we don't popup multiple times in case the menu updates again later
connect(importer, &KDBusMenuImporter::menuUpdated, this, [=] {
connect(importer, &KDBusMenuImporter::menuUpdated, this, [=](QMenu *m) {
QMenu *menu = importer->menu();
if (!menu) {
if (!menu || menu != m) {
return;
}
m_menu = qobject_cast<VerticalMenu*>(menu);

@ -368,7 +368,11 @@ void StatusNotifierItemSource::refreshCallback(QDBusPendingCallWatcher *call)
qWarning() << "DBusMenu disabled for this application";
} else {
m_menuImporter = new PlasmaDBusMenuImporter(m_statusNotifierItemInterface->service(), menuObjectPath, iconLoader(), this);
connect(m_menuImporter, SIGNAL(menuUpdated()), this, SLOT(contextMenuReady()));
connect(m_menuImporter, &PlasmaDBusMenuImporter::menuUpdated, this, [this](QMenu *menu) {
if (menu == m_menuImporter->menu()) {
contextMenuReady();
}
});
}
}
}

@ -375,11 +375,14 @@ void DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher *watcher)
int parentId = watcher->property(DBUSMENU_PROPERTY_ID).toInt();
watcher->deleteLater();
QMenu *menu = d->menuForId(parentId);
QDBusPendingReply<uint, DBusMenuLayoutItem> reply = *watcher;
if (!reply.isValid()) {
qWarning() << reply.error().message();
emit menuUpdated();
if (menu) {
emit menuUpdated(menu);
}
return;
}
@ -388,7 +391,6 @@ void DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher *watcher)
#endif
DBusMenuLayoutItem rootItem = reply.argumentAt<1>();
QMenu *menu = d->menuForId(parentId);
if (!menu) {
qWarning() << "No menu for id" << parentId;
return;
@ -443,7 +445,7 @@ void DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher *watcher)
}
}
emit menuUpdated();
emit menuUpdated(menu);
}
void DBusMenuImporter::sendClickedEvent(int id)
@ -477,24 +479,26 @@ void DBusMenuImporter::slotAboutToShowDBusCallFinished(QDBusPendingCallWatcher *
int id = watcher->property(DBUSMENU_PROPERTY_ID).toInt();
watcher->deleteLater();
QMenu *menu = d->menuForId(id);
QDBusPendingReply<bool> reply = *watcher;
if (reply.isError()) {
menuUpdated();
qWarning() << "Call to AboutToShow() failed:" << reply.error().message();
if (menu) {
menuUpdated(menu);
}
return;
}
//Note, this isn't used by Qt's QPT - but we get a LayoutChanged emitted before
//this returns, which equates to the same thing
bool needRefresh = reply.argumentAt<0>();
QMenu *menu = d->menuForId(id);
DMRETURN_IF_FAIL(menu);
if (needRefresh || menu->actions().isEmpty()) {
d->m_idsRefreshedByAboutToShow << id;
d->refresh(id);
} else {
menuUpdated();
} else if (menu) {
menuUpdated(menu);
}
}

@ -69,7 +69,7 @@ Q_SIGNALS:
* Emitted after a call to updateMenu().
* @see updateMenu()
*/
void menuUpdated();
void menuUpdated(QMenu *);
/**
* Emitted when the exporter was asked to activate an action

Loading…
Cancel
Save