[kwin] Generate dbus interface for Appmenu
Generated code > hand written code.
This commit is contained in:
parent
50987a6ddc
commit
144003a0aa
3 changed files with 11 additions and 21 deletions
|
@ -199,6 +199,8 @@ if(KWIN_BUILD_KAPPMENU)
|
|||
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
|
||||
appmenu.cpp
|
||||
)
|
||||
qt5_add_dbus_interface(kwin_KDEINIT_SRCS
|
||||
${KDEBASE_WORKSPACE_SOURCE_DIR}/appmenu/org.kde.kappmenu.xml appmenu_interface)
|
||||
endif()
|
||||
|
||||
if(KWIN_BUILD_ACTIVITIES)
|
||||
|
|
28
appmenu.cpp
28
appmenu.cpp
|
@ -22,31 +22,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "appmenu.h"
|
||||
#include "client.h"
|
||||
#include "workspace.h"
|
||||
// Qt
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
#include <appmenu_interface.h>
|
||||
|
||||
namespace KWin {
|
||||
|
||||
static QString KDED_SERVICE = QStringLiteral("org.kde.kappmenu");
|
||||
static QString KDED_APPMENU_PATH = QStringLiteral("/KAppMenu");
|
||||
static QString KDED_INTERFACE = QStringLiteral("org.kde.kappmenu");
|
||||
|
||||
KWIN_SINGLETON_FACTORY(ApplicationMenu)
|
||||
|
||||
ApplicationMenu::ApplicationMenu(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_appmenuInterface(new OrgKdeKappmenuInterface(QStringLiteral("org.kde.kappmenu"), QStringLiteral("/KAppMenu"), QDBusConnection::sessionBus(), this))
|
||||
{
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("showRequest"),
|
||||
this, SLOT(slotShowRequest(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("menuAvailable"),
|
||||
this, SLOT(slotMenuAvailable(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("menuHidden"),
|
||||
this, SLOT(slotMenuHidden(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("clearMenus"),
|
||||
this, SLOT(slotClearMenus()));
|
||||
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::showRequest, this, &ApplicationMenu::slotShowRequest);
|
||||
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuAvailable, this, &ApplicationMenu::slotMenuAvailable);
|
||||
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuHidden, this, &ApplicationMenu::slotMenuHidden);
|
||||
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::clearMenus, this, &ApplicationMenu::slotClearMenus);
|
||||
}
|
||||
|
||||
ApplicationMenu::~ApplicationMenu()
|
||||
|
@ -88,10 +77,7 @@ void ApplicationMenu::slotClearMenus()
|
|||
|
||||
void ApplicationMenu::showApplicationMenu(const QPoint &p, const xcb_window_t id)
|
||||
{
|
||||
QList<QVariant> args = QList<QVariant>() << p.x() << p.y() << qulonglong(id);
|
||||
QDBusMessage method = QDBusMessage::createMethodCall(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, QStringLiteral("showMenu"));
|
||||
method.setArguments(args);
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
m_appmenuInterface->showMenu(p.x(), p.y(), id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <xcb/xcb.h>
|
||||
|
||||
class QPoint;
|
||||
class OrgKdeKappmenuInterface;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -51,6 +52,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
QList<xcb_window_t> m_windowsMenu;
|
||||
OrgKdeKappmenuInterface *m_appmenuInterface;
|
||||
|
||||
KWIN_SINGLETON(ApplicationMenu)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue