#include <netinet/in.h>
#include <dbusmenuimporter.h>
-#ifndef DBUSMENUQT_VERSION
-// DBUSMENUQT_VERSION was introduced in DBusMenuQt 0.4.0
-#define DBUSMENUQT_VERSION 0x000305
-#endif
class PlasmaDBusMenuImporter : public DBusMenuImporter
{
kWarning() << "DBusMenu disabled for this application";
} else {
m_menuImporter = new PlasmaDBusMenuImporter(m_statusNotifierItemInterface->service(), menuObjectPath, iconLoader(), this);
-#if DBUSMENUQT_VERSION >= 0x000400
connect(m_menuImporter, SIGNAL(menuUpdated()), this, SLOT(contextMenuReady()));
-#endif
}
}
}
void StatusNotifierItemSource::contextMenuReady()
{
-#if DBUSMENUQT_VERSION < 0x000400
- // Work around to avoid infinite recursion because menuReadyToBeShown() is emitted
- // by DBusMenuImporter at the end of its slot connected to aboutToShow()
- // (dbusmenu-qt 0.3.5)
- disconnect(m_menuImporter, SIGNAL(menuReadyToBeShown()), this, SLOT(contextMenuReady()));
-#endif
emit contextMenuReady(m_menuImporter->menu());
}
void StatusNotifierItemSource::contextMenu(int x, int y)
{
if (m_menuImporter) {
- #if DBUSMENUQT_VERSION >= 0x000400
m_menuImporter->updateMenu();
- #else
- QMenu *menu = m_menuImporter->menu();
- // Simulate an "aboutToShow" so that menu->sizeHint() is correct. Otherwise
- // the menu may show up over the applet if new actions are added on the
- // fly.
- connect(m_menuImporter, SIGNAL(menuReadyToBeShown()), this, SLOT(contextMenuReady()));
- QMetaObject::invokeMethod(menu, "aboutToShow");
- #endif
} else {
kWarning() << "Could not find DBusMenu interface, falling back to calling ContextMenu()";
if (m_statusNotifierItemInterface && m_statusNotifierItemInterface->isValid()) {