File indexing completed on 2024-05-05 05:37:32

0001 /*
0002     SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr>
0003     SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com>
0004 
0005     SPDX-License-Identifier: MIT
0006 */
0007 
0008 #include "appmenu_dbus.h"
0009 #include "appmenuadaptor.h"
0010 #include "kdbusimporter.h"
0011 
0012 #include <QApplication>
0013 #include <QDBusMessage>
0014 #include <QDBusServiceWatcher>
0015 
0016 static const char *DBUS_SERVICE = "org.kde.kappmenu";
0017 static const char *DBUS_OBJECT_PATH = "/KAppMenu";
0018 
0019 AppmenuDBus::AppmenuDBus(QObject *parent)
0020     : QObject(parent)
0021 {
0022 }
0023 
0024 AppmenuDBus::~AppmenuDBus()
0025 {
0026 }
0027 
0028 bool AppmenuDBus::connectToBus(const QString &service, const QString &path)
0029 {
0030     m_service = service.isEmpty() ? DBUS_SERVICE : service;
0031     const QString newPath = path.isEmpty() ? DBUS_OBJECT_PATH : path;
0032 
0033     if (!QDBusConnection::sessionBus().registerService(m_service)) {
0034         return false;
0035     }
0036     new AppmenuAdaptor(this);
0037     QDBusConnection::sessionBus().registerObject(newPath, this);
0038 
0039     return true;
0040 }
0041 
0042 void AppmenuDBus::showMenu(int x, int y, const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId)
0043 {
0044     Q_EMIT appShowMenu(x, y, serviceName, menuObjectPath, actionId);
0045 }
0046 
0047 void AppmenuDBus::reconfigure()
0048 {
0049     Q_EMIT reconfigured();
0050 }